🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -414,9 +414,9 @@ class ExpressionLearner:
|
|||||||
init_prompt()
|
init_prompt()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
expression_learner = None
|
expression_learner = None
|
||||||
|
|
||||||
|
|
||||||
def get_expression_learner():
|
def get_expression_learner():
|
||||||
global expression_learner
|
global expression_learner
|
||||||
if expression_learner is None:
|
if expression_learner is None:
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ from src.chat.message_receive.chat_stream import ChatStream
|
|||||||
from src.chat.focus_chat.hfc_utils import parse_thinking_id_to_timestamp
|
from src.chat.focus_chat.hfc_utils import parse_thinking_id_to_timestamp
|
||||||
from src.chat.utils.prompt_builder import Prompt, global_prompt_manager
|
from src.chat.utils.prompt_builder import Prompt, global_prompt_manager
|
||||||
from src.chat.utils.chat_message_builder import build_readable_messages, get_raw_msg_before_timestamp_with_chat
|
from src.chat.utils.chat_message_builder import build_readable_messages, get_raw_msg_before_timestamp_with_chat
|
||||||
from src.chat.express.exprssion_learner import get_expression_learner
|
|
||||||
import time
|
import time
|
||||||
import asyncio
|
import asyncio
|
||||||
from src.chat.express.expression_selector import expression_selector
|
from src.chat.express.expression_selector import expression_selector
|
||||||
@@ -89,7 +88,6 @@ def init_prompt():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DefaultReplyer:
|
class DefaultReplyer:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -464,8 +462,7 @@ class DefaultReplyer:
|
|||||||
|
|
||||||
return keywords_reaction_prompt
|
return keywords_reaction_prompt
|
||||||
|
|
||||||
async def build_prompt_reply_context(
|
async def build_prompt_reply_context(self, reply_data=None, available_actions: List[str] = None) -> str:
|
||||||
self, reply_data=None, available_actions: List[str] = None) -> str:
|
|
||||||
"""
|
"""
|
||||||
构建回复器上下文
|
构建回复器上下文
|
||||||
|
|
||||||
@@ -587,7 +584,9 @@ class DefaultReplyer:
|
|||||||
if sender and target:
|
if sender and target:
|
||||||
if is_group_chat:
|
if is_group_chat:
|
||||||
if sender:
|
if sender:
|
||||||
reply_target_block = f"现在{sender}说的:{target}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
reply_target_block = (
|
||||||
|
f"现在{sender}说的:{target}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
|
)
|
||||||
elif target:
|
elif target:
|
||||||
reply_target_block = f"现在{target}引起了你的注意,你想要在群里发言或者回复这条消息。"
|
reply_target_block = f"现在{target}引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
else:
|
else:
|
||||||
@@ -608,7 +607,6 @@ class DefaultReplyer:
|
|||||||
if prompt_info:
|
if prompt_info:
|
||||||
prompt_info = await global_prompt_manager.format_prompt("knowledge_prompt", prompt_info=prompt_info)
|
prompt_info = await global_prompt_manager.format_prompt("knowledge_prompt", prompt_info=prompt_info)
|
||||||
|
|
||||||
|
|
||||||
template_name = "default_generator_prompt"
|
template_name = "default_generator_prompt"
|
||||||
if is_group_chat:
|
if is_group_chat:
|
||||||
chat_target_1 = await global_prompt_manager.get_prompt_async("chat_target_group1")
|
chat_target_1 = await global_prompt_manager.get_prompt_async("chat_target_group1")
|
||||||
@@ -620,12 +618,10 @@ class DefaultReplyer:
|
|||||||
self.chat_target_info.get("person_name") or self.chat_target_info.get("user_nickname") or "对方"
|
self.chat_target_info.get("person_name") or self.chat_target_info.get("user_nickname") or "对方"
|
||||||
)
|
)
|
||||||
chat_target_1 = await global_prompt_manager.get_prompt_async(
|
chat_target_1 = await global_prompt_manager.get_prompt_async(
|
||||||
"chat_target_private1",
|
"chat_target_private1", sender_name=chat_target_name
|
||||||
sender_name = chat_target_name
|
|
||||||
)
|
)
|
||||||
chat_target_2 = await global_prompt_manager.get_prompt_async(
|
chat_target_2 = await global_prompt_manager.get_prompt_async(
|
||||||
"chat_target_private2",
|
"chat_target_private2", sender_name=chat_target_name
|
||||||
sender_name = chat_target_name
|
|
||||||
)
|
)
|
||||||
|
|
||||||
prompt = await global_prompt_manager.format_prompt(
|
prompt = await global_prompt_manager.format_prompt(
|
||||||
@@ -668,7 +664,6 @@ class DefaultReplyer:
|
|||||||
reply_to = reply_data.get("reply_to", "none")
|
reply_to = reply_data.get("reply_to", "none")
|
||||||
sender, target = self._parse_reply_target(reply_to)
|
sender, target = self._parse_reply_target(reply_to)
|
||||||
|
|
||||||
|
|
||||||
message_list_before_now_half = get_raw_msg_before_timestamp_with_chat(
|
message_list_before_now_half = get_raw_msg_before_timestamp_with_chat(
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
timestamp=time.time(),
|
timestamp=time.time(),
|
||||||
@@ -684,7 +679,7 @@ class DefaultReplyer:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 并行执行2个构建任务
|
# 并行执行2个构建任务
|
||||||
expression_habits_block, relation_info= await asyncio.gather(
|
expression_habits_block, relation_info = await asyncio.gather(
|
||||||
self.build_expression_habits(chat_talking_prompt_half, target),
|
self.build_expression_habits(chat_talking_prompt_half, target),
|
||||||
self.build_relation_info(reply_data, chat_talking_prompt_half),
|
self.build_relation_info(reply_data, chat_talking_prompt_half),
|
||||||
)
|
)
|
||||||
@@ -724,7 +719,9 @@ class DefaultReplyer:
|
|||||||
if sender and target:
|
if sender and target:
|
||||||
if is_group_chat:
|
if is_group_chat:
|
||||||
if sender:
|
if sender:
|
||||||
reply_target_block = f"现在{sender}说的:{target}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
reply_target_block = (
|
||||||
|
f"现在{sender}说的:{target}。引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
|
)
|
||||||
elif target:
|
elif target:
|
||||||
reply_target_block = f"现在{target}引起了你的注意,你想要在群里发言或者回复这条消息。"
|
reply_target_block = f"现在{target}引起了你的注意,你想要在群里发言或者回复这条消息。"
|
||||||
else:
|
else:
|
||||||
@@ -739,8 +736,7 @@ class DefaultReplyer:
|
|||||||
else:
|
else:
|
||||||
reply_target_block = ""
|
reply_target_block = ""
|
||||||
|
|
||||||
mood_prompt = mood_manager.get_mood_prompt()
|
mood_manager.get_mood_prompt()
|
||||||
|
|
||||||
|
|
||||||
if is_group_chat:
|
if is_group_chat:
|
||||||
chat_target_1 = await global_prompt_manager.get_prompt_async("chat_target_group1")
|
chat_target_1 = await global_prompt_manager.get_prompt_async("chat_target_group1")
|
||||||
@@ -752,12 +748,10 @@ class DefaultReplyer:
|
|||||||
self.chat_target_info.get("person_name") or self.chat_target_info.get("user_nickname") or "对方"
|
self.chat_target_info.get("person_name") or self.chat_target_info.get("user_nickname") or "对方"
|
||||||
)
|
)
|
||||||
chat_target_1 = await global_prompt_manager.get_prompt_async(
|
chat_target_1 = await global_prompt_manager.get_prompt_async(
|
||||||
"chat_target_private1",
|
"chat_target_private1", sender_name=chat_target_name
|
||||||
sender_name = chat_target_name
|
|
||||||
)
|
)
|
||||||
chat_target_2 = await global_prompt_manager.get_prompt_async(
|
chat_target_2 = await global_prompt_manager.get_prompt_async(
|
||||||
"chat_target_private2",
|
"chat_target_private2", sender_name=chat_target_name
|
||||||
sender_name = chat_target_name
|
|
||||||
)
|
)
|
||||||
|
|
||||||
template_name = "default_expressor_prompt"
|
template_name = "default_expressor_prompt"
|
||||||
|
|||||||
Reference in New Issue
Block a user