🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -28,7 +28,6 @@ from src.chat.focus_chat.planners.action_manager import ActionManager
|
||||
from src.config.config import global_config
|
||||
from src.chat.focus_chat.hfc_performance_logger import HFCPerformanceLogger
|
||||
from src.chat.focus_chat.hfc_version_manager import get_hfc_version
|
||||
from src.chat.focus_chat.info.structured_info import StructuredInfo
|
||||
from src.person_info.relationship_builder_manager import relationship_builder_manager
|
||||
|
||||
|
||||
@@ -218,8 +217,6 @@ class HeartFChatting:
|
||||
else:
|
||||
logger.warning(f"{self.log_prefix} 没有注册任何处理器。这可能是由于配置错误或所有处理器都被禁用了。")
|
||||
|
||||
|
||||
|
||||
async def start(self):
|
||||
"""检查是否需要启动主循环,如果未激活则启动。"""
|
||||
logger.debug(f"{self.log_prefix} 开始启动 HeartFChatting")
|
||||
@@ -400,8 +397,6 @@ class HeartFChatting:
|
||||
("\n前处理器耗时: " + "; ".join(processor_time_strings)) if processor_time_strings else ""
|
||||
)
|
||||
|
||||
|
||||
|
||||
logger.info(
|
||||
f"{self.log_prefix} 第{self._current_cycle_detail.cycle_id}次思考,"
|
||||
f"耗时: {self._current_cycle_detail.end_time - self._current_cycle_detail.start_time:.1f}秒, "
|
||||
@@ -560,8 +555,6 @@ class HeartFChatting:
|
||||
|
||||
return all_plan_info, processor_time_costs
|
||||
|
||||
|
||||
|
||||
async def _observe_process_plan_action_loop(self, cycle_timers: dict, thinking_id: str) -> dict:
|
||||
try:
|
||||
loop_start_time = time.time()
|
||||
|
||||
@@ -157,20 +157,13 @@ class DefaultReplyer:
|
||||
fallback_config = global_config.model.replyer_1.copy()
|
||||
fallback_config.setdefault("weight", 1.0)
|
||||
self.express_model_configs = [fallback_config]
|
||||
|
||||
|
||||
self.chat_stream = chat_stream
|
||||
self.is_group_chat, self.chat_target_info = get_chat_type_and_target_info(self.chat_stream.stream_id)
|
||||
|
||||
|
||||
self.heart_fc_sender = HeartFCSender()
|
||||
self.memory_activator = MemoryActivator()
|
||||
self.tool_executor = ToolExecutor(
|
||||
chat_id=self.chat_stream.stream_id,
|
||||
enable_cache=True,
|
||||
cache_ttl=3
|
||||
)
|
||||
|
||||
|
||||
|
||||
self.tool_executor = ToolExecutor(chat_id=self.chat_stream.stream_id, enable_cache=True, cache_ttl=3)
|
||||
|
||||
def _select_weighted_model_config(self) -> Dict[str, Any]:
|
||||
"""使用加权随机选择来挑选一个模型配置"""
|
||||
@@ -405,48 +398,45 @@ class DefaultReplyer:
|
||||
|
||||
async def build_tool_info(self, reply_data=None, chat_history=None):
|
||||
"""构建工具信息块
|
||||
|
||||
|
||||
Args:
|
||||
reply_data: 回复数据,包含要回复的消息内容
|
||||
chat_history: 聊天历史
|
||||
|
||||
|
||||
Returns:
|
||||
str: 工具信息字符串
|
||||
"""
|
||||
if not reply_data:
|
||||
return ""
|
||||
|
||||
|
||||
reply_to = reply_data.get("reply_to", "")
|
||||
sender, text = self._parse_reply_target(reply_to)
|
||||
|
||||
|
||||
if not text:
|
||||
return ""
|
||||
|
||||
|
||||
try:
|
||||
# 使用工具执行器获取信息
|
||||
tool_results = await self.tool_executor.execute_from_chat_message(
|
||||
sender = sender,
|
||||
target_message=text,
|
||||
chat_history=chat_history,
|
||||
return_details=False
|
||||
sender=sender, target_message=text, chat_history=chat_history, return_details=False
|
||||
)
|
||||
|
||||
|
||||
if tool_results:
|
||||
tool_info_str = "以下是你通过工具获取到的实时信息:\n"
|
||||
for tool_result in tool_results:
|
||||
tool_name = tool_result.get("tool_name", "unknown")
|
||||
content = tool_result.get("content", "")
|
||||
result_type = tool_result.get("type", "info")
|
||||
|
||||
|
||||
tool_info_str += f"- 【{tool_name}】{result_type}: {content}\n"
|
||||
|
||||
|
||||
tool_info_str += "以上是你获取到的实时信息,请在回复时参考这些信息。"
|
||||
logger.info(f"{self.log_prefix} 获取到 {len(tool_results)} 个工具结果")
|
||||
return tool_info_str
|
||||
else:
|
||||
logger.debug(f"{self.log_prefix} 未获取到任何工具结果")
|
||||
return ""
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"{self.log_prefix} 工具信息获取失败: {e}")
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user