From 122decec012c2ef9de8064fd0f3655386939b088 Mon Sep 17 00:00:00 2001 From: H Vs Date: Tue, 6 May 2025 17:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E6=B7=BB=E5=8A=A0=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E9=80=9A=E7=9F=A5=EF=BC=8C=E6=98=AF=E5=90=A6=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E7=BE=A4=E8=81=8A=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/endpoints/pipeline_endpoint.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/endpoints/pipeline_endpoint.py b/app/endpoints/pipeline_endpoint.py index 2395d5c..56babc9 100644 --- a/app/endpoints/pipeline_endpoint.py +++ b/app/endpoints/pipeline_endpoint.py @@ -1368,6 +1368,18 @@ async def handle_add_friend_notice_async(request: Request,token_id,app_id, wxid, if ret==200: logger.info('自动添加好友成功') + # 保存好友信息 + await request.app.state.gewe_service.save_contacts_brief_to_cache_async(token_id,app_id, wxid,[to_contact_wxid]) + + + # 判断是否开启了 + config=await request.app.state.gewe_service.get_wxchat_config_from_cache_async(wxid) + validated_config = AgentConfig.model_validate(config) + + if not validated_config.privateGroupChatEnabled: + logger.warning(f"智能体微信号 {wxid} 关闭好友和群自动回复功能,{handle_text_async.__name__} 不回复消息") + return + # 好友发送的文字 hash_key = f'__AI_OPS_WX__:MESSAGES:{wxid}:{to_contact_wxid}' prompt={"role": "user", "content": [{"type": "text","text": msg_content}]} @@ -1382,8 +1394,7 @@ async def handle_add_friend_notice_async(request: Request,token_id,app_id, wxid, res=await gpt_client_async(request,messages_to_send,wxid,callback_to_user) reply_content=remove_markdown_symbol(res["choices"][0]["message"]["content"]) - #保存好友信息 - await request.app.state.gewe_service.save_contacts_brief_to_cache_async(token_id,app_id, wxid,[to_contact_wxid]) + if reply_content == '不回复': logger.warning(f"加好友消息,AI回答<不回复>,跳过微信加好友打招呼消息回复")