🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-04-27 14:45:21 +00:00
parent d0cdaac7d0
commit 80fdefeeea
4 changed files with 78 additions and 70 deletions

View File

@@ -75,7 +75,9 @@ class ReplyGenerator:
self.reply_checker = ReplyChecker(stream_id)
# 修改 generate 方法签名,增加 action_type 参数
async def generate(self, observation_info: ObservationInfo, conversation_info: ConversationInfo, action_type: str) -> str:
async def generate(
self, observation_info: ObservationInfo, conversation_info: ConversationInfo, action_type: str
) -> str:
"""生成回复
Args:
@@ -109,7 +111,7 @@ class ReplyGenerator:
reasoning = str(reasoning) if reasoning is not None else "没有明确原因"
goals_str += f"- 目标:{goal}\n 原因:{reasoning}\n"
else:
goals_str = "- 目前没有明确对话目标\n" # 简化无目标情况
goals_str = "- 目前没有明确对话目标\n" # 简化无目标情况
# 获取聊天历史记录 (chat_history_text)
chat_history_text = observation_info.chat_history_str
@@ -126,7 +128,6 @@ class ReplyGenerator:
elif not chat_history_text:
chat_history_text = "还没有聊天记录。"
# 构建 Persona 文本 (persona_text)
identity_details_only = self.identity_detail_info
identity_addon = ""
@@ -144,18 +145,16 @@ class ReplyGenerator:
persona_text = f"你的名字是{self.name}{self.personality_info}{identity_addon}"
# --- 选择 Prompt ---
if action_type == 'send_new_message':
if action_type == "send_new_message":
prompt_template = PROMPT_SEND_NEW_MESSAGE
logger.info("使用 PROMPT_SEND_NEW_MESSAGE (追问生成)")
else: # 默认使用 direct_reply 的 prompt
else: # 默认使用 direct_reply 的 prompt
prompt_template = PROMPT_DIRECT_REPLY
logger.info("使用 PROMPT_DIRECT_REPLY (首次/非连续回复生成)")
# --- 格式化最终的 Prompt ---
prompt = prompt_template.format(
persona_text=persona_text,
goals_str=goals_str,
chat_history_text=chat_history_text
persona_text=persona_text, goals_str=goals_str, chat_history_text=chat_history_text
)
# --- 调用 LLM 生成 ---
@@ -177,4 +176,4 @@ class ReplyGenerator:
"""检查回复是否合适
(此方法逻辑保持不变)
"""
return await self.reply_checker.check(reply, goal, chat_history, chat_history_str, retry_count)
return await self.reply_checker.check(reply, goal, chat_history, chat_history_str, retry_count)