DiamondYin commited on
Commit
f4adc69
1 Parent(s): f1b6383

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -27,7 +27,7 @@ BUZZ_TIMEOUT = 60
27
 
28
  global MESSAGES
29
 
30
- GENERAL_RSPONSE_TRIGGERS = ["不好意思,我没有找到相关信息,你可以继续问其他问题"]
31
  MESSAGES = [{"role": "system", "content": "你现在是一个优秀的展览馆讲解员,你可以通过文字或语音与客户交流,你可以讲述上海老建筑和历史人物之间的关系。"}]
32
  LOGGER = logging.getLogger('voice_agent') #日志
33
  AUDIO_HTML = ''
@@ -108,7 +108,8 @@ def get_response(history, audio_input):
108
  del MESSAGES[1]
109
  conv_history_tokens = num_tokens_from_messages(MESSAGES)
110
  print("conv_history_tokens_ajust: ", conv_history_tokens)
111
-
 
112
  for trigger in GENERAL_RSPONSE_TRIGGERS:
113
  if trigger in answer:
114
  MESSAGES.append({"role": "user", "content": question})
@@ -124,7 +125,6 @@ def get_response(history, audio_input):
124
  MESSAGES.append({"role": "assistant", "content": answer})
125
  LOGGER.info("general_response: %s", answer)
126
  print('\ngeneral_response:', answer)
127
-
128
  AUDIO_HTML = text_to_speech_gen(answer)
129
  history[-1][1] = answer
130
 
 
27
 
28
  global MESSAGES
29
 
30
+ GENERAL_RSPONSE_TRIGGERS = ["I don't understand the question.", "I don't know", "Hello, my name is", "mentioned in the context provided"]
31
  MESSAGES = [{"role": "system", "content": "你现在是一个优秀的展览馆讲解员,你可以通过文字或语音与客户交流,你可以讲述上海老建筑和历史人物之间的关系。"}]
32
  LOGGER = logging.getLogger('voice_agent') #日志
33
  AUDIO_HTML = ''
 
108
  del MESSAGES[1]
109
  conv_history_tokens = num_tokens_from_messages(MESSAGES)
110
  print("conv_history_tokens_ajust: ", conv_history_tokens)
111
+ MESSAGES.append({"role": "user", "content": question})
112
+ MESSAGES.append({"role": "assistant", "content": answer})
113
  for trigger in GENERAL_RSPONSE_TRIGGERS:
114
  if trigger in answer:
115
  MESSAGES.append({"role": "user", "content": question})
 
125
  MESSAGES.append({"role": "assistant", "content": answer})
126
  LOGGER.info("general_response: %s", answer)
127
  print('\ngeneral_response:', answer)
 
128
  AUDIO_HTML = text_to_speech_gen(answer)
129
  history[-1][1] = answer
130