浏览代码

调整ai对话

develop
H Vs 4 天前
父节点
当前提交
d134b1275a
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. +4
    -4
      app/endpoints/pipeline_endpoint.py

+ 4
- 4
app/endpoints/pipeline_endpoint.py 查看文件

@@ -402,7 +402,7 @@ async def handle_text_async(request: Request,token_id,app_id, wxid,msg_data,from
callback_to_user=msg_data["FromUserName"]["string"] callback_to_user=msg_data["FromUserName"]["string"]


# 判断哪些关键词存在于 msg_content 中 # 判断哪些关键词存在于 msg_content 中
keywords = ["预约", "报价", "购买", "价钱"]
keywords = ["预约", "报价", "购买", "价钱","价格", "多少钱", "下单"]
found_keywords = [keyword for keyword in keywords if keyword in msg_content] found_keywords = [keyword for keyword in keywords if keyword in msg_content]
if found_keywords: if found_keywords:
await request.app.state.gewe_service.set_human_handle_msg_with_contact_wxid_async(wxid,callback_to_user,60*30) await request.app.state.gewe_service.set_human_handle_msg_with_contact_wxid_async(wxid,callback_to_user,60*30)
@@ -625,11 +625,11 @@ async def ai_chat_text_async(request: Request,token_id, app_id, wxid, msg_data,
if ret!=200: if ret!=200:
logger.warning(f'{wxid} 发送视频{video_url} 到 {callback_to_user} 失败,{ret_msg}') logger.warning(f'{wxid} 发送视频{video_url} 到 {callback_to_user} 失败,{ret_msg}')
await asyncio.sleep(random.uniform(1.5, 3)) await asyncio.sleep(random.uniform(1.5, 3))
# 发送AI微信回复 # 发送AI微信回复
#await request.app.state.gewe_service.post_text_async(token_id, app_id, callback_to_user, reply_content) #await request.app.state.gewe_service.post_text_async(token_id, app_id, callback_to_user, reply_content)
async with message_lock:
await ai_post_text_split_async_async(request, token_id, app_id, callback_to_user, reply_content)
if (not video_urls) and (not img_urls):
async with message_lock:
await ai_post_text_split_async_async(request, token_id, app_id, callback_to_user, reply_content)
await request.app.state.gewe_service.save_session_messages_to_cache_async(hash_key, {"role": "assistant", "content": reply_content}) await request.app.state.gewe_service.save_session_messages_to_cache_async(hash_key, {"role": "assistant", "content": reply_content})
# 回复的对话 # 回复的对话


正在加载...
取消
保存