Revert "refactor(maizone): 升级上下文检索为用户中心模式"
This reverts commit dbe9d616d2.
This commit is contained in:
@@ -13,11 +13,11 @@ import aiohttp
|
||||
from maim_message import UserInfo
|
||||
|
||||
from src.chat.message_receive.chat_stream import get_chat_manager
|
||||
from src.plugin_system.apis.cross_context_api import get_user_centric_context
|
||||
from src.common.logger import get_logger
|
||||
from src.config.api_ada_configs import TaskConfig
|
||||
from src.llm_models.utils_model import LLMRequest
|
||||
from src.plugin_system.apis import config_api, generator_api, llm_api
|
||||
from src.plugin_system.apis.cross_context_api import get_chat_history_by_group_name
|
||||
|
||||
# 导入旧的工具函数,我们稍后会考虑是否也需要重构它
|
||||
from ..utils.history_utils import get_send_history
|
||||
@@ -89,12 +89,8 @@ class ContentService:
|
||||
prompt += f"\n作为参考,这里有一些最近的聊天记录:\n---\n{context}\n---"
|
||||
|
||||
# 添加跨群聊上下文
|
||||
bot_user_id = config_api.get_global_config("bot.qq_account")
|
||||
if bot_user_id:
|
||||
cross_context = await get_user_centric_context(
|
||||
user_id=bot_user_id, platform="qq", limit=5
|
||||
) # limit可以根据需要调整
|
||||
if cross_context:
|
||||
cross_context = await get_chat_history_by_group_name("maizone_context_group")
|
||||
if cross_context and "找不到名为" not in cross_context:
|
||||
prompt += f"\n\n---跨群聊参考---\n{cross_context}\n---"
|
||||
|
||||
# 添加历史记录以避免重复
|
||||
|
||||
@@ -187,28 +187,10 @@ class QZoneService:
|
||||
|
||||
async def _get_intercom_context(self, stream_id: str) -> str | None:
|
||||
"""
|
||||
获取用户的跨场景聊天上下文。
|
||||
获取互通组的聊天上下文。
|
||||
"""
|
||||
if not stream_id:
|
||||
return None
|
||||
|
||||
from src.chat.message_receive.chat_stream import get_chat_manager
|
||||
chat_manager = get_chat_manager()
|
||||
stream = await chat_manager.get_stream(stream_id)
|
||||
|
||||
if not stream or not stream.user_info:
|
||||
return None
|
||||
|
||||
user_id = stream.user_info.user_id
|
||||
platform = stream.platform
|
||||
|
||||
# 调用新的以用户为中心的上下文获取函数
|
||||
return await cross_context_api.get_user_centric_context(
|
||||
user_id=user_id,
|
||||
platform=platform,
|
||||
limit=10, # 可以根据需要调整获取的消息数量
|
||||
exclude_chat_id=stream_id
|
||||
)
|
||||
# 实际的逻辑已迁移到 cross_context_api
|
||||
return await cross_context_api.get_intercom_group_context_by_name("maizone_context_group")
|
||||
|
||||
async def _reply_to_own_feed_comments(self, feed: dict, api_client: dict):
|
||||
"""处理对自己说说的评论并进行回复"""
|
||||
|
||||
Reference in New Issue
Block a user