我要曹飞一切之thinkflow创世纪
This commit is contained in:
@@ -18,7 +18,7 @@ from ..memory_system.memory import hippocampus
|
||||
from .message_sender import message_manager, message_sender
|
||||
from .storage import MessageStorage
|
||||
from src.common.logger import get_module_logger
|
||||
from src.think_flow_demo.current_mind import brain
|
||||
# from src.think_flow_demo.current_mind import subheartflow
|
||||
from src.think_flow_demo.outer_world import outer_world
|
||||
|
||||
logger = get_module_logger("chat_init")
|
||||
@@ -46,12 +46,11 @@ scheduler = require("nonebot_plugin_apscheduler").scheduler
|
||||
|
||||
|
||||
async def start_think_flow():
|
||||
"""启动大脑和外部世界"""
|
||||
"""启动外部世界"""
|
||||
try:
|
||||
brain_task = asyncio.create_task(brain.brain_start_working())
|
||||
outer_world_task = asyncio.create_task(outer_world.open_eyes())
|
||||
logger.success("大脑和外部世界启动成功")
|
||||
return brain_task, outer_world_task
|
||||
return outer_world_task
|
||||
except Exception as e:
|
||||
logger.error(f"启动大脑和外部世界失败: {e}")
|
||||
raise
|
||||
|
||||
@@ -32,7 +32,7 @@ from .utils_user import get_user_nickname, get_user_cardname
|
||||
from ..willing.willing_manager import willing_manager # 导入意愿管理器
|
||||
from .message_base import UserInfo, GroupInfo, Seg
|
||||
|
||||
from src.think_flow_demo.current_mind import brain
|
||||
from src.think_flow_demo.heartflow import subheartflow_manager
|
||||
from src.think_flow_demo.outer_world import outer_world
|
||||
|
||||
from src.common.logger import get_module_logger, CHAT_STYLE_CONFIG, LogConfig
|
||||
@@ -93,6 +93,12 @@ class ChatBot:
|
||||
group_info=groupinfo, # 我嘞个gourp_info
|
||||
)
|
||||
message.update_chat_stream(chat)
|
||||
|
||||
#创建 心流 观察
|
||||
await outer_world.check_and_add_new_observe()
|
||||
subheartflow_manager.create_subheartflow(chat.stream_id)
|
||||
|
||||
|
||||
await relationship_manager.update_relationship(
|
||||
chat_stream=chat,
|
||||
)
|
||||
@@ -185,7 +191,7 @@ class ChatBot:
|
||||
stream_id, limit=global_config.MAX_CONTEXT_SIZE, combine=True
|
||||
)
|
||||
|
||||
await brain.do_after_reply(response,chat_talking_prompt)
|
||||
await subheartflow_manager.get_subheartflow(stream_id).do_after_reply(response,chat_talking_prompt)
|
||||
# print(f"有response: {response}")
|
||||
container = message_manager.get_container(chat.stream_id)
|
||||
thinking_message = None
|
||||
@@ -308,11 +314,11 @@ class ChatBot:
|
||||
|
||||
raw_message = f"[戳了戳]{global_config.BOT_NICKNAME}" # 默认类型
|
||||
if info := event.model_extra["raw_info"]:
|
||||
poke_type = info[2].get("txt", "戳了戳") # 戳戳类型,例如“拍一拍”、“揉一揉”、“捏一捏”
|
||||
poke_type = info[2].get("txt", "戳了戳") # 戳戳类型,例如"拍一拍"、"揉一揉"、"捏一捏"
|
||||
custom_poke_message = info[4].get("txt", "") # 自定义戳戳消息,若不存在会为空字符串
|
||||
raw_message = f"[{poke_type}]{global_config.BOT_NICKNAME}{custom_poke_message}"
|
||||
|
||||
raw_message += "(这是一个类似摸摸头的友善行为,而不是恶意行为,请不要作出攻击发言)"
|
||||
raw_message += ",作为一个类似摸摸头的友善行为"
|
||||
|
||||
user_info = UserInfo(
|
||||
user_id=event.user_id,
|
||||
|
||||
@@ -12,7 +12,7 @@ from .chat_stream import chat_manager
|
||||
from .relationship_manager import relationship_manager
|
||||
from src.common.logger import get_module_logger
|
||||
|
||||
from src.think_flow_demo.current_mind import brain
|
||||
from src.think_flow_demo.heartflow import subheartflow_manager
|
||||
from src.think_flow_demo.outer_world import outer_world
|
||||
|
||||
logger = get_module_logger("prompt")
|
||||
@@ -36,8 +36,8 @@ class PromptBuilder:
|
||||
limit=global_config.MAX_CONTEXT_SIZE,
|
||||
)
|
||||
|
||||
outer_world_info = outer_world.outer_world_info
|
||||
current_mind_info = brain.current_mind
|
||||
# outer_world_info = outer_world.outer_world_info
|
||||
current_mind_info = subheartflow_manager.get_subheartflow(stream_id).current_mind
|
||||
|
||||
relation_prompt = ""
|
||||
for person in who_chat_in_group:
|
||||
@@ -183,7 +183,7 @@ class PromptBuilder:
|
||||
prompt_check_if_response = ""
|
||||
|
||||
|
||||
print(prompt)
|
||||
# print(prompt)
|
||||
|
||||
return prompt, prompt_check_if_response
|
||||
|
||||
|
||||
@@ -799,7 +799,7 @@ class Hippocampus:
|
||||
"""
|
||||
topics_response = await self.llm_topic_judge.generate_response(self.find_topic_llm(text, 4))
|
||||
# 使用正则表达式提取<>中的内容
|
||||
print(f"话题: {topics_response[0]}")
|
||||
# print(f"话题: {topics_response[0]}")
|
||||
topics = re.findall(r'<([^>]+)>', topics_response[0])
|
||||
|
||||
# 如果没有找到<>包裹的内容,返回['none']
|
||||
@@ -884,7 +884,7 @@ class Hippocampus:
|
||||
"""计算输入文本对记忆的激活程度"""
|
||||
# 识别主题
|
||||
identified_topics = await self._identify_topics(text)
|
||||
print(f"识别主题: {identified_topics}")
|
||||
# print(f"识别主题: {identified_topics}")
|
||||
|
||||
if identified_topics[0] == "none":
|
||||
return 0
|
||||
|
||||
@@ -42,8 +42,8 @@ class WillingManager:
|
||||
interested_rate = interested_rate * config.response_interested_rate_amplifier
|
||||
|
||||
|
||||
if interested_rate > 0.3:
|
||||
current_willing += interested_rate - 0.2
|
||||
if interested_rate > 0.4:
|
||||
current_willing += interested_rate - 0.3
|
||||
|
||||
if is_mentioned_bot and current_willing < 1.0:
|
||||
current_willing += 1
|
||||
|
||||
Reference in New Issue
Block a user