better:简化配置,让关系构建间隔可配置
This commit is contained in:
@@ -33,9 +33,9 @@ class MemoryManager:
|
||||
self._id_map: Dict[str, MemoryItem] = {}
|
||||
|
||||
self.llm_summarizer = LLMRequest(
|
||||
model=global_config.model.focus_working_memory,
|
||||
model=global_config.model.memory,
|
||||
temperature=0.3,
|
||||
request_type="focus.processor.working_memory",
|
||||
request_type="working_memory",
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
@@ -57,15 +57,10 @@ class RelationshipConfig(ConfigBase):
|
||||
"""关系配置类"""
|
||||
|
||||
enable_relationship: bool = True
|
||||
|
||||
give_name: bool = False
|
||||
"""是否给其他人取名"""
|
||||
|
||||
build_relationship_interval: int = 600
|
||||
"""构建关系间隔 单位秒,如果为0则不构建关系"""
|
||||
"""是否启用关系系统"""
|
||||
|
||||
relation_frequency: int = 1
|
||||
"""关系频率,麦麦构建关系的速度,仅在normal_chat模式下有效"""
|
||||
"""关系频率,麦麦构建关系的速度"""
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -636,33 +631,18 @@ class ModelConfig(ConfigBase):
|
||||
|
||||
replyer_2: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""normal_chat次要回复模型配置"""
|
||||
|
||||
memory_summary: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""记忆的概括模型配置"""
|
||||
|
||||
memory: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""记忆模型配置"""
|
||||
|
||||
vlm: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""视觉语言模型配置"""
|
||||
|
||||
focus_working_memory: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""专注工作记忆模型配置"""
|
||||
|
||||
tool_use: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""专注工具使用模型配置"""
|
||||
|
||||
planner: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""规划模型配置"""
|
||||
|
||||
relation: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""关系模型配置"""
|
||||
|
||||
embedding: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""嵌入模型配置"""
|
||||
|
||||
pfc_action_planner: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""PFC动作规划模型配置"""
|
||||
|
||||
pfc_chat: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""PFC聊天模型配置"""
|
||||
|
||||
pfc_reply_checker: dict[str, Any] = field(default_factory=lambda: {})
|
||||
"""PFC回复检查模型配置"""
|
||||
"""嵌入模型配置"""
|
||||
@@ -36,7 +36,7 @@ class S4UStreamGenerator:
|
||||
raise ValueError("`replyer_1` 在配置文件中缺少 `model_name` 字段")
|
||||
self.replyer_1_config = replyer_1_config
|
||||
|
||||
self.model_sum = LLMRequest(model=global_config.model.memory_summary, temperature=0.7, request_type="relation")
|
||||
|
||||
self.current_model_name = "unknown model"
|
||||
self.partial_response = ""
|
||||
|
||||
|
||||
@@ -20,11 +20,13 @@ logger = get_logger("relationship_builder")
|
||||
# 消息段清理配置
|
||||
SEGMENT_CLEANUP_CONFIG = {
|
||||
"enable_cleanup": True, # 是否启用清理
|
||||
"max_segment_age_days": 7, # 消息段最大保存天数
|
||||
"max_segment_age_days": 3, # 消息段最大保存天数
|
||||
"max_segments_per_user": 10, # 每用户最大消息段数
|
||||
"cleanup_interval_hours": 1, # 清理间隔(小时)
|
||||
"cleanup_interval_hours": 0.5, # 清理间隔(小时)
|
||||
}
|
||||
|
||||
MAX_MESSAGE_COUNT = 80 / global_config.relationship.relation_frequency
|
||||
|
||||
|
||||
class RelationshipBuilder:
|
||||
"""关系构建器
|
||||
@@ -330,7 +332,7 @@ class RelationshipBuilder:
|
||||
for person_id, segments in self.person_engaged_cache.items():
|
||||
total_count = self._get_total_message_count(person_id)
|
||||
status_lines.append(f"用户 {person_id}:")
|
||||
status_lines.append(f" 总消息数:{total_count} ({total_count}/45)")
|
||||
status_lines.append(f" 总消息数:{total_count} ({total_count}/60)")
|
||||
status_lines.append(f" 消息段数:{len(segments)}")
|
||||
|
||||
for i, segment in enumerate(segments):
|
||||
@@ -384,7 +386,7 @@ class RelationshipBuilder:
|
||||
users_to_build_relationship = []
|
||||
for person_id, segments in self.person_engaged_cache.items():
|
||||
total_message_count = self._get_total_message_count(person_id)
|
||||
if total_message_count >= 45:
|
||||
if total_message_count >= MAX_MESSAGE_COUNT:
|
||||
users_to_build_relationship.append(person_id)
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 用户 {person_id} 满足关系构建条件,总消息数:{total_message_count},消息段数:{len(segments)}"
|
||||
@@ -392,7 +394,7 @@ class RelationshipBuilder:
|
||||
elif total_message_count > 0:
|
||||
# 记录进度信息
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 用户 {person_id} 进度:{total_message_count}/45 条消息,{len(segments)} 个消息段"
|
||||
f"{self.log_prefix} 用户 {person_id} 进度:{total_message_count}60 条消息,{len(segments)} 个消息段"
|
||||
)
|
||||
|
||||
# 2. 为满足条件的用户构建关系
|
||||
|
||||
@@ -22,7 +22,7 @@ logger = get_logger("relation")
|
||||
class RelationshipManager:
|
||||
def __init__(self):
|
||||
self.relationship_llm = LLMRequest(
|
||||
model=global_config.model.relation,
|
||||
model=global_config.model.utils,
|
||||
request_type="relationship", # 用于动作规划
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user