|
@@ -3,8 +3,8 @@ 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.message import MessageType
|
|
|
from pqai_agent.toolkit.function_tool import FunctionTool
|
|
|
from pqai_agent.toolkit.image_describer import ImageDescriber
|
|
|
from pqai_agent.toolkit.message_notifier import MessageNotifier
|
|
@@ -109,7 +109,7 @@ QUERY_PROMPT_TEMPLATE = """现在,请通过多步思考,以客服的角色
|
|
|
# 当前上下文信息
|
|
|
时间:{current_datetime}
|
|
|
|
|
|
-注意对话信息的格式为: [角色][时间]对话内容
|
|
|
+注意对话的格式为: [角色][时间][消息类型]消息内容
|
|
|
注意分析客服和用户当前的社交阶段,先确立本次问候的目的。
|
|
|
注意一定要分析对话信息中的时间,避免和当前时间段不符的内容!注意一定要结合历史的对话情况进行分析和问候方式的选择!
|
|
|
如有必要,可以使用analyse_image分析用户头像。
|
|
@@ -153,7 +153,8 @@ class MessagePushAgent(SimpleOpenAICompatibleChatAgent):
|
|
|
if msg['role'] not in role_map:
|
|
|
continue
|
|
|
format_dt = datetime.datetime.fromtimestamp(msg['timestamp'] / 1000).strftime('%Y-%m-%d %H:%M:%S')
|
|
|
- messages.append('[{}][{}]{}'.format(role_map[msg['role']], format_dt, msg['content']))
|
|
|
+ msg_type = msg.get('type', MessageType.TEXT).description
|
|
|
+ messages.append('[{}][{}][{}]{}'.format(role_map[msg['role']], format_dt, msg_type, msg['content']))
|
|
|
return '\n'.join(messages)
|
|
|
|
|
|
class DummyMessagePushAgent(MessagePushAgent):
|
|
@@ -197,7 +198,7 @@ if __name__ == '__main__':
|
|
|
}
|
|
|
from pqai_agent.utils import prompt_utils
|
|
|
test_context = {
|
|
|
- "current_datetime": "2025-05-11 08:00:00",
|
|
|
+ "current_datetime": "2025-05-12 08:00:00",
|
|
|
"formatted_staff_profile": prompt_utils.format_agent_profile(test_staff_profile),
|
|
|
**test_user_profile,
|
|
|
}
|
|
@@ -205,10 +206,7 @@ if __name__ == '__main__':
|
|
|
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)},
|
|
|
+ # {"role": "user", "content": "我又不认识你,不要给我发了", "timestamp": create_ts(2025, 5, 10, 8, 30)},
|
|
|
]
|
|
|
response = agent.generate_message(test_context, messages)
|
|
|
- print(response)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ print(response)
|