🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -660,7 +660,6 @@ class HeartFChatting:
|
||||
}
|
||||
|
||||
with Timer("执行动作", cycle_timers):
|
||||
|
||||
action_type, action_data, reasoning = (
|
||||
plan_result.get("action_result", {}).get("action_type", "error"),
|
||||
plan_result.get("action_result", {}).get("action_data", {}),
|
||||
@@ -675,7 +674,7 @@ class HeartFChatting:
|
||||
action_str = action_type
|
||||
|
||||
logger.debug(f"{self.log_prefix} 麦麦想要:'{action_str}'")
|
||||
|
||||
|
||||
success, reply_text, command = await self._handle_action(
|
||||
action_type, reasoning, action_data, cycle_timers, thinking_id
|
||||
)
|
||||
|
||||
@@ -80,7 +80,7 @@ class ObsInfo(InfoBase):
|
||||
chat_target (str): 聊天目标,可以是 "private"(私聊)、"group"(群聊)或 "other"(其他)
|
||||
"""
|
||||
self.data["chat_target"] = chat_target
|
||||
|
||||
|
||||
def set_chat_id(self, chat_id: str) -> None:
|
||||
"""设置聊天ID
|
||||
|
||||
@@ -88,7 +88,7 @@ class ObsInfo(InfoBase):
|
||||
chat_id (str): 聊天ID
|
||||
"""
|
||||
self.data["chat_id"] = chat_id
|
||||
|
||||
|
||||
def get_chat_id(self) -> Optional[str]:
|
||||
"""获取聊天ID
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class ExpressionSelectorProcessor(BaseProcessor):
|
||||
if observations:
|
||||
for observation in observations:
|
||||
if isinstance(observation, ChattingObservation):
|
||||
# chat_info = observation.get_observe_info()
|
||||
# chat_info = observation.get_observe_info()
|
||||
chat_info = observation.talking_message_str_truncate_short
|
||||
break
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ def init_prompt():
|
||||
""",
|
||||
"simple_planner_prompt",
|
||||
)
|
||||
|
||||
|
||||
Prompt(
|
||||
"""
|
||||
{time_block}
|
||||
@@ -62,19 +62,19 @@ def init_prompt():
|
||||
"simple_planner_prompt_private",
|
||||
)
|
||||
|
||||
# Prompt(
|
||||
# """
|
||||
# 动作:{action_name}
|
||||
# 该动作的描述:{action_description}
|
||||
# 使用该动作的场景:
|
||||
# {action_require}
|
||||
# 输出要求:
|
||||
# {{
|
||||
# "action": "{action_name}",{action_parameters}
|
||||
# }}
|
||||
# """,
|
||||
# "action_prompt",
|
||||
# )
|
||||
# Prompt(
|
||||
# """
|
||||
# 动作:{action_name}
|
||||
# 该动作的描述:{action_description}
|
||||
# 使用该动作的场景:
|
||||
# {action_require}
|
||||
# 输出要求:
|
||||
# {{
|
||||
# "action": "{action_name}",{action_parameters}
|
||||
# }}
|
||||
# """,
|
||||
# "action_prompt",
|
||||
# )
|
||||
Prompt(
|
||||
"""
|
||||
{action_require}
|
||||
@@ -84,7 +84,7 @@ def init_prompt():
|
||||
""",
|
||||
"action_prompt",
|
||||
)
|
||||
|
||||
|
||||
Prompt(
|
||||
"""
|
||||
{action_require}
|
||||
@@ -96,7 +96,6 @@ def init_prompt():
|
||||
)
|
||||
|
||||
|
||||
|
||||
class ActionPlanner(BasePlanner):
|
||||
def __init__(self, log_prefix: str, action_manager: ActionManager):
|
||||
super().__init__(log_prefix, action_manager)
|
||||
@@ -141,7 +140,7 @@ class ActionPlanner(BasePlanner):
|
||||
relation_info = ""
|
||||
selected_expressions = []
|
||||
chat_id = None # 添加chat_id变量
|
||||
|
||||
|
||||
for info in all_plan_info:
|
||||
if isinstance(info, ObsInfo):
|
||||
observed_messages = info.get_talking_message()
|
||||
@@ -170,7 +169,9 @@ class ActionPlanner(BasePlanner):
|
||||
# 如果获取成功,更新is_group_chat
|
||||
if is_group_chat_updated is not None:
|
||||
is_group_chat = is_group_chat_updated
|
||||
logger.debug(f"{self.log_prefix}获取到聊天信息 - 群聊: {is_group_chat}, 目标信息: {chat_target_info}")
|
||||
logger.debug(
|
||||
f"{self.log_prefix}获取到聊天信息 - 群聊: {is_group_chat}, 目标信息: {chat_target_info}"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"{self.log_prefix}获取聊天目标信息失败: {e}")
|
||||
chat_target_info = None
|
||||
@@ -372,7 +373,7 @@ class ActionPlanner(BasePlanner):
|
||||
action_options_block = ""
|
||||
# 根据聊天类型选择不同的动作prompt模板
|
||||
action_template_name = "action_prompt_private" if not is_group_chat else "action_prompt"
|
||||
|
||||
|
||||
for using_actions_name, using_actions_info in current_available_actions.items():
|
||||
using_action_prompt = await global_prompt_manager.get_prompt_async(action_template_name)
|
||||
|
||||
|
||||
@@ -232,11 +232,11 @@ class ChattingObservation(Observation):
|
||||
truncate=True,
|
||||
show_actions=True,
|
||||
)
|
||||
|
||||
|
||||
# 构建简短版本 - 使用最新一半的消息
|
||||
half_count = len(self.talking_message) // 2
|
||||
recent_messages = self.talking_message[-half_count:] if half_count > 0 else self.talking_message
|
||||
|
||||
|
||||
self.talking_message_str_short = build_readable_messages(
|
||||
messages=recent_messages,
|
||||
timestamp_mode="lite",
|
||||
|
||||
Reference in New Issue
Block a user