feat(proactive_thinker): 增加跨上下文信息到主动思考提示词
在主动思考的提示词中增加了“和Ta在别处的讨论摘要”部分。 这使得AI在进行主动思考时,能够参考用户在其他群组或私聊中的相关讨论,从而获得更全面的上下文信息,做出更贴切和连贯的响应。
This commit is contained in:
committed by
Windpicker-owo
parent
016c86a2dd
commit
3c2a90bad4
@@ -5,6 +5,7 @@ from typing import Any
|
||||
import orjson
|
||||
|
||||
from src.chat.utils.chat_message_builder import build_readable_actions, get_actions_by_timestamp_with_chat
|
||||
from src.chat.utils.prompt import Prompt
|
||||
from src.common.logger import get_logger
|
||||
from src.config.config import global_config, model_config
|
||||
from src.mood.mood_manager import mood_manager
|
||||
@@ -193,6 +194,10 @@ class ProactiveThinkerExecutor:
|
||||
|
||||
person_id = person_api.get_person_id(user_info.platform, int(user_info.user_id))
|
||||
person_info_manager = get_person_info_manager()
|
||||
person_info = await person_info_manager.get_values(person_id, ["user_id", "platform", "person_name"])
|
||||
cross_context_block = await Prompt.build_cross_context(
|
||||
stream.stream_id, "s4u", person_info
|
||||
)
|
||||
|
||||
# 获取关系信息
|
||||
short_impression = await person_info_manager.get_value(person_id, "short_impression") or "无"
|
||||
@@ -204,6 +209,7 @@ class ProactiveThinkerExecutor:
|
||||
"chat_type": "private",
|
||||
"person_id": person_id,
|
||||
"user_info": user_info,
|
||||
"cross_context_block": cross_context_block,
|
||||
"relationship": {
|
||||
"short_impression": short_impression,
|
||||
"impression": impression,
|
||||
@@ -259,7 +265,9 @@ class ProactiveThinkerExecutor:
|
||||
- 简短印象: {relationship["short_impression"]}
|
||||
- 详细印象: {relationship["impression"]}
|
||||
- 好感度: {relationship["attitude"]}/100
|
||||
4. **最近的聊天摘要**:
|
||||
4. **和Ta在别处的讨论摘要**:
|
||||
{context["cross_context_block"]}
|
||||
5. **最近的聊天摘要**:
|
||||
{context["recent_chat_history"]}
|
||||
"""
|
||||
elif chat_type == "group":
|
||||
@@ -408,9 +416,11 @@ class ProactiveThinkerExecutor:
|
||||
- 简短印象: {relationship["short_impression"]}
|
||||
- 详细印象: {relationship["impression"]}
|
||||
- 好感度: {relationship["attitude"]}/100
|
||||
3. **最近的聊天摘要**:
|
||||
3. **和Ta在别处的讨论摘要**:
|
||||
{context["cross_context_block"]}
|
||||
4. **最近的聊天摘要**:
|
||||
{context["recent_chat_history"]}
|
||||
4. **你最近的相关动作**:
|
||||
5. **你最近的相关动作**:
|
||||
{context["action_history_context"]}
|
||||
|
||||
# 对话指引
|
||||
|
||||
Reference in New Issue
Block a user