mirror of https://github.com/Mai-with-u/MaiBot.git
parent
d10e08f15d
commit
bc2b07302b
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
## [0.10.1] - 2025-8-
|
||||
|
||||
- planner现在改为主+副结构
|
||||
|
||||
- 优化识图的表现
|
||||
- 为planner添加单独控制的提示词
|
||||
- 修复激活值计算异常的BUG
|
||||
- 修复lpmm日志错误
|
||||
|
|
@ -9,6 +12,8 @@
|
|||
- 修复emoji管理器的一个BUG
|
||||
- 优化对模型请求的处理
|
||||
- 重构内部代码
|
||||
- 暂时禁用记忆
|
||||
- 优化关系的表现的效率
|
||||
|
||||
## [0.10.0] - 2025-8-18
|
||||
### 🌟 主要功能更改
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from src.chat.utils.chat_message_builder import replace_user_references
|
|||
from src.common.logger import get_logger
|
||||
from src.mood.mood_manager import mood_manager
|
||||
from src.person_info.person_info import Person
|
||||
from src.common.database.database_model import Images
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.chat.heart_flow.heartFC_chat import HeartFChatting
|
||||
|
|
@ -31,6 +32,9 @@ async def _calculate_interest(message: MessageRecv) -> Tuple[float, list[str]]:
|
|||
Returns:
|
||||
Tuple[float, bool, list[str]]: (兴趣度, 是否被提及, 关键词)
|
||||
"""
|
||||
if message.is_picid:
|
||||
return 0.0, []
|
||||
|
||||
is_mentioned, _ = is_mentioned_bot_in_message(message)
|
||||
interested_rate = 0.0
|
||||
|
||||
|
|
@ -129,13 +133,26 @@ class HeartFCMessageReceiver:
|
|||
# 3. 日志记录
|
||||
mes_name = chat.group_info.group_name if chat.group_info else "私聊"
|
||||
|
||||
# 如果消息中包含图片标识,则将 [picid:...] 替换为 [图片]
|
||||
# 用这个pattern截取出id部分,picid是一个list,并替换成对应的图片描述
|
||||
picid_pattern = r"\[picid:([^\]]+)\]"
|
||||
processed_plain_text = re.sub(picid_pattern, "[图片]", message.processed_plain_text)
|
||||
picid_list = re.findall(picid_pattern, message.processed_plain_text)
|
||||
|
||||
# 创建替换后的文本
|
||||
processed_text = message.processed_plain_text
|
||||
if picid_list:
|
||||
for picid in picid_list:
|
||||
image = Images.get_or_none(Images.image_id == picid)
|
||||
if image and image.description:
|
||||
# 将[picid:xxxx]替换成图片描述
|
||||
processed_text = processed_text.replace(f"[picid:{picid}]", f"[图片:{image.description}]")
|
||||
else:
|
||||
# 如果没有找到图片描述,则移除[picid:xxxx]标记
|
||||
processed_text = processed_text.replace(f"[picid:{picid}]", "[图片:网络不好,图片无法加载]")
|
||||
|
||||
|
||||
# 应用用户引用格式替换,将回复<aaa:bbb>和@<aaa:bbb>格式转换为可读格式
|
||||
processed_plain_text = replace_user_references(
|
||||
processed_plain_text,
|
||||
processed_text,
|
||||
message.message_info.platform, # type: ignore
|
||||
replace_bot_name=True
|
||||
)
|
||||
|
|
|
|||
|
|
@ -357,7 +357,7 @@ class ActionPlanner:
|
|||
|
||||
# --- 调用 LLM (普通文本生成) ---
|
||||
llm_content = None
|
||||
action_planner_infos = [] # 存储多个ActionPlannerInfo对象
|
||||
action_planner_infos: List[ActionPlannerInfo] = [] # 存储多个ActionPlannerInfo对象
|
||||
|
||||
try:
|
||||
llm_content, (reasoning_content, _, _) = await self.planner_small_llm.generate_response_async(prompt=prompt)
|
||||
|
|
@ -581,7 +581,7 @@ class ActionPlanner:
|
|||
sub_plan_results = await asyncio.gather(*sub_plan_tasks)
|
||||
|
||||
# 收集所有结果
|
||||
all_sub_planner_results = []
|
||||
all_sub_planner_results: List[ActionPlannerInfo] = []
|
||||
for sub_result in sub_plan_results:
|
||||
all_sub_planner_results.extend(sub_result)
|
||||
|
||||
|
|
@ -679,9 +679,12 @@ class ActionPlanner:
|
|||
reasoning = f"Planner 内部处理错误: {outer_e}"
|
||||
|
||||
is_parallel = True
|
||||
if mode == ChatMode.NORMAL and action in current_available_actions:
|
||||
if is_parallel:
|
||||
is_parallel = current_available_actions[action].parallel_action
|
||||
for action_planner_info in all_sub_planner_results:
|
||||
if action_planner_info.action_type == "no_action":
|
||||
continue
|
||||
if not current_available_actions[action_planner_info.action_type].parallel_action:
|
||||
is_parallel = False
|
||||
break
|
||||
|
||||
action_data["loop_start_time"] = loop_start_time
|
||||
|
||||
|
|
@ -720,8 +723,11 @@ class ActionPlanner:
|
|||
)
|
||||
]
|
||||
|
||||
action_str = ""
|
||||
for action in actions:
|
||||
action_str += f"{action.action_type} "
|
||||
logger.info(
|
||||
f"{self.log_prefix}并行模式:返回主规划器{len(main_actions)}个action + 副规划器{len(all_sub_planner_results)}个action,过滤后总计{len(actions)}个action"
|
||||
f"{self.log_prefix}大脑小脑决定执行{len(actions)}个动作: {action_str}"
|
||||
)
|
||||
else:
|
||||
# 如果为假,只返回副规划器的结果
|
||||
|
|
@ -739,7 +745,7 @@ class ActionPlanner:
|
|||
)
|
||||
]
|
||||
|
||||
logger.info(f"{self.log_prefix}非并行模式:返回副规划器的{len(actions)}个action(已过滤no_action)")
|
||||
logger.info(f"{self.log_prefix}跳过大脑,执行小脑的{len(actions)}个动作")
|
||||
|
||||
return actions, target_message
|
||||
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ class ImageManager:
|
|||
)
|
||||
|
||||
# 启动异步VLM处理
|
||||
asyncio.create_task(self._process_image_with_vlm(image_id, image_base64))
|
||||
await self._process_image_with_vlm(image_id, image_base64)
|
||||
|
||||
return image_id, f"[picid:{image_id}]"
|
||||
|
||||
|
|
@ -568,17 +568,16 @@ class ImageManager:
|
|||
prompt = global_config.custom_prompt.image_prompt
|
||||
|
||||
# 获取VLM描述
|
||||
logger.info(f"[VLM异步调用] 为图片生成描述 (ID: {image_id}, Hash: {image_hash[:8]}...)")
|
||||
description, _ = await self.vlm.generate_response_for_image(
|
||||
prompt, image_base64, image_format, temperature=0.4, max_tokens=300
|
||||
)
|
||||
|
||||
if description is None:
|
||||
logger.warning("VLM未能生成图片描述")
|
||||
description = "无法生成描述"
|
||||
description = ""
|
||||
|
||||
if cached_description := self._get_description_from_db(image_hash, "image"):
|
||||
logger.warning(f"虽然生成了描述,但是找到缓存图片描述: {cached_description}")
|
||||
logger.info(f"虽然生成了描述,但是找到缓存图片描述: {cached_description}")
|
||||
description = cached_description
|
||||
|
||||
# 更新数据库
|
||||
|
|
@ -589,8 +588,6 @@ class ImageManager:
|
|||
# 保存描述到ImageDescriptions表作为备用缓存
|
||||
self._save_description_to_db(image_hash, description, "image")
|
||||
|
||||
logger.info(f"[VLM异步完成] 图片描述生成: {description[:50]}...")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"VLM处理图片失败: {str(e)}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue