浏览代码

Udpate agents: remove test code in __main__

StrayWarrior 3 周之前
父节点
当前提交
912fd5e743
共有 2 个文件被更改,包括 4 次插入102 次删除
  1. 3 47
      pqai_agent/agents/message_push_agent.py
  2. 1 55
      pqai_agent/agents/message_reply_agent.py

+ 3 - 47
pqai_agent/agents/message_push_agent.py

@@ -56,7 +56,7 @@ DEFAULT_SYSTEM_PROMPT = '''
 * 简介:对用户进行节日/节气相关问候
 * 适用情形:不限
 * 内容:结合具体节假日及其习俗产生问候,以一个让老年人有动力继续聊天的问句结尾,与前面的问候自然承接
-* 要求:根据今日或近日实际日期,不要假设日期和节日;忽略小众节假日,和根据最近的节假日产生问候,如临近或刚过完重要节日,可询问节日安排或节日经历;简短亲切,2-3句话 30字左右;如无用户信息或行为,不要根据联想杜撰用户偏好/行为
+* 要求:根据实际日期,不要假设日期和节日;忽略小众节假日,和根据最近的节假日产生问候,如临近或刚过完重要节日,可询问节日安排或节日经历;简短亲切,2-3句话 30字左右;如无用户信息或行为,不要根据联想杜撰用户偏好/行为
 </话术>
 <话术>
 * 简介:询问用户当日计划安排并产生问候
@@ -130,7 +130,7 @@ class MessagePushAgent(SimpleOpenAICompatibleChatAgent):
         tools = tools.copy()
         tools.extend([
             *ImageDescriber().get_tools(),
-            *MessageNotifier().get_tools()
+            *MessageNotifier().get_tools(),
         ])
         super().__init__(model, system_prompt, tools, generate_cfg, max_run_step)
 
@@ -165,48 +165,4 @@ class DummyMessagePushAgent(MessagePushAgent):
 
     def generate_message(self, context: Dict, dialogue_history: List[Dict]) -> str:
         logger.debug(f"DummyMessagePushAgent.generate_message called, context: {context}")
-        return "测试消息: {agent_name} -> {nickname}".format(**context)
-
-
-if __name__ == '__main__':
-    import pqai_agent.logging_service
-    pqai_agent.logging_service.setup_root_logger()
-    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,
-        'region': '北京',
-        'health_conditions': '高血压',
-        'medications': ['降压药'],
-        'interests': ['钓鱼', '旅游']
-    }
-    from pqai_agent.utils import prompt_utils
-    test_context = {
-        "current_datetime": "2025-05-12 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)
+        return "测试消息: {agent_name} -> {nickname}".format(**context)

+ 1 - 55
pqai_agent/agents/message_reply_agent.py

@@ -132,58 +132,4 @@ class DummyMessageReplyAgent(MessageReplyAgent):
 
     def generate_message(self, context: Dict, dialogue_history: List[Dict]) -> str:
         logger.debug(f"DummyMessageReplyAgent.generate_message called, context: {context}")
-        return "测试消息: {agent_name} -> {nickname}".format(**context)
-
-
-if __name__ == '__main__':
-    import pqai_agent.logging_service
-    pqai_agent.logging_service.setup_root_logger()
-    from pqai_agent.chat_service import VOLCENGINE_MODEL_DEEPSEEK_V3
-    from pqai_agent.toolkit.pq_video_searcher import PQVideoSearcher
-    agent = MessageReplyAgent(model=VOLCENGINE_MODEL_DEEPSEEK_V3,
-                              tools=[*PQVideoSearcher().get_tools()])
-    query = """
-现在,请以客服的角色分析以下会话并生成给用户的回复。
-# 客服的基本信息
-- 名字:周洁
-- 性别:女
-- 年龄:35
-- 所在地:长沙
-- 之前所在地:老家长沙,北京工作三年
-- 学历:本科。师范学校毕业
-- 职业:长沙某中学的老师
-- 工作经历:大学毕业后三年在北京一家“中老年”教育公司任班主任;北漂三年后,回到家乡任职普通中学的语文老师
-- 家庭成员:父亲;母亲;丈夫;女儿
-- 家庭成员职业:父亲:高中教师(已退休);母亲:经营一家商店;丈夫:知名律所专业律师
-# 用户的信息
-- 微信昵称:薛岱月
-- 姓名:薛岱月
-- 头像:http://wx.qlogo.cn/mmhead/Q3auHgzwzM5glpnBtDUianJErYf9AQsptLM3N78xP3sOR8SSibsG35HQ/0
-- 偏好的称呼:月哥
-- 年龄:65
-- 地区:北京
-- 健康状况:
-- 用药信息:[]
-- 兴趣爱好:[]
-# 已知过去的对话
-[用户][2025-05-20 21:58:24][文本]我喜欢跑步
-[客服][2025-05-20 21:58:52][文本]大哥,跑步是特别棒的爱好呢!既锻炼了身体,又能让人心情愉悦~最近有去哪里跑步呀?
-[用户][2025-05-20 21:59:05][文本]我要睡觉了
-[用户][2025-05-20 21:59:13][表情包]http://dl.weshineapp.com/gif/20250503/a7a5afcefa8bc7d293c2d0bfde0007be.gif?id=a7a5afcefa8bc7d293c2d0bfde0007be
-[客服][2025-05-20 21:59:15][文本]晚安啦
-[用户][2025-05-20 21:59:52][文本]晚安
-# 当前上下文信息
-时间:2025-05-20 22:00:00
-
-注意对话信息的格式为: [角色][时间][消息类型]对话内容
-注意分析客服和用户当前的社交阶段,先确立对话的目的。
-注意一定要分析对话信息中的时间,避免和当前时间段不符的内容!注意一定要结合历史的对话情况进行分析和问候方式的选择!
-使用output_multimodal_message发送最终的回复消息,如果有多条消息需要发送,可以多次调用output_multimodal_message,请务必保证所有回复内容都通过output_multimodal_message发出。
-请注意这是微信聊天,如果用户使用了表情包,请使用analyse_image描述表情包,并分析其含义和情绪,如果要回复请尽量用简短的emoji或文字进行回复。
-特殊情况处理:
-如果用户连续2次以上感到疑惑,请先发送<人工介入>,后接你认为需要人工介入的原因。如果判断对话可自然结束、无需再回复用户,请发送<结束>。如果用户表现出强烈的负向情绪、要求不再对话,请发送<负向情绪结束>。
-以上特殊情况的消息发送请使用message_notify_user。
-Now, start to process your task. Please think step by step.
-"""
-    response = agent.run(query)
-    print(response)
+        return "测试消息: {agent_name} -> {nickname}".format(**context)