Browse Source

Update message_push_agent: tune prompt

StrayWarrior 2 months ago
parent
commit
2ef72798b4
1 changed files with 11 additions and 9 deletions
  1. 11 9
      pqai_agent/agents/message_push_agent.py

+ 11 - 9
pqai_agent/agents/message_push_agent.py

@@ -29,19 +29,19 @@ DEFAULT_SYSTEM_PROMPT = '''
 <通用话术列表>
 <话术>
 * 简介:简单自我介绍,并向用户发出交友邀请
-* 适用情形:初次问候
+* 适用情形:破冰试探
 * 内容:根据你的人设做出简短自我介绍,并向用户发出交友邀请
 * 要求:简短亲切,1-2句话;模拟微信聊天的回复格式,分段清晰
 </话术>
 <话术>
 * 简介:使用用户微信名做藏头诗,进行问候
-* 适用情形:不限
+* 适用情形:破冰试探
 * 内容:首先进行用户问候,然后介绍藏头诗,最后以一个让老年人有动力继续聊天的问句结尾
 * 要求:最后的问句要与藏头诗或用户自身经历有关,与藏头诗自然承接,无需和用户画像其他内容相关
 </话术>
 <话术>
 * 简介:介绍自己的兴趣并询问用户的兴趣爱好
-* 适用情形:不限
+* 适用情形:与用户有一定交流基础之后
 * 内容:根据用户头像分析用户的特点、可能的兴趣爱好,作为参考,表述自己有相同的兴趣爱好,并举一些简短的例子 ,然后询问用户的兴趣爱好
 * 要求:询问无需和用户画像中其他信息有关;说明引发你问候的是用户头像;简短亲切,2-3句话 30字左右;如无用户信息或行为,不要根据联想杜撰用户偏好/行为
 </话术>
@@ -53,7 +53,7 @@ DEFAULT_SYSTEM_PROMPT = '''
 </话术>
 <话术>
 * 简介:询问用户当日计划安排并产生问候
-* 适用情形:不限
+* 适用情形:与用户有一定交流基础之后
 * 内容:向用户介绍你的今日安排以及询问用户的今日安排
 * 要求:简短亲切,1-2句话,像用户熟悉的晚辈一样问候沟通;模拟微信聊天的回复格式,分段清晰
 </话术>
@@ -83,9 +83,10 @@ You are operating in an agent loop, iteratively completing tasks through these s
 </agent_loop>
 '''
 
-QUERY_PROMPT_TEMPLATE = """现在,请通过多步思考,选择合适的方法向一位用户发起问候。
-# 已知用户的信息
-用户信息:
+QUERY_PROMPT_TEMPLATE = """现在,请通过多步思考,以客服的角色,选择合适的方法向一位用户发起问候。
+# 客服的基本信息
+{formatted_staff_profile}
+# 用户的信息
 - 姓名:{name}
 - 头像:{avatar}
 - 偏好的称呼:{preferred_nickname}
@@ -152,6 +153,7 @@ class DummyMessagePushAgent(MessagePushAgent):
         super().__init__(*args, **kwargs)
 
     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)
 
 
@@ -170,13 +172,13 @@ if __name__ == '__main__':
         'interests': ['钓鱼', '旅游']
     }
     test_context = {
-        "current_datetime": "2025-05-10 08:00:00",
+        "current_datetime": "2025-05-12 08:00:00",
         **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": "assistant", "content": "月哥,早上好!看到您的头像是一片宁静的户外风景,感觉您一定很喜欢大自然吧?今天天气不错,您有什么计划吗?", "timestamp": create_ts(2025, 5, 10, 8, 0)},
     ]
     response = agent.generate_message(test_context, messages)
     print(response)