🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -23,11 +23,7 @@ class EmojiAction(BaseAction):
|
|||||||
action_parameters: dict[str:str] = {
|
action_parameters: dict[str:str] = {
|
||||||
"description": "文字描述你想要发送的表情",
|
"description": "文字描述你想要发送的表情",
|
||||||
}
|
}
|
||||||
action_require: list[str] = [
|
action_require: list[str] = ["你想要发送一个表情", "表达情绪时可以选择使用", "一般在你回复之后可以选择性使用"]
|
||||||
"你想要发送一个表情",
|
|
||||||
"表达情绪时可以选择使用",
|
|
||||||
"一般在你回复之后可以选择性使用"
|
|
||||||
]
|
|
||||||
|
|
||||||
associated_types: list[str] = ["emoji"]
|
associated_types: list[str] = ["emoji"]
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ def init_prompt():
|
|||||||
"simple_planner_prompt",
|
"simple_planner_prompt",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
Prompt(
|
Prompt(
|
||||||
"""
|
"""
|
||||||
动作名称:{action_name}
|
动作名称:{action_name}
|
||||||
@@ -192,7 +191,6 @@ class ActionPlanner(BasePlanner):
|
|||||||
reasoning = f"LLM 请求失败,你的模型出现问题: {req_e}"
|
reasoning = f"LLM 请求失败,你的模型出现问题: {req_e}"
|
||||||
action = "no_reply"
|
action = "no_reply"
|
||||||
|
|
||||||
|
|
||||||
if llm_content:
|
if llm_content:
|
||||||
try:
|
try:
|
||||||
fixed_json_string = repair_json(llm_content)
|
fixed_json_string = repair_json(llm_content)
|
||||||
@@ -233,9 +231,7 @@ class ActionPlanner(BasePlanner):
|
|||||||
reasoning = extracted_reasoning
|
reasoning = extracted_reasoning
|
||||||
|
|
||||||
except Exception as json_e:
|
except Exception as json_e:
|
||||||
logger.warning(
|
logger.warning(f"{self.log_prefix}解析LLM响应JSON失败 {json_e}. LLM原始输出: '{llm_content}'")
|
||||||
f"{self.log_prefix}解析LLM响应JSON失败 {json_e}. LLM原始输出: '{llm_content}'"
|
|
||||||
)
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
reasoning = f"解析LLM响应JSON失败: {json_e}. 将使用默认动作 'no_reply'."
|
reasoning = f"解析LLM响应JSON失败: {json_e}. 将使用默认动作 'no_reply'."
|
||||||
action = "no_reply"
|
action = "no_reply"
|
||||||
|
|||||||
@@ -195,7 +195,6 @@ class DefaultReplyer:
|
|||||||
|
|
||||||
await self._create_thinking_message(anchor_message, thinking_id)
|
await self._create_thinking_message(anchor_message, thinking_id)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
has_sent_something = False
|
has_sent_something = False
|
||||||
sent_msg_list = []
|
sent_msg_list = []
|
||||||
@@ -209,7 +208,6 @@ class DefaultReplyer:
|
|||||||
else:
|
else:
|
||||||
logger.warning(f"{self.log_prefix} 没有找到合适表情")
|
logger.warning(f"{self.log_prefix} 没有找到合适表情")
|
||||||
|
|
||||||
|
|
||||||
if reply:
|
if reply:
|
||||||
with Timer("发送表情", cycle_timers):
|
with Timer("发送表情", cycle_timers):
|
||||||
sent_msg_list = await self.send_response_messages(
|
sent_msg_list = await self.send_response_messages(
|
||||||
@@ -231,8 +229,6 @@ class DefaultReplyer:
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def reply(
|
async def reply(
|
||||||
self,
|
self,
|
||||||
# in_mind_reply: str,
|
# in_mind_reply: str,
|
||||||
@@ -385,7 +381,7 @@ class DefaultReplyer:
|
|||||||
style_habbits_str = "\n".join(style_habbits)
|
style_habbits_str = "\n".join(style_habbits)
|
||||||
grammar_habbits_str = "\n".join(grammar_habbits)
|
grammar_habbits_str = "\n".join(grammar_habbits)
|
||||||
|
|
||||||
# 关键词检测与反应
|
# 关键词检测与反应
|
||||||
keywords_reaction_prompt = ""
|
keywords_reaction_prompt = ""
|
||||||
try:
|
try:
|
||||||
# 处理关键词规则
|
# 处理关键词规则
|
||||||
|
|||||||
@@ -510,11 +510,15 @@ class MemoryManager:
|
|||||||
# 如果有摘要信息,添加到提示中
|
# 如果有摘要信息,添加到提示中
|
||||||
if summary1:
|
if summary1:
|
||||||
prompt += f"记忆1主题:{summary1['brief']}\n"
|
prompt += f"记忆1主题:{summary1['brief']}\n"
|
||||||
prompt += "记忆1关键要点:\n" + "\n".join([f"- {point}" for point in summary1.get("key_points", [])]) + "\n\n"
|
prompt += (
|
||||||
|
"记忆1关键要点:\n" + "\n".join([f"- {point}" for point in summary1.get("key_points", [])]) + "\n\n"
|
||||||
|
)
|
||||||
|
|
||||||
if summary2:
|
if summary2:
|
||||||
prompt += f"记忆2主题:{summary2['brief']}\n"
|
prompt += f"记忆2主题:{summary2['brief']}\n"
|
||||||
prompt += "记忆2关键要点:\n" + "\n".join([f"- {point}" for point in summary2.get("key_points", [])]) + "\n\n"
|
prompt += (
|
||||||
|
"记忆2关键要点:\n" + "\n".join([f"- {point}" for point in summary2.get("key_points", [])]) + "\n\n"
|
||||||
|
)
|
||||||
|
|
||||||
# 添加记忆原始内容
|
# 添加记忆原始内容
|
||||||
prompt += f"""
|
prompt += f"""
|
||||||
|
|||||||
@@ -184,9 +184,7 @@ class ImageManager:
|
|||||||
return f"[图片:{cached_description}]"
|
return f"[图片:{cached_description}]"
|
||||||
|
|
||||||
# 调用AI获取描述
|
# 调用AI获取描述
|
||||||
prompt = (
|
prompt = "请用中文描述这张图片的内容。如果有文字,请把文字都描述出来,请留意其主题,直观感受,以及是否有擦边色情内容。最多100个字。"
|
||||||
"请用中文描述这张图片的内容。如果有文字,请把文字都描述出来,请留意其主题,直观感受,以及是否有擦边色情内容。最多100个字。"
|
|
||||||
)
|
|
||||||
description, _ = await self._llm.generate_response_for_image(prompt, image_base64, image_format)
|
description, _ = await self._llm.generate_response_for_image(prompt, image_base64, image_format)
|
||||||
|
|
||||||
if description is None:
|
if description is None:
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ class TelemetryHeartBeatTask(AsyncTask):
|
|||||||
else:
|
else:
|
||||||
logger.error("无效的服务端响应")
|
logger.error("无效的服务端响应")
|
||||||
else:
|
else:
|
||||||
logger.error(f"请求UUID失败,不过你还是可以正常使用麦麦,状态码: {response.status_code}, 响应内容: {response.text}")
|
logger.error(
|
||||||
|
f"请求UUID失败,不过你还是可以正常使用麦麦,状态码: {response.status_code}, 响应内容: {response.text}"
|
||||||
|
)
|
||||||
|
|
||||||
# 请求失败,重试次数+1
|
# 请求失败,重试次数+1
|
||||||
try_count += 1
|
try_count += 1
|
||||||
|
|||||||
@@ -79,7 +79,11 @@ class ConfigBase:
|
|||||||
|
|
||||||
if field_origin_type is list:
|
if field_origin_type is list:
|
||||||
# 如果列表元素类型是ConfigBase的子类,则对每个元素调用from_dict
|
# 如果列表元素类型是ConfigBase的子类,则对每个元素调用from_dict
|
||||||
if field_type_args and isinstance(field_type_args[0], type) and issubclass(field_type_args[0], ConfigBase):
|
if (
|
||||||
|
field_type_args
|
||||||
|
and isinstance(field_type_args[0], type)
|
||||||
|
and issubclass(field_type_args[0], ConfigBase)
|
||||||
|
):
|
||||||
return [field_type_args[0].from_dict(item) for item in value]
|
return [field_type_args[0].from_dict(item) for item in value]
|
||||||
return [cls._convert_field(item, field_type_args[0]) for item in value]
|
return [cls._convert_field(item, field_type_args[0]) for item in value]
|
||||||
elif field_origin_type is set:
|
elif field_origin_type is set:
|
||||||
|
|||||||
Reference in New Issue
Block a user