适配新的人设获取工具
This commit is contained in:
@@ -93,8 +93,7 @@ class ActionPlanner:
|
|||||||
max_tokens=1500,
|
max_tokens=1500,
|
||||||
request_type="action_planning",
|
request_type="action_planning",
|
||||||
)
|
)
|
||||||
self.personality_info = Individuality.get_instance().get_prompt(type="personality", x_person=2, level=3)
|
self.personality_info = Individuality.get_instance().get_prompt(x_person=2, level=3)
|
||||||
self.identity_detail_info = Individuality.get_instance().get_prompt(type="identity", x_person=2, level=2)
|
|
||||||
self.name = global_config.BOT_NICKNAME
|
self.name = global_config.BOT_NICKNAME
|
||||||
self.private_name = private_name
|
self.private_name = private_name
|
||||||
self.chat_observer = ChatObserver.get_instance(stream_id, private_name)
|
self.chat_observer = ChatObserver.get_instance(stream_id, private_name)
|
||||||
@@ -244,21 +243,7 @@ class ActionPlanner:
|
|||||||
chat_history_text = "处理聊天记录时出错。\n"
|
chat_history_text = "处理聊天记录时出错。\n"
|
||||||
|
|
||||||
# 构建 Persona 文本 (persona_text)
|
# 构建 Persona 文本 (persona_text)
|
||||||
# (这部分逻辑不变)
|
persona_text = f"你的名字是{self.name},{self.personality_info}。"
|
||||||
identity_details_only = self.identity_detail_info
|
|
||||||
identity_addon = ""
|
|
||||||
if isinstance(identity_details_only, str):
|
|
||||||
pronouns = ["你", "我", "他"]
|
|
||||||
for p in pronouns:
|
|
||||||
if identity_details_only.startswith(p):
|
|
||||||
identity_details_only = identity_details_only[len(p) :]
|
|
||||||
break
|
|
||||||
if identity_details_only.endswith("。"):
|
|
||||||
identity_details_only = identity_details_only[:-1]
|
|
||||||
cleaned_details = identity_details_only.strip(",, ")
|
|
||||||
if cleaned_details:
|
|
||||||
identity_addon = f"并且{cleaned_details}"
|
|
||||||
persona_text = f"你的名字是{self.name},{self.personality_info}{identity_addon}。"
|
|
||||||
|
|
||||||
# 构建行动历史和上一次行动结果 (action_history_summary, last_action_context)
|
# 构建行动历史和上一次行动结果 (action_history_summary, last_action_context)
|
||||||
# (这部分逻辑不变)
|
# (这部分逻辑不变)
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ class GoalAnalyzer:
|
|||||||
model=global_config.llm_normal, temperature=0.7, max_tokens=1000, request_type="conversation_goal"
|
model=global_config.llm_normal, temperature=0.7, max_tokens=1000, request_type="conversation_goal"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.personality_info = Individuality.get_instance().get_prompt(type="personality", x_person=2, level=3)
|
self.personality_info = Individuality.get_instance().get_prompt(x_person=2, level=3)
|
||||||
self.identity_detail_info = Individuality.get_instance().get_prompt(type="identity", x_person=2, level=2)
|
|
||||||
self.name = global_config.BOT_NICKNAME
|
self.name = global_config.BOT_NICKNAME
|
||||||
self.nick_name = global_config.BOT_ALIAS_NAMES
|
self.nick_name = global_config.BOT_ALIAS_NAMES
|
||||||
self.private_name = private_name
|
self.private_name = private_name
|
||||||
@@ -79,21 +78,7 @@ class GoalAnalyzer:
|
|||||||
|
|
||||||
# await observation_info.clear_unprocessed_messages()
|
# await observation_info.clear_unprocessed_messages()
|
||||||
|
|
||||||
identity_details_only = self.identity_detail_info
|
persona_text = f"你的名字是{self.name},{self.personality_info}。"
|
||||||
identity_addon = ""
|
|
||||||
if isinstance(identity_details_only, str):
|
|
||||||
pronouns = ["你", "我", "他"]
|
|
||||||
for p in pronouns:
|
|
||||||
if identity_details_only.startswith(p):
|
|
||||||
identity_details_only = identity_details_only[len(p) :]
|
|
||||||
break
|
|
||||||
if identity_details_only.endswith("。"):
|
|
||||||
identity_details_only = identity_details_only[:-1]
|
|
||||||
cleaned_details = identity_details_only.strip(",, ")
|
|
||||||
if cleaned_details:
|
|
||||||
identity_addon = f"并且{cleaned_details}"
|
|
||||||
|
|
||||||
persona_text = f"你的名字是{self.name},{self.personality_info}{identity_addon}。"
|
|
||||||
# 构建action历史文本
|
# 构建action历史文本
|
||||||
action_history_list = conversation_info.done_action
|
action_history_list = conversation_info.done_action
|
||||||
action_history_text = "你之前做的事情是:"
|
action_history_text = "你之前做的事情是:"
|
||||||
@@ -241,21 +226,8 @@ class GoalAnalyzer:
|
|||||||
timestamp_mode="relative",
|
timestamp_mode="relative",
|
||||||
read_mark=0.0,
|
read_mark=0.0,
|
||||||
)
|
)
|
||||||
identity_details_only = self.identity_detail_info
|
|
||||||
identity_addon = ""
|
|
||||||
if isinstance(identity_details_only, str):
|
|
||||||
pronouns = ["你", "我", "他"]
|
|
||||||
for p in pronouns:
|
|
||||||
if identity_details_only.startswith(p):
|
|
||||||
identity_details_only = identity_details_only[len(p) :]
|
|
||||||
break
|
|
||||||
if identity_details_only.endswith("。"):
|
|
||||||
identity_details_only = identity_details_only[:-1]
|
|
||||||
cleaned_details = identity_details_only.strip(",, ")
|
|
||||||
if cleaned_details:
|
|
||||||
identity_addon = f"并且{cleaned_details}"
|
|
||||||
|
|
||||||
persona_text = f"你的名字是{self.name},{self.personality_info}{identity_addon}。"
|
persona_text = f"你的名字是{self.name},{self.personality_info}。"
|
||||||
# ===> Persona 文本构建结束 <===
|
# ===> Persona 文本构建结束 <===
|
||||||
|
|
||||||
# --- 修改 Prompt 字符串,使用 persona_text ---
|
# --- 修改 Prompt 字符串,使用 persona_text ---
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ class ReplyGenerator:
|
|||||||
max_tokens=300,
|
max_tokens=300,
|
||||||
request_type="reply_generation",
|
request_type="reply_generation",
|
||||||
)
|
)
|
||||||
self.personality_info = Individuality.get_instance().get_prompt(type="personality", x_person=2, level=3)
|
self.personality_info = Individuality.get_instance().get_prompt(x_person=2, level=3)
|
||||||
self.identity_detail_info = Individuality.get_instance().get_prompt(type="identity", x_person=2, level=2)
|
|
||||||
self.name = global_config.BOT_NICKNAME
|
self.name = global_config.BOT_NICKNAME
|
||||||
self.private_name = private_name
|
self.private_name = private_name
|
||||||
self.chat_observer = ChatObserver.get_instance(stream_id, private_name)
|
self.chat_observer = ChatObserver.get_instance(stream_id, private_name)
|
||||||
@@ -130,20 +129,7 @@ class ReplyGenerator:
|
|||||||
chat_history_text = "还没有聊天记录。"
|
chat_history_text = "还没有聊天记录。"
|
||||||
|
|
||||||
# 构建 Persona 文本 (persona_text)
|
# 构建 Persona 文本 (persona_text)
|
||||||
identity_details_only = self.identity_detail_info
|
persona_text = f"你的名字是{self.name},{self.personality_info}。"
|
||||||
identity_addon = ""
|
|
||||||
if isinstance(identity_details_only, str):
|
|
||||||
pronouns = ["你", "我", "他"]
|
|
||||||
for p in pronouns:
|
|
||||||
if identity_details_only.startswith(p):
|
|
||||||
identity_details_only = identity_details_only[len(p) :]
|
|
||||||
break
|
|
||||||
if identity_details_only.endswith("。"):
|
|
||||||
identity_details_only = identity_details_only[:-1]
|
|
||||||
cleaned_details = identity_details_only.strip(",, ")
|
|
||||||
if cleaned_details:
|
|
||||||
identity_addon = f"并且{cleaned_details}"
|
|
||||||
persona_text = f"你的名字是{self.name},{self.personality_info}{identity_addon}。"
|
|
||||||
|
|
||||||
# --- 选择 Prompt ---
|
# --- 选择 Prompt ---
|
||||||
if action_type == "send_new_message":
|
if action_type == "send_new_message":
|
||||||
|
|||||||
Reference in New Issue
Block a user