feat:新的记忆系统,deepthink插件,修复平行动作
This commit is contained in:
@@ -6,6 +6,7 @@ import re
|
||||
|
||||
from typing import List, Optional, Dict, Any, Tuple
|
||||
from datetime import datetime
|
||||
from src.chat.memory_system.Memory_chest import global_memory_chest
|
||||
from src.mais4u.mai_think import mai_thinking_manager
|
||||
from src.common.logger import get_logger
|
||||
from src.common.data_models.database_data_model import DatabaseMessages
|
||||
@@ -315,6 +316,17 @@ class DefaultReplyer:
|
||||
# memory_str += f"- {instant_memory}\n"
|
||||
|
||||
# return memory_str
|
||||
|
||||
async def build_memory_block(self) -> str:
|
||||
"""构建记忆块
|
||||
"""
|
||||
# if not global_config.memory.enable_memory:
|
||||
# return ""
|
||||
|
||||
if global_memory_chest.get_chat_memories_as_string(self.chat_stream.stream_id):
|
||||
return f"你有以下记忆:\n{global_memory_chest.get_chat_memories_as_string(self.chat_stream.stream_id)}"
|
||||
else:
|
||||
return ""
|
||||
|
||||
async def build_tool_info(self, chat_history: str, sender: str, target: str, enable_tool: bool = True) -> str:
|
||||
"""构建工具信息块
|
||||
@@ -701,6 +713,7 @@ class DefaultReplyer:
|
||||
# self.build_relation_info(chat_talking_prompt_short, sender, person_list_short), "relation_info"
|
||||
# ),
|
||||
# self._time_and_run_task(self.build_memory_block(message_list_before_short, target), "memory_block"),
|
||||
self._time_and_run_task(self.build_memory_block(), "memory_block"),
|
||||
self._time_and_run_task(
|
||||
self.build_tool_info(chat_talking_prompt_short, sender, target, enable_tool=enable_tool), "tool_info"
|
||||
),
|
||||
@@ -714,6 +727,7 @@ class DefaultReplyer:
|
||||
"expression_habits": "选取表达方式",
|
||||
"relation_info": "感受关系",
|
||||
# "memory_block": "回忆",
|
||||
"memory_block": "记忆",
|
||||
"tool_info": "使用工具",
|
||||
"prompt_info": "获取知识",
|
||||
"actions_info": "动作信息",
|
||||
@@ -742,6 +756,7 @@ class DefaultReplyer:
|
||||
selected_expressions: List[int]
|
||||
# relation_info: str = results_dict["relation_info"]
|
||||
# memory_block: str = results_dict["memory_block"]
|
||||
memory_block: str = results_dict["memory_block"]
|
||||
tool_info: str = results_dict["tool_info"]
|
||||
prompt_info: str = results_dict["prompt_info"] # 直接使用格式化后的结果
|
||||
actions_info: str = results_dict["actions_info"]
|
||||
@@ -779,6 +794,7 @@ class DefaultReplyer:
|
||||
"replyer_self_prompt",
|
||||
expression_habits_block=expression_habits_block,
|
||||
tool_info_block=tool_info,
|
||||
memory_block=memory_block,
|
||||
knowledge_prompt=prompt_info,
|
||||
# memory_block=memory_block,
|
||||
# relation_info_block=relation_info,
|
||||
@@ -798,6 +814,7 @@ class DefaultReplyer:
|
||||
"replyer_prompt",
|
||||
expression_habits_block=expression_habits_block,
|
||||
tool_info_block=tool_info,
|
||||
memory_block=memory_block,
|
||||
knowledge_prompt=prompt_info,
|
||||
# memory_block=memory_block,
|
||||
# relation_info_block=relation_info,
|
||||
@@ -946,7 +963,7 @@ class DefaultReplyer:
|
||||
async def llm_generate_content(self, prompt: str):
|
||||
with Timer("LLM生成", {}): # 内部计时器,可选保留
|
||||
# 直接使用已初始化的模型实例
|
||||
# logger.info(f"\n{prompt}\n")
|
||||
logger.info(f"\n{prompt}\n")
|
||||
|
||||
if global_config.debug.show_prompt:
|
||||
logger.info(f"\n{prompt}\n")
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
|
||||
from typing import List, Optional, Dict, Any, Tuple
|
||||
from datetime import datetime
|
||||
from src.chat.memory_system.Memory_chest import global_memory_chest
|
||||
from src.mais4u.mai_think import mai_thinking_manager
|
||||
from src.common.logger import get_logger
|
||||
from src.common.data_models.database_data_model import DatabaseMessages
|
||||
@@ -312,6 +313,15 @@ class PrivateReplyer:
|
||||
|
||||
# return memory_str
|
||||
|
||||
|
||||
async def build_memory_block(self) -> str:
|
||||
"""构建记忆块
|
||||
"""
|
||||
if global_memory_chest.get_chat_memories_as_string(self.chat_stream.stream_id):
|
||||
return f"你有以下记忆:\n{global_memory_chest.get_chat_memories_as_string(self.chat_stream.stream_id)}"
|
||||
else:
|
||||
return ""
|
||||
|
||||
async def build_tool_info(self, chat_history: str, sender: str, target: str, enable_tool: bool = True) -> str:
|
||||
"""构建工具信息块
|
||||
|
||||
@@ -582,6 +592,7 @@ class PrivateReplyer:
|
||||
self._time_and_run_task(
|
||||
self.build_relation_info(chat_talking_prompt_short, sender), "relation_info"
|
||||
),
|
||||
self._time_and_run_task(self.build_memory_block(), "memory_block"),
|
||||
# self._time_and_run_task(self.build_memory_block(message_list_before_short, target), "memory_block"),
|
||||
self._time_and_run_task(
|
||||
self.build_tool_info(chat_talking_prompt_short, sender, target, enable_tool=enable_tool), "tool_info"
|
||||
@@ -595,7 +606,7 @@ class PrivateReplyer:
|
||||
task_name_mapping = {
|
||||
"expression_habits": "选取表达方式",
|
||||
"relation_info": "感受关系",
|
||||
# "memory_block": "回忆",
|
||||
"memory_block": "回忆",
|
||||
"tool_info": "使用工具",
|
||||
"prompt_info": "获取知识",
|
||||
"actions_info": "动作信息",
|
||||
@@ -623,7 +634,7 @@ class PrivateReplyer:
|
||||
expression_habits_block: str
|
||||
selected_expressions: List[int]
|
||||
relation_info: str = results_dict["relation_info"]
|
||||
# memory_block: str = results_dict["memory_block"]
|
||||
memory_block: str = results_dict["memory_block"]
|
||||
tool_info: str = results_dict["tool_info"]
|
||||
prompt_info: str = results_dict["prompt_info"] # 直接使用格式化后的结果
|
||||
actions_info: str = results_dict["actions_info"]
|
||||
@@ -649,7 +660,7 @@ class PrivateReplyer:
|
||||
expression_habits_block=expression_habits_block,
|
||||
tool_info_block=tool_info,
|
||||
knowledge_prompt=prompt_info,
|
||||
# memory_block=memory_block,
|
||||
memory_block=memory_block,
|
||||
relation_info_block=relation_info,
|
||||
extra_info_block=extra_info_block,
|
||||
identity=personality_prompt,
|
||||
@@ -670,7 +681,7 @@ class PrivateReplyer:
|
||||
expression_habits_block=expression_habits_block,
|
||||
tool_info_block=tool_info,
|
||||
knowledge_prompt=prompt_info,
|
||||
# memory_block=memory_block,
|
||||
memory_block=memory_block,
|
||||
relation_info_block=relation_info,
|
||||
extra_info_block=extra_info_block,
|
||||
identity=personality_prompt,
|
||||
|
||||
@@ -13,7 +13,7 @@ def init_replyer_prompt():
|
||||
|
||||
Prompt(
|
||||
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||
{expression_habits_block}
|
||||
{expression_habits_block}{memory_block}
|
||||
|
||||
你正在qq群里聊天,下面是群里正在聊的内容:
|
||||
{time_block}
|
||||
@@ -34,7 +34,7 @@ def init_replyer_prompt():
|
||||
|
||||
Prompt(
|
||||
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||
{expression_habits_block}
|
||||
{expression_habits_block}{memory_block}
|
||||
|
||||
你正在qq群里聊天,下面是群里正在聊的内容:
|
||||
{time_block}
|
||||
@@ -55,7 +55,7 @@ def init_replyer_prompt():
|
||||
|
||||
Prompt(
|
||||
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||
{expression_habits_block}
|
||||
{expression_habits_block}{memory_block}
|
||||
|
||||
你正在和{sender_name}聊天,这是你们之前聊的内容:
|
||||
{time_block}
|
||||
@@ -74,7 +74,7 @@ def init_replyer_prompt():
|
||||
|
||||
Prompt(
|
||||
"""{knowledge_prompt}{tool_info_block}{extra_info_block}
|
||||
{expression_habits_block}
|
||||
{expression_habits_block}{memory_block}
|
||||
|
||||
你正在和{sender_name}聊天,这是你们之前聊的内容:
|
||||
{time_block}
|
||||
|
||||
Reference in New Issue
Block a user