better:PFC 更好的对话结束
This commit is contained in:
@@ -122,7 +122,7 @@ wait: 当你做出了发言,对方尚未回复时暂时等待对方的回复
|
|||||||
listening: 倾听对方发言,当你认为对方发言尚未结束时采用
|
listening: 倾听对方发言,当你认为对方发言尚未结束时采用
|
||||||
direct_reply: 不符合上述情况,回复对方,注意不要过多或者重复发言
|
direct_reply: 不符合上述情况,回复对方,注意不要过多或者重复发言
|
||||||
rethink_goal: 重新思考对话目标,当发现对话目标不合适时选择,会重新思考对话目标
|
rethink_goal: 重新思考对话目标,当发现对话目标不合适时选择,会重新思考对话目标
|
||||||
end_conversation: 结束对话,当你觉得谈话暂时结束时选择,停止该场对话
|
end_conversation: 结束对话,长时间没回复或者当你觉得谈话暂时结束时选择,停止该场对话
|
||||||
|
|
||||||
请以JSON格式输出,包含以下字段:
|
请以JSON格式输出,包含以下字段:
|
||||||
1. action: 行动类型,注意你之前的行为
|
1. action: 行动类型,注意你之前的行为
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ class Conversation:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if action == "direct_reply":
|
if action == "direct_reply":
|
||||||
|
self.waiter.wait_accumulated_time = 0
|
||||||
|
|
||||||
self.state = ConversationState.GENERATING
|
self.state = ConversationState.GENERATING
|
||||||
self.generated_reply = await self.reply_generator.generate(observation_info, conversation_info)
|
self.generated_reply = await self.reply_generator.generate(observation_info, conversation_info)
|
||||||
print(f"生成回复: {self.generated_reply}")
|
print(f"生成回复: {self.generated_reply}")
|
||||||
@@ -181,6 +183,8 @@ class Conversation:
|
|||||||
)
|
)
|
||||||
|
|
||||||
elif action == "fetch_knowledge":
|
elif action == "fetch_knowledge":
|
||||||
|
self.waiter.wait_accumulated_time = 0
|
||||||
|
|
||||||
self.state = ConversationState.FETCHING
|
self.state = ConversationState.FETCHING
|
||||||
knowledge = "TODO:知识"
|
knowledge = "TODO:知识"
|
||||||
topic = "TODO:关键词"
|
topic = "TODO:关键词"
|
||||||
@@ -194,6 +198,8 @@ class Conversation:
|
|||||||
self.conversation_info.knowledge_list[topic] += knowledge
|
self.conversation_info.knowledge_list[topic] += knowledge
|
||||||
|
|
||||||
elif action == "rethink_goal":
|
elif action == "rethink_goal":
|
||||||
|
self.waiter.wait_accumulated_time = 0
|
||||||
|
|
||||||
self.state = ConversationState.RETHINKING
|
self.state = ConversationState.RETHINKING
|
||||||
await self.goal_analyzer.analyze_goal(conversation_info, observation_info)
|
await self.goal_analyzer.analyze_goal(conversation_info, observation_info)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class Waiter:
|
|||||||
self.personality_info = Individuality.get_instance().get_prompt(type="personality", x_person=2, level=2)
|
self.personality_info = Individuality.get_instance().get_prompt(type="personality", x_person=2, level=2)
|
||||||
self.name = global_config.BOT_NICKNAME
|
self.name = global_config.BOT_NICKNAME
|
||||||
|
|
||||||
|
self.wait_accumulated_time = 0
|
||||||
|
|
||||||
async def wait(self, conversation_info: ConversationInfo) -> bool:
|
async def wait(self, conversation_info: ConversationInfo) -> bool:
|
||||||
"""等待
|
"""等待
|
||||||
|
|
||||||
@@ -34,10 +36,12 @@ class Waiter:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# 检查是否超时
|
# 检查是否超时
|
||||||
if time.time() - wait_start_time > 15:
|
if time.time() - wait_start_time > 300:
|
||||||
|
self.wait_accumulated_time += 300
|
||||||
|
|
||||||
logger.info("等待超过300秒,结束对话")
|
logger.info("等待超过300秒,结束对话")
|
||||||
wait_goal = {
|
wait_goal = {
|
||||||
"goal": "你等待了5分钟,思考接下来要做什么",
|
"goal": f"你等待了{self.wait_accumulated_time/60}分钟,思考接下来要做什么",
|
||||||
"reason": "对方很久没有回复你的消息了"
|
"reason": "对方很久没有回复你的消息了"
|
||||||
}
|
}
|
||||||
conversation_info.goal_list.append(wait_goal)
|
conversation_info.goal_list.append(wait_goal)
|
||||||
@@ -65,10 +69,11 @@ class Waiter:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# 检查是否超时
|
# 检查是否超时
|
||||||
if time.time() - wait_start_time > 30:
|
if time.time() - wait_start_time > 300:
|
||||||
|
self.wait_accumulated_time += 300
|
||||||
logger.info("等待超过300秒,结束对话")
|
logger.info("等待超过300秒,结束对话")
|
||||||
wait_goal = {
|
wait_goal = {
|
||||||
"goal": "你等待了5分钟,思考接下来要做什么",
|
"goal": f"你等待了{self.wait_accumulated_time/60}分钟,思考接下来要做什么",
|
||||||
"reason": "对方话说一半消失了,很久没有回复"
|
"reason": "对方话说一半消失了,很久没有回复"
|
||||||
}
|
}
|
||||||
conversation_info.goal_list.append(wait_goal)
|
conversation_info.goal_list.append(wait_goal)
|
||||||
|
|||||||
Reference in New Issue
Block a user