This commit is contained in:
SengokuCola
2025-06-29 22:21:17 +08:00
7 changed files with 22 additions and 39 deletions

View File

@@ -66,9 +66,9 @@
## 💬 讨论 ## 💬 讨论
- [](https://qm.qq.com/q/VQ3XZrWgMs) | - [](https://qm.qq.com/q/wGePTl1UyY) |
[](https://qm.qq.com/q/wGePTl1UyY) | [](https://qm.qq.com/q/VQ3XZrWgMs)(已满) |
[二群](https://qm.qq.com/q/RzmCiRtHEW) | [二群](https://qm.qq.com/q/RzmCiRtHEW)(已满) |
[五群](https://qm.qq.com/q/JxvHZnxyec)(已满) | [五群](https://qm.qq.com/q/JxvHZnxyec)(已满) |
[三群](https://qm.qq.com/q/wlH5eT8OmQ)(已满) [三群](https://qm.qq.com/q/wlH5eT8OmQ)(已满)

View File

@@ -209,14 +209,14 @@ class ExpressionSelector:
return [] return []
all_situations_str = "\n".join(all_situations) all_situations_str = "\n".join(all_situations)
if target_message: if target_message:
target_message_str = f",现在你想要回复消息:{target_message}" target_message_str = f",现在你想要回复消息:{target_message}"
target_message_extra_block = f"4.考虑你要回复的目标消息" target_message_extra_block = "4.考虑你要回复的目标消息"
else: else:
target_message_str = "" target_message_str = ""
target_message_extra_block = "" target_message_extra_block = ""
# 3. 构建prompt只包含情境不包含完整的表达方式 # 3. 构建prompt只包含情境不包含完整的表达方式
prompt = (await global_prompt_manager.get_prompt_async("expression_evaluation_prompt")).format( prompt = (await global_prompt_manager.get_prompt_async("expression_evaluation_prompt")).format(
bot_name=global_config.bot.nickname, bot_name=global_config.bot.nickname,
@@ -227,7 +227,7 @@ class ExpressionSelector:
target_message=target_message_str, target_message=target_message_str,
target_message_extra_block=target_message_extra_block, target_message_extra_block=target_message_extra_block,
) )
# print(prompt) # print(prompt)
# 4. 调用LLM # 4. 调用LLM

View File

@@ -649,7 +649,6 @@ class HeartFChatting:
return all_plan_info, processor_time_costs return all_plan_info, processor_time_costs
async def _process_post_planning_processors_with_timing( async def _process_post_planning_processors_with_timing(
self, observations: List[Observation], action_type: str, action_data: dict self, observations: List[Observation], action_type: str, action_data: dict
) -> tuple[dict, dict]: ) -> tuple[dict, dict]:
@@ -681,9 +680,7 @@ class HeartFChatting:
start_time = time.time() start_time = time.time()
try: try:
result = await asyncio.wait_for( result = await asyncio.wait_for(
proc.process_info( proc.process_info(observations=observations, action_type=action_type, action_data=action_data),
observations=observations, action_type=action_type, action_data=action_data
),
timeout=global_config.focus_chat.processor_max_time, timeout=global_config.focus_chat.processor_max_time,
) )
end_time = time.time() end_time = time.time()

View File

@@ -181,14 +181,13 @@ class HeartFCMessageReceiver:
mes_name = chat.group_info.group_name if chat.group_info else "私聊" mes_name = chat.group_info.group_name if chat.group_info else "私聊"
# current_time = time.strftime("%H:%M:%S", time.localtime(message.message_info.time)) # current_time = time.strftime("%H:%M:%S", time.localtime(message.message_info.time))
current_talk_frequency = global_config.chat.get_current_talk_frequency(chat.stream_id) current_talk_frequency = global_config.chat.get_current_talk_frequency(chat.stream_id)
# 如果消息中包含图片标识,则日志展示为图片 # 如果消息中包含图片标识,则日志展示为图片
import re import re
picid_match = re.search(r"\[picid:([^\]]+)\]", message.processed_plain_text) picid_match = re.search(r"\[picid:([^\]]+)\]", message.processed_plain_text)
if picid_match: if picid_match:
logger.info( logger.info(f"[{mes_name}]{userinfo.user_nickname}: [图片] [当前回复频率: {current_talk_frequency}]")
f"[{mes_name}]{userinfo.user_nickname}: [图片] [当前回复频率: {current_talk_frequency}]"
)
else: else:
logger.info( logger.info(
f"[{mes_name}]{userinfo.user_nickname}:{message.processed_plain_text}[当前回复频率: {current_talk_frequency}]" f"[{mes_name}]{userinfo.user_nickname}:{message.processed_plain_text}[当前回复频率: {current_talk_frequency}]"

View File

@@ -13,7 +13,6 @@ from typing import List
from typing import Dict from typing import Dict
from src.chat.focus_chat.info.info_base import InfoBase from src.chat.focus_chat.info.info_base import InfoBase
from src.chat.focus_chat.info.relation_info import RelationInfo from src.chat.focus_chat.info.relation_info import RelationInfo
from src.person_info.person_info import PersonInfoManager
from json_repair import repair_json from json_repair import repair_json
from src.person_info.person_info import get_person_info_manager from src.person_info.person_info import get_person_info_manager
import json import json
@@ -26,7 +25,6 @@ from src.chat.utils.chat_message_builder import (
) )
import os import os
import pickle import pickle
import random
# 消息段清理配置 # 消息段清理配置
@@ -446,8 +444,8 @@ class PersonImpressionpProcessor(BaseProcessor):
List[InfoBase]: 处理后的结构化信息列表 List[InfoBase]: 处理后的结构化信息列表
""" """
await self.build_relation(observations) await self.build_relation(observations)
relation_info_str = await self.relation_identify(observations,action_type,action_data) relation_info_str = await self.relation_identify(observations, action_type, action_data)
if relation_info_str: if relation_info_str:
relation_info = RelationInfo() relation_info = RelationInfo()
@@ -462,7 +460,7 @@ class PersonImpressionpProcessor(BaseProcessor):
"""构建关系""" """构建关系"""
self._cleanup_old_segments() self._cleanup_old_segments()
current_time = time.time() current_time = time.time()
if observations: if observations:
for observation in observations: for observation in observations:
if isinstance(observation, ChattingObservation): if isinstance(observation, ChattingObservation):
@@ -518,7 +516,7 @@ class PersonImpressionpProcessor(BaseProcessor):
# 移除已处理的用户缓存 # 移除已处理的用户缓存
del self.person_engaged_cache[person_id] del self.person_engaged_cache[person_id]
self._save_cache() self._save_cache()
async def relation_identify( async def relation_identify(
self, self,
observations: List[Observation] = None, observations: List[Observation] = None,
@@ -527,7 +525,7 @@ class PersonImpressionpProcessor(BaseProcessor):
): ):
""" """
从人物获取信息 从人物获取信息
""" """
chat_observe_info = "" chat_observe_info = ""
current_time = time.time() current_time = time.time()
@@ -567,7 +565,6 @@ class PersonImpressionpProcessor(BaseProcessor):
self.last_processed_message_time = max(self.last_processed_message_time, msg_time) self.last_processed_message_time = max(self.last_processed_message_time, msg_time)
break break
for person_id in list(self.info_fetched_cache.keys()): for person_id in list(self.info_fetched_cache.keys()):
for info_type in list(self.info_fetched_cache[person_id].keys()): for info_type in list(self.info_fetched_cache[person_id].keys()):
self.info_fetched_cache[person_id][info_type]["ttl"] -= 1 self.info_fetched_cache[person_id][info_type]["ttl"] -= 1
@@ -575,11 +572,7 @@ class PersonImpressionpProcessor(BaseProcessor):
del self.info_fetched_cache[person_id][info_type] del self.info_fetched_cache[person_id][info_type]
if not self.info_fetched_cache[person_id]: if not self.info_fetched_cache[person_id]:
del self.info_fetched_cache[person_id] del self.info_fetched_cache[person_id]
if action_type != "reply": if action_type != "reply":
return None return None
@@ -831,7 +824,6 @@ class PersonImpressionpProcessor(BaseProcessor):
logger.info(f"{self.log_prefix} 记得 {person_name}{info_type}: {cached_info}") logger.info(f"{self.log_prefix} 记得 {person_name}{info_type}: {cached_info}")
return return
try: try:
person_name = await person_info_manager.get_value(person_id, "person_name") person_name = await person_info_manager.get_value(person_id, "person_name")
person_impression = await person_info_manager.get_value(person_id, "impression") person_impression = await person_info_manager.get_value(person_id, "impression")
@@ -864,9 +856,7 @@ class PersonImpressionpProcessor(BaseProcessor):
return return
nickname_str = ",".join(global_config.bot.alias_names) nickname_str = ",".join(global_config.bot.alias_names)
name_block = ( name_block = f"你的名字是{global_config.bot.nickname},你的昵称有{nickname_str},有人也会用这些昵称称呼你。"
f"你的名字是{global_config.bot.nickname},你的昵称有{nickname_str},有人也会用这些昵称称呼你。"
)
prompt = (await global_prompt_manager.get_prompt_async("fetch_person_info_prompt")).format( prompt = (await global_prompt_manager.get_prompt_async("fetch_person_info_prompt")).format(
name_block=name_block, name_block=name_block,
info_type=info_type, info_type=info_type,

View File

@@ -8,7 +8,7 @@ from src.chat.utils.prompt_builder import Prompt, global_prompt_manager
from src.tools.tool_use import ToolUser from src.tools.tool_use import ToolUser
from src.chat.utils.json_utils import process_llm_tool_calls from src.chat.utils.json_utils import process_llm_tool_calls
from .base_processor import BaseProcessor from .base_processor import BaseProcessor
from typing import List, Optional from typing import List
from src.chat.heart_flow.observation.observation import Observation from src.chat.heart_flow.observation.observation import Observation
from src.chat.focus_chat.info.structured_info import StructuredInfo from src.chat.focus_chat.info.structured_info import StructuredInfo
from src.chat.heart_flow.observation.structure_observation import StructureObservation from src.chat.heart_flow.observation.structure_observation import StructureObservation
@@ -92,9 +92,7 @@ class ToolProcessor(BaseProcessor):
return [structured_info] return [structured_info]
async def execute_tools( async def execute_tools(self, observation: ChattingObservation, action_type: str = None, action_data: dict = None):
self, observation: ChattingObservation, action_type: str = None, action_data: dict = None
):
""" """
并行执行工具,返回结构化信息 并行执行工具,返回结构化信息

View File

@@ -126,10 +126,9 @@ class PromptBuilder:
(chat_stream.user_info.platform, chat_stream.user_info.user_id) if chat_stream.user_info else None, (chat_stream.user_info.platform, chat_stream.user_info.user_id) if chat_stream.user_info else None,
limit=global_config.normal_chat.max_context_size, limit=global_config.normal_chat.max_context_size,
) )
elif chat_stream.user_info: who_chat_in_group.append(
who_chat_in_group.append( (chat_stream.user_info.platform, chat_stream.user_info.user_id, chat_stream.user_info.user_nickname)
(chat_stream.user_info.platform, chat_stream.user_info.user_id, chat_stream.user_info.user_nickname) )
)
relation_prompt = "" relation_prompt = ""
if global_config.relationship.enable_relationship: if global_config.relationship.enable_relationship: