mirror of https://github.com/Mai-with-u/MaiBot.git
feat:可自定义planner行为
parent
298a74da64
commit
fb587f6475
|
|
@ -39,6 +39,7 @@ def init_prompt():
|
|||
"""
|
||||
{time_block}
|
||||
{name_block}
|
||||
你的兴趣是:{interest}
|
||||
{chat_context_description},以下是具体的聊天内容
|
||||
**聊天内容**
|
||||
{chat_content_block}
|
||||
|
|
@ -76,13 +77,8 @@ no_reply_until_call
|
|||
请选择合适的action,并说明触发action的消息id和选择该action的原因。消息id格式:m+数字
|
||||
先输出你的选择思考理由,再输出你选择的action,理由是一段平文本,不要分点,精简。
|
||||
**动作选择要求**
|
||||
请你根据聊天内容和用户的最新消息选择合适的动作:
|
||||
1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用调节符合当下条件就使用
|
||||
2.如果相同的内容已经被执行,请不要重复执行
|
||||
3.你的兴趣是:{interest}
|
||||
4.请控制你的发言频率,不要太过频繁的发言
|
||||
5.如果有人对你感到厌烦,请减少回复
|
||||
6.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对
|
||||
请你根据聊天内容,用户的最新消息和以下标准选择合适的动作:
|
||||
{plan_style}
|
||||
{moderation_prompt}
|
||||
|
||||
请选择所有符合使用要求的action,动作用json格式输出,如果输出多个json,每个json都要单独用```json包裹,你可以重复使用同一个动作或不同动作:
|
||||
|
|
@ -349,6 +345,7 @@ class ActionPlanner:
|
|||
moderation_prompt=moderation_prompt_block,
|
||||
name_block=name_block,
|
||||
interest=interest,
|
||||
plan_style=global_config.personality.plan_style,
|
||||
)
|
||||
|
||||
return prompt, message_id_list
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ class ImageManager:
|
|||
|
||||
# 调用AI获取描述
|
||||
image_format = Image.open(io.BytesIO(image_bytes)).format.lower() # type: ignore
|
||||
prompt = global_config.custom_prompt.image_prompt
|
||||
prompt = global_config.personality.visual_style
|
||||
logger.info(f"[VLM调用] 为图片生成新描述 (Hash: {image_hash[:8]}...)")
|
||||
description, _ = await self.vlm.generate_response_for_image(
|
||||
prompt, image_base64, image_format, temperature=0.4, max_tokens=300
|
||||
|
|
@ -566,7 +566,7 @@ class ImageManager:
|
|||
image_format = Image.open(io.BytesIO(image_bytes)).format.lower() # type: ignore
|
||||
|
||||
# 构建prompt
|
||||
prompt = global_config.custom_prompt.image_prompt
|
||||
prompt = global_config.personality.visual_style
|
||||
|
||||
# 获取VLM描述
|
||||
description, _ = await self.vlm.generate_response_for_image(
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ from src.config.official_configs import (
|
|||
ToolConfig,
|
||||
VoiceConfig,
|
||||
DebugConfig,
|
||||
CustomPromptConfig,
|
||||
)
|
||||
|
||||
from .api_ada_configs import (
|
||||
|
|
@ -357,7 +356,6 @@ class Config(ConfigBase):
|
|||
lpmm_knowledge: LPMMKnowledgeConfig
|
||||
tool: ToolConfig
|
||||
debug: DebugConfig
|
||||
custom_prompt: CustomPromptConfig
|
||||
voice: VoiceConfig
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ class PersonalityConfig(ConfigBase):
|
|||
|
||||
interest: str = ""
|
||||
"""兴趣"""
|
||||
|
||||
plan_style: str = ""
|
||||
"""说话规则,行为风格"""
|
||||
|
||||
visual_style: str = ""
|
||||
"""图片提示词"""
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
@ -385,14 +391,6 @@ class KeywordReactionConfig(ConfigBase):
|
|||
raise ValueError(f"规则必须是KeywordRuleConfig类型,而不是{type(rule).__name__}")
|
||||
|
||||
|
||||
@dataclass
|
||||
class CustomPromptConfig(ConfigBase):
|
||||
"""自定义提示词配置类"""
|
||||
|
||||
image_prompt: str = ""
|
||||
"""图片提示词"""
|
||||
|
||||
|
||||
@dataclass
|
||||
class ResponsePostProcessConfig(ConfigBase):
|
||||
"""回复后处理配置类"""
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[inner]
|
||||
version = "6.10.1"
|
||||
version = "6.11.0"
|
||||
|
||||
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
||||
#如果你想要修改配置文件,请递增version的值
|
||||
|
|
@ -28,6 +28,17 @@ emotion_style = "情绪较为稳定,但遭遇特定事件的时候起伏较大
|
|||
# 麦麦的兴趣,会影响麦麦对什么话题进行回复
|
||||
interest = "对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题"
|
||||
|
||||
# 麦麦的说话规则,行为风格:
|
||||
plan_style = """请你根据聊天内容,用户的最新消息和以下标准选择合适的动作:
|
||||
1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
|
||||
2.如果相同的内容已经被执行,请不要重复执行
|
||||
3.请控制你的发言频率,不要太过频繁的发言
|
||||
4.如果有人对你感到厌烦,请减少回复
|
||||
5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对"""
|
||||
|
||||
# 麦麦识图规则,不建议修改
|
||||
visual_style = "请用中文描述这张图片的内容。如果有文字,请把文字描述概括出来,请留意其主题,直观感受,输出为一段平文本,最多30字,请注意不要分点,就输出一段文本"
|
||||
|
||||
[expression]
|
||||
# 表达学习配置
|
||||
learning_list = [ # 表达学习配置列表,支持按聊天流配置
|
||||
|
|
@ -121,10 +132,6 @@ regex_rules = [
|
|||
{ regex = ["^(?P<n>\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的,xx只要xx就可以,可是[n]要考虑的事情就很多了,比如什么时候xx,什么时候xx,什么时候xx。(请自由发挥替换xx部分,只需保持句式结构,同时表达一种将[n]过度重视的反讽意味)" }
|
||||
]
|
||||
|
||||
# 可以自定义部分提示词
|
||||
[custom_prompt]
|
||||
image_prompt = "请用中文描述这张图片的内容。如果有文字,请把文字描述概括出来,请留意其主题,直观感受,输出为一段平文本,最多30字,请注意不要分点,就输出一段文本"
|
||||
|
||||
[response_post_process]
|
||||
enable_response_post_process = true # 是否启用回复后处理,包括错别字生成器,回复分割器
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue