将PFC加回来,修复一大堆PFC的神秘报错

This commit is contained in:
墨梓柒
2026-01-16 03:36:25 +08:00
parent 77725ba9d8
commit 7bdd394bf0
17 changed files with 303 additions and 286 deletions

View File

@@ -1,12 +1,12 @@
from typing import List, Tuple, TYPE_CHECKING
from src.common.logger import get_module_logger
from src.common.logger import get_logger
from src.llm_models.utils_model import LLMRequest
from src.config.config import global_config
from src.config.config import global_config, model_config
import random
from .chat_observer import ChatObserver
from .pfc_utils import get_items_from_json
from .conversation_info import ConversationInfo
from .observation_info import ObservationInfo
from .observation_info import ObservationInfo, dict_to_database_message
from src.chat.utils.chat_message_builder import build_readable_messages
from rich.traceback import install
@@ -15,7 +15,7 @@ install(extra_lines=3)
if TYPE_CHECKING:
pass
logger = get_module_logger("pfc")
logger = get_logger("pfc")
def _calculate_similarity(goal1: str, goal2: str) -> float:
@@ -43,12 +43,12 @@ class GoalAnalyzer:
def __init__(self, stream_id: str, private_name: str):
self.llm = LLMRequest(
model=global_config.llm_normal, temperature=0.7, max_tokens=1000, request_type="conversation_goal"
model_set=model_config.model_task_config.planner, request_type="conversation_goal"
)
self.personality_info = self._get_personality_prompt()
self.name = global_config.BOT_NICKNAME
self.nick_name = global_config.BOT_ALIAS_NAMES
self.name = global_config.bot.nickname
self.nick_name = global_config.bot.alias_names
self.private_name = private_name
self.chat_observer = ChatObserver.get_instance(stream_id, private_name)
@@ -105,10 +105,10 @@ class GoalAnalyzer:
if observation_info.new_messages_count > 0:
new_messages_list = observation_info.unprocessed_messages
new_messages_str = await build_readable_messages(
new_messages_list,
db_messages = [dict_to_database_message(m) for m in new_messages_list]
new_messages_str = build_readable_messages(
db_messages,
replace_bot_name=True,
merge_messages=False,
timestamp_mode="relative",
read_mark=0.0,
)
@@ -189,7 +189,9 @@ class GoalAnalyzer:
else:
# 单个目标的情况
conversation_info.goal_list.append(result)
return goal, "", reasoning
goal_value = result.get("goal", "")
reasoning_value = result.get("reasoning", "")
return goal_value, "", reasoning_value
# 如果解析失败,返回默认值
return "", "", ""
@@ -238,10 +240,10 @@ class GoalAnalyzer:
async def analyze_conversation(self, goal, reasoning):
messages = self.chat_observer.get_cached_messages()
chat_history_text = await build_readable_messages(
messages,
db_messages = [dict_to_database_message(m) for m in messages]
chat_history_text = build_readable_messages(
db_messages,
replace_bot_name=True,
merge_messages=False,
timestamp_mode="relative",
read_mark=0.0,
)