|
|
@@ -369,14 +369,17 @@ async def check_timeout_async(task: asyncio.Task, request: Request,token_id, wxi |
|
|
|
print(f"任务运行时间超过{timeout_duration}秒,token_id={token_id}, app_id={app_id}, callback_to_user={callback_to_user}") |
|
|
|
wx_config = await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid) |
|
|
|
if bool(wx_config.get("chatWaitingMsgEnabled", True)): |
|
|
|
if callback_to_user == 'wxid_mesh33pw13e721': |
|
|
|
logger.info(f'wxid_mesh33pw13e721 不发送到微信有关等待的AI回复到微信') |
|
|
|
else: |
|
|
|
phrases = ["稍等一下", "辛苦等等", "马上就好", "很快就好", "请稍后", "请等会", "稍等1分钟","请别急,在整理","就好了"] |
|
|
|
|
|
|
|
# 随机选择一个短语 |
|
|
|
random_phrase = random.choice(phrases) |
|
|
|
await request.app.state.gewe_service.post_text_async(token_id, app_id, callback_to_user, random_phrase) |
|
|
|
# if callback_to_user == 'wxid_mesh33pw13e721': |
|
|
|
# logger.info(f'wxid_mesh33pw13e721 不发送到微信有关等待的AI回复到微信') |
|
|
|
# else: |
|
|
|
# phrases = ["稍等一下", "辛苦等等", "马上就好", "很快就好", "请稍后", "请等会", "稍等1分钟","请别急,在整理","就好了"] |
|
|
|
|
|
|
|
# # 随机选择一个短语 |
|
|
|
# random_phrase = random.choice(phrases) |
|
|
|
# await request.app.state.gewe_service.post_text_async(token_id, app_id, callback_to_user, random_phrase) |
|
|
|
phrases = ["稍等一下", "辛苦等等", "马上就好", "很快就好", "请稍后", "请等会", "稍等1分钟","请别急,在整理","就好了"] |
|
|
|
random_phrase = random.choice(phrases) |
|
|
|
await request.app.state.gewe_service.post_text_async(token_id, app_id, callback_to_user, random_phrase) |
|
|
|
#await request.app.state.gewe_service.post_text_async(token_id, app_id, callback_to_user, "亲,我正在组织回复的信息,请稍等一会") |
|
|
|
|
|
|
|
async def ai_chat_text_async(request: Request,token_id, app_id, wxid, msg_data, msg_content): |
|
|
@@ -457,12 +460,12 @@ async def ai_chat_text_async(request: Request,token_id, app_id, wxid, msg_data, |
|
|
|
} |
|
|
|
reply_content = remove_markdown_symbol(res["choices"][0]["message"]["content"]) |
|
|
|
|
|
|
|
if callback_to_user == 'wxid_mesh33pw13e721': |
|
|
|
logger.info(f'wxid_mesh33pw13e721 不发送到微信有关{msg_content}的AI回复到微信') |
|
|
|
else: |
|
|
|
await request.app.state.gewe_service.post_text_async(token_id, app_id, callback_to_user, reply_content) |
|
|
|
# if callback_to_user == 'wxid_mesh33pw13e721': |
|
|
|
# logger.info(f'wxid_mesh33pw13e721 不发送到微信有关{msg_content}的AI回复到微信') |
|
|
|
# else: |
|
|
|
# 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) |
|
|
|
await request.app.state.gewe_service.save_session_messages_to_cache_async(hash_key, {"role": "assistant", "content": reply_content}) |
|
|
|
# 回复的对话 |
|
|
|
input_wx_content_dialogue_message = [{"type": "text", "text": reply_content}] |
|
|
|