|
@@ -3,6 +3,7 @@ from typing import Optional, List, Dict
|
|
|
|
|
|
from pqai_agent.agents.simple_chat_agent import SimpleOpenAICompatibleChatAgent
|
|
|
from pqai_agent.chat_service import VOLCENGINE_MODEL_DEEPSEEK_V3
|
|
|
+from pqai_agent.dialogue_manager import DialogueManager
|
|
|
from pqai_agent.logging_service import logger
|
|
|
from pqai_agent.toolkit.function_tool import FunctionTool
|
|
|
from pqai_agent.toolkit.image_describer import ImageDescriber
|
|
@@ -72,7 +73,7 @@ DEFAULT_SYSTEM_PROMPT = '''
|
|
|
</心理学技巧>
|
|
|
|
|
|
<风险规避原则>
|
|
|
-* 避免过度打扰和重复:注意分析历史对话
|
|
|
+* 避免过度打扰和重复:注意分析历史对话,如果用户之前没有回复,48小时内不再问候
|
|
|
* 避免过度解读:不要过度解读用户的信息
|
|
|
* 文化适配:注意不同地域的用户文化差异
|
|
|
* 准确性要求:不要使用虚构的信息
|
|
@@ -89,7 +90,7 @@ You are operating in an agent loop, iteratively completing tasks through these s
|
|
|
</agent_loop>
|
|
|
'''
|
|
|
|
|
|
-QUERY_PROMPT_TEMPLATE = """现在,请通过多步思考,以客服的角色,选择合适的方法向一位用户发起问候。
|
|
|
+QUERY_PROMPT_TEMPLATE = """现在,请通过多步思考,以客服的角色判断是否需要以下用户发起问候并生成问候的内容。
|
|
|
# 客服的基本信息
|
|
|
{formatted_staff_profile}
|
|
|
# 用户的信息
|
|
@@ -112,7 +113,8 @@ QUERY_PROMPT_TEMPLATE = """现在,请通过多步思考,以客服的角色
|
|
|
注意分析客服和用户当前的社交阶段,先确立本次问候的目的。
|
|
|
注意一定要分析对话信息中的时间,避免和当前时间段不符的内容!注意一定要结合历史的对话情况进行分析和问候方式的选择!
|
|
|
如有必要,可以使用analyse_image分析用户头像。
|
|
|
-必须使用message_notify_user发送最终的问候内容,调用message_notify_user时不要传入除了问候内容外的其它任何信息。
|
|
|
+使用message_notify_user发送最终的问候内容,调用时不要传入除了问候内容外的其它任何信息。
|
|
|
+如果无需发起问候,可直接结束,无需调用message_notify_user。
|
|
|
注意每次问候只使用一种话术。
|
|
|
Now, start to process your task. Please think step by step.
|
|
|
"""
|
|
@@ -168,9 +170,23 @@ class DummyMessagePushAgent(MessagePushAgent):
|
|
|
if __name__ == '__main__':
|
|
|
import pqai_agent.logging_service
|
|
|
pqai_agent.logging_service.setup_root_logger()
|
|
|
- agent = MessagePushAgent()
|
|
|
+ from pqai_agent.chat_service import VOLCENGINE_MODEL_DEEPSEEK_V3
|
|
|
+ agent = MessagePushAgent(model=VOLCENGINE_MODEL_DEEPSEEK_V3)
|
|
|
+ test_staff_profile = {
|
|
|
+ "name": "周洁",
|
|
|
+ "gender": "女",
|
|
|
+ "age": 35,
|
|
|
+ "region": "长沙",
|
|
|
+ "previous_location": "老家长沙,北京工作三年",
|
|
|
+ "education": "本科。师范学校毕业",
|
|
|
+ "occupation": "长沙某中学的老师",
|
|
|
+ "work_experience": "大学毕业后三年在北京一家“中老年”教育公司任班主任;北漂三年后,回到家乡任职普通中学的语文老师",
|
|
|
+ "family_members": "父亲;母亲;丈夫;女儿",
|
|
|
+ "family_occupation": "父亲:高中教师(已退休);母亲:经营一家商店;丈夫:知名律所专业律师"
|
|
|
+ }
|
|
|
test_user_profile = {
|
|
|
'name': '薛岱月',
|
|
|
+ 'nickname': '薛岱月',
|
|
|
'avatar': 'http://wx.qlogo.cn/mmhead/Q3auHgzwzM5glpnBtDUianJErYf9AQsptLM3N78xP3sOR8SSibsG35HQ/0',
|
|
|
'preferred_nickname': '月哥',
|
|
|
'age': 65,
|
|
@@ -179,14 +195,17 @@ if __name__ == '__main__':
|
|
|
'medications': ['降压药'],
|
|
|
'interests': ['钓鱼', '旅游']
|
|
|
}
|
|
|
+ from pqai_agent.utils import prompt_utils
|
|
|
test_context = {
|
|
|
- "current_datetime": "2025-05-12 08:00:00",
|
|
|
- **test_user_profile
|
|
|
+ "current_datetime": "2025-05-11 08:00:00",
|
|
|
+ "formatted_staff_profile": prompt_utils.format_agent_profile(test_staff_profile),
|
|
|
+ **test_user_profile,
|
|
|
}
|
|
|
def create_ts(year, month, day, hour, minute):
|
|
|
return datetime.datetime(year, month, day, hour, minute).timestamp() * 1000
|
|
|
messages = [
|
|
|
{"role": "assistant", "content": "月哥,早上好!看到您的头像是一片宁静的户外风景,感觉您一定很喜欢大自然吧?今天天气不错,您有什么计划吗?", "timestamp": create_ts(2025, 5, 10, 8, 0)},
|
|
|
+ {"role": "user", "content": "我又不认识你,不要给我发了", "timestamp": create_ts(2025, 5, 10, 8, 30)},
|
|
|
]
|
|
|
response = agent.generate_message(test_context, messages)
|
|
|
print(response)
|