Niki Zhang commited on
Commit
60cb9b0
·
verified ·
1 Parent(s): 4da0523

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -767,11 +767,14 @@ def update_click_state(click_state, caption, click_mode):
767
  async def chat_input_callback(*args):
768
  visual_chatgpt, chat_input, click_state, state, aux_state ,language , autoplay,gender,api_key,image_input = args
769
  message = chat_input["text"]
770
- prompt="Please help me answer the question with this painting."
 
771
  state = state + [(message,None)]
772
  if visual_chatgpt is not None:
773
  result=get_gpt_response(api_key, image_input,prompt+message)
774
  state = state + [(None, result)]
 
 
775
  # state, _, aux_state, _ = visual_chatgpt.run_text(message, state, aux_state)
776
  last_text, last_response = state[-1]
777
  print("last response",last_response)
@@ -779,7 +782,7 @@ async def chat_input_callback(*args):
779
  return state, state, aux_state, None
780
 
781
  else:
782
- audio = await texttospeech(last_response,language,autoplay,gender)
783
  return state, state, aux_state, audio
784
  else:
785
  response = "Text refiner is not initilzed, please input openai api key."
 
767
  async def chat_input_callback(*args):
768
  visual_chatgpt, chat_input, click_state, state, aux_state ,language , autoplay,gender,api_key,image_input = args
769
  message = chat_input["text"]
770
+ prompt="Please help me answer the question with this painting {question} in {language}."
771
+ prompt=prompt.format(question=message, language=language)
772
  state = state + [(message,None)]
773
  if visual_chatgpt is not None:
774
  result=get_gpt_response(api_key, image_input,prompt+message)
775
  state = state + [(None, result)]
776
+ read_info = re.sub(r'[#[\]!*]','',result)
777
+ read_info = emoji.replace_emoji(read_info,replace="")
778
  # state, _, aux_state, _ = visual_chatgpt.run_text(message, state, aux_state)
779
  last_text, last_response = state[-1]
780
  print("last response",last_response)
 
782
  return state, state, aux_state, None
783
 
784
  else:
785
+ audio = await texttospeech(read_info,language,autoplay,gender)
786
  return state, state, aux_state, audio
787
  else:
788
  response = "Text refiner is not initilzed, please input openai api key."