|
@@ -433,7 +433,6 @@ class ToTextBotAgent:
|
|
if user_asr_text != 'ASR408error':
|
|
if user_asr_text != 'ASR408error':
|
|
self.call_agent.inter_action_total += 1
|
|
self.call_agent.inter_action_total += 1
|
|
# 发送请求并处理响应
|
|
# 发送请求并处理响应
|
|
- # self.test_request(self.request_data)
|
|
|
|
self.to_quest(self.request_data)
|
|
self.to_quest(self.request_data)
|
|
|
|
|
|
|
|
|
|
@@ -495,64 +494,6 @@ class ToTextBotAgent:
|
|
parsed_response = ChatMessage.from_json(response)
|
|
parsed_response = ChatMessage.from_json(response)
|
|
return parsed_response
|
|
return parsed_response
|
|
|
|
|
|
-# 模拟接口请求返回
|
|
|
|
- def test_request(self, params: BotChatRequest):
|
|
|
|
- self.call_agent.logger.info("test_request::params= %s", params)
|
|
|
|
- response_data = {
|
|
|
|
- "node_id": "1.0",
|
|
|
|
- "contents": [],
|
|
|
|
- "wait_time": "6",
|
|
|
|
- "action": {
|
|
|
|
- "action_code": "normal",
|
|
|
|
- "action_content": "正常通话"
|
|
|
|
- },
|
|
|
|
- "inputType": "0"
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- self.call_agent.logger.info("asrText: %s", params.asrText)
|
|
|
|
- if params.asrText == 'start': #欢迎语
|
|
|
|
- response_data['contents'].append({
|
|
|
|
- "content_type": "voice",
|
|
|
|
- "content": "",
|
|
|
|
- "voice_url": '/code/src/core/voip/scripts/1_00.wav',
|
|
|
|
- "voice_content": "五一北京到上海的高铁票还有吗?"
|
|
|
|
- })
|
|
|
|
- response_data['inputType'] = '1.0'
|
|
|
|
- elif params.asrText == 'ASR408error': #超时执行
|
|
|
|
- response_data['contents'].append({
|
|
|
|
- "content_type": "voice",
|
|
|
|
- "content": "",
|
|
|
|
- "voice_url": '/code/src/core/voip/scripts/4_00.wav',
|
|
|
|
- "voice_content": "waitTime超时"
|
|
|
|
- })
|
|
|
|
- elif "DTMF" in params.asrText and self.call_agent.inputType =='1.0': #长按键超30s执行
|
|
|
|
- response_data['contents'].append({
|
|
|
|
- "content_type": "voice",
|
|
|
|
- "content": "",
|
|
|
|
- "voice_url": '/code/src/core/voip/scripts/2_00.wav',
|
|
|
|
- "voice_content": "sds"
|
|
|
|
- })
|
|
|
|
- else :
|
|
|
|
- response_data['contents'] = [
|
|
|
|
- {
|
|
|
|
- "content_type": "voice",
|
|
|
|
- "content": "",
|
|
|
|
- "voice_url": '/code/src/core/voip/test111.wav',
|
|
|
|
- "voice_content": "测试第二个录音文件"
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "content_type": "voice",
|
|
|
|
- "content": "",
|
|
|
|
- "voice_url": '/code/src/core/voip/test222.wav',
|
|
|
|
- "voice_content": "五一北京到上海的高铁票还有吗?"
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- try:
|
|
|
|
- parsed_response = ChatMessage.from_json(response_data)
|
|
|
|
- self.call_agent.message_queue.put(parsed_response)
|
|
|
|
- except Exception as e:
|
|
|
|
- traceback.print_exc() # 打印完整的错误信息
|
|
|
|
- return None
|
|
|
|
|
|
|
|
@singleton_keys
|
|
@singleton_keys
|
|
class BotAgent:
|
|
class BotAgent:
|