better:优化心流能力
This commit is contained in:
@@ -44,7 +44,7 @@ def init_prompt():
|
|||||||
prompt += "现在请你根据刚刚的想法继续思考,思考时可以想想如何对群聊内容进行回复,要不要对群里的话题进行回复,关注新话题,可以适当转换话题,大家正在说的话才是聊天的主题。\n"
|
prompt += "现在请你根据刚刚的想法继续思考,思考时可以想想如何对群聊内容进行回复,要不要对群里的话题进行回复,关注新话题,可以适当转换话题,大家正在说的话才是聊天的主题。\n"
|
||||||
prompt += "回复的要求是:平淡一些,简短一些,说中文,如果你要回复,最好只回复一个人的一个话题\n"
|
prompt += "回复的要求是:平淡一些,简短一些,说中文,如果你要回复,最好只回复一个人的一个话题\n"
|
||||||
prompt += "请注意不要输出多余内容(包括前后缀,冒号和引号,括号, 表情,等),不要带有括号和动作描写。不要回复自己的发言,尽量不要说你说过的话。"
|
prompt += "请注意不要输出多余内容(包括前后缀,冒号和引号,括号, 表情,等),不要带有括号和动作描写。不要回复自己的发言,尽量不要说你说过的话。"
|
||||||
prompt += "现在请你继续生成你在这个聊天中的想法,不要分点输出,生成内心想法,文字不要浮夸"
|
prompt += "现在请你{hf_do_next},不要分点输出,生成内心想法,文字不要浮夸"
|
||||||
|
|
||||||
Prompt(prompt, "sub_heartflow_prompt_before")
|
Prompt(prompt, "sub_heartflow_prompt_before")
|
||||||
|
|
||||||
@@ -176,6 +176,26 @@ class SubHeartflow:
|
|||||||
prompt_personality += f",{random_detail}"
|
prompt_personality += f",{random_detail}"
|
||||||
|
|
||||||
time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||||
|
|
||||||
|
|
||||||
|
# 创建局部Random对象避免影响全局随机状态
|
||||||
|
local_random = random.Random()
|
||||||
|
current_minute = int(time.strftime("%M"))
|
||||||
|
local_random.seed(current_minute) # 用分钟作为种子确保每分钟内选择一致
|
||||||
|
|
||||||
|
hf_options = [
|
||||||
|
("继续生成你在这个聊天中的想法,在原来想法的基础上继续思考", 0.7),
|
||||||
|
("生成你在这个聊天中的想法,在原来的想法上尝试新的话题", 0.1),
|
||||||
|
("生成你在这个聊天中的想法,不要太深入", 0.1),
|
||||||
|
("继续生成你在这个聊天中的想法,进行深入思考", 0.1)
|
||||||
|
]
|
||||||
|
|
||||||
|
hf_do_next = local_random.choices(
|
||||||
|
[option[0] for option in hf_options],
|
||||||
|
weights=[option[1] for option in hf_options],
|
||||||
|
k=1
|
||||||
|
)[0]
|
||||||
|
|
||||||
|
|
||||||
prompt = (await global_prompt_manager.get_prompt_async("sub_heartflow_prompt_before")).format(
|
prompt = (await global_prompt_manager.get_prompt_async("sub_heartflow_prompt_before")).format(
|
||||||
extra_info=extra_info_prompt,
|
extra_info=extra_info_prompt,
|
||||||
@@ -186,6 +206,7 @@ class SubHeartflow:
|
|||||||
time_now=time_now,
|
time_now=time_now,
|
||||||
chat_observe_info=chat_observe_info,
|
chat_observe_info=chat_observe_info,
|
||||||
mood_info=mood_info,
|
mood_info=mood_info,
|
||||||
|
hf_do_next=hf_do_next,
|
||||||
# sender_name=sender_name_sign,
|
# sender_name=sender_name_sign,
|
||||||
# message_txt=message_txt,
|
# message_txt=message_txt,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ HISTORY_LOG_FILENAME = "interest_history.log" # 新的历史日志文件名
|
|||||||
|
|
||||||
# --- 新增:概率回复相关常量 ---
|
# --- 新增:概率回复相关常量 ---
|
||||||
REPLY_TRIGGER_THRESHOLD = 3.0 # 触发概率回复的兴趣阈值 (示例值)
|
REPLY_TRIGGER_THRESHOLD = 3.0 # 触发概率回复的兴趣阈值 (示例值)
|
||||||
BASE_REPLY_PROBABILITY = 0.05 # 首次超过阈值时的基础回复概率 (示例值)
|
BASE_REPLY_PROBABILITY = 0.1 # 首次超过阈值时的基础回复概率 (示例值)
|
||||||
PROBABILITY_INCREASE_RATE_PER_SECOND = 0.02 # 高于阈值时,每秒概率增加量 (线性增长, 示例值)
|
PROBABILITY_INCREASE_RATE_PER_SECOND = 0.02 # 高于阈值时,每秒概率增加量 (线性增长, 示例值)
|
||||||
PROBABILITY_DECAY_FACTOR_PER_SECOND = 0.3 # 低于阈值时,每秒概率衰减因子 (指数衰减, 示例值)
|
PROBABILITY_DECAY_FACTOR_PER_SECOND = 0.2 # 低于阈值时,每秒概率衰减因子 (指数衰减, 示例值)
|
||||||
MAX_REPLY_PROBABILITY = 1 # 回复概率上限 (示例值)
|
MAX_REPLY_PROBABILITY = 1 # 回复概率上限 (示例值)
|
||||||
# --- 结束:概率回复相关常量 ---
|
# --- 结束:概率回复相关常量 ---
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class PFChatting:
|
|||||||
max_tokens=1000,
|
max_tokens=1000,
|
||||||
request_type="action_planning",
|
request_type="action_planning",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Internal state for loop control
|
# Internal state for loop control
|
||||||
self._loop_timer: float = 0.0 # Remaining time for the loop in seconds
|
self._loop_timer: float = 0.0 # Remaining time for the loop in seconds
|
||||||
@@ -711,7 +712,7 @@ class PFChatting:
|
|||||||
else:
|
else:
|
||||||
prompt += "当前没有观察到新的聊天内容。\n"
|
prompt += "当前没有观察到新的聊天内容。\n"
|
||||||
|
|
||||||
prompt += "\n你的内心想法是:"
|
prompt += "\n看了以上内容,你产生的内心想法是:"
|
||||||
if current_mind:
|
if current_mind:
|
||||||
prompt += f"\n---\n{current_mind}\n---\n\n"
|
prompt += f"\n---\n{current_mind}\n---\n\n"
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ def num_new_messages_since_with_users(chat_id: str, timestamp_start: float, time
|
|||||||
async def _build_readable_messages_internal(
|
async def _build_readable_messages_internal(
|
||||||
messages: List[Dict[str, Any]],
|
messages: List[Dict[str, Any]],
|
||||||
replace_bot_name: bool = True,
|
replace_bot_name: bool = True,
|
||||||
merge_messages: bool = True,
|
merge_messages: bool = False,
|
||||||
timestamp_mode: str = "relative" # 新增参数控制时间戳格式
|
timestamp_mode: str = "relative" # 新增参数控制时间戳格式
|
||||||
) -> Tuple[str, List[Tuple[float, str, str]]]:
|
) -> Tuple[str, List[Tuple[float, str, str]]]:
|
||||||
"""
|
"""
|
||||||
@@ -223,7 +223,7 @@ async def _build_readable_messages_internal(
|
|||||||
async def build_readable_messages_with_list(
|
async def build_readable_messages_with_list(
|
||||||
messages: List[Dict[str, Any]],
|
messages: List[Dict[str, Any]],
|
||||||
replace_bot_name: bool = True,
|
replace_bot_name: bool = True,
|
||||||
merge_messages: bool = True,
|
merge_messages: bool = False,
|
||||||
timestamp_mode: str = "relative"
|
timestamp_mode: str = "relative"
|
||||||
) -> Tuple[str, List[Tuple[float, str, str]]]:
|
) -> Tuple[str, List[Tuple[float, str, str]]]:
|
||||||
"""
|
"""
|
||||||
@@ -238,7 +238,7 @@ async def build_readable_messages_with_list(
|
|||||||
async def build_readable_messages(
|
async def build_readable_messages(
|
||||||
messages: List[Dict[str, Any]],
|
messages: List[Dict[str, Any]],
|
||||||
replace_bot_name: bool = True,
|
replace_bot_name: bool = True,
|
||||||
merge_messages: bool = True,
|
merge_messages: bool = False,
|
||||||
timestamp_mode: str = "relative"
|
timestamp_mode: str = "relative"
|
||||||
) -> str:
|
) -> str:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user