remove:无用配置
This commit is contained in:
@@ -24,9 +24,7 @@
|
||||
3. 对于参数化泛型,应该使用`typing`模块中的类型注解来指定参数化泛型的类型。
|
||||
- 例如,使用`List[int]`来表示一个包含整数的列表,使用`Dict[str, Any]`来表示一个键为字符串,值为任意类型的字典。
|
||||
## 变量规范
|
||||
1. 变量命名应该具有描述性,能够清晰地表达变量的用途和含义。
|
||||
2. 变量命名应该遵循下划线命名法。
|
||||
3. 当确定某个变量/实例是某种类型的时候(优先按照类型注解确定,除非你分析出类型注解是错误的),可以不必使用`or`进行fallback。
|
||||
1. 当确定某个变量/实例是某种类型的时候(优先按照类型注解确定,除非你分析出类型注解是错误的),可以不必使用`or`进行fallback。
|
||||
- 例如,`bot_nickname = (global_config.bot.nickname or "").strip()` 可以改为 `bot_nickname = global_config.bot.nickname.strip()`,前提是我们确定`global_config.bot.nickname`一定是一个字符串。
|
||||
## 类属性使用规范
|
||||
1. 应该尽量减少使用getattr和setattr方法,除非是在对一个动态类进行处理或者使用Monkeypatch完成Pytest
|
||||
@@ -36,6 +34,7 @@
|
||||
# 运行/调试/构建/测试/依赖
|
||||
优先使用uv
|
||||
依赖项以 pyproject.toml 为准
|
||||
不要修改dashboard下的内容,因为这部分内容由另一个仓库build
|
||||
|
||||
# 语言规范
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ async def generate_reply(
|
||||
reply_to: str = "",
|
||||
extra_info: str = "",
|
||||
available_actions: Optional[Dict[str, ActionInfo]] = None,
|
||||
enable_tool: bool = False,
|
||||
enable_splitter: bool = True,
|
||||
enable_chinese_typo: bool = True,
|
||||
return_prompt: bool = False,
|
||||
@@ -73,7 +72,6 @@ async def generate_reply(
|
||||
- `reply_to`: 回复目标,格式为 `{发送者的person_name:消息内容}`
|
||||
- `extra_info`: 附加信息
|
||||
- `available_actions`: 可用动作字典,格式为 `{"action_name": ActionInfo}`
|
||||
- `enable_tool`: 是否启用工具
|
||||
- `enable_splitter`: 是否启用分割器
|
||||
- `enable_chinese_typo`: 是否启用中文错别字
|
||||
- `return_prompt`: 是否返回提示词
|
||||
@@ -91,7 +89,6 @@ success, reply_set, prompt = await generator_api.generate_reply(
|
||||
action_data=action_data,
|
||||
reply_to="麦麦:你好",
|
||||
available_actions=action_info,
|
||||
enable_tool=True,
|
||||
return_prompt=True
|
||||
)
|
||||
if success:
|
||||
@@ -198,4 +195,4 @@ async def generate_response_custom(
|
||||
2. **聊天流依赖**:需要有效的聊天流对象才能正常工作
|
||||
3. **性能考虑**:回复生成可能需要一些时间,特别是使用LLM时
|
||||
4. **回复格式**:返回的回复集合是元组列表,包含类型和内容
|
||||
5. **上下文感知**:生成器会考虑聊天上下文和历史消息,除非你用的是自定义提示词。
|
||||
5. **上下文感知**:生成器会考虑聊天上下文和历史消息,除非你用的是自定义提示词。
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
|
||||
你可以使用这些工具:
|
||||
- wait(seconds) - 暂时停止对话,等待(seconds)秒,把话语权交给用户,等待对方新的发言。
|
||||
- stop() - 当你判断{bot_name}现在不应该发言,结束对话,不进行任何回复,直到对方有新消息。
|
||||
- no_reply() - 当你判断{bot_name}现在不应该发言,结束对话,不进行任何回复,直到对方有新消息。
|
||||
- reply():当你判断{bot_name}现在应该正式对用户发出一条可见回复时调用。调用后系统会基于你当前这轮的想法生成一条真正展示给用户的回复。
|
||||
- query_jargon():当你认为某些词的含义不明确,或用户询问某些词的含义,需要进行查询
|
||||
- 其他定义的工具,你可以视情况合适使用
|
||||
|
||||
工具使用规则:
|
||||
1.如果{bot_name}已经回复,但用户暂时没有新的回复,且没有新信息需要搜集,使用wait或者stop进行等待
|
||||
1.如果{bot_name}已经回复,但用户暂时没有新的回复,且没有新信息需要搜集,使用wait或者no_reply进行等待
|
||||
2.如果用户有新发言,但是你评估用户还有后续发言尚未发送,可以适当等待让用户说完
|
||||
3.在特定情况下也可以连续回复,例如想要追问,或者补充自己先前的发言,可以不使用stop或者wait
|
||||
4.你需要控制自己发言的频率,如果用户一对一聊天,可以以均匀地频率发言,如果用户较多,不要每句都回复,控制回复频率。当你决定暂时不发言,可以使用wait暂时等待一定时间或者stop等待新消息
|
||||
3.在特定情况下也可以连续回复,例如想要追问,或者补充自己先前的发言,可以不使用no_reply或者wait
|
||||
4.你需要控制自己发言的频率,如果用户一对一聊天,可以以均匀地频率发言,如果用户较多,不要每句都回复,控制回复频率。当你决定暂时不发言,可以使用wait暂时等待一定时间或者no_reply等待新消息
|
||||
5.不要每条消息都回复,不要直接回复别的用户发送的表情包消息,控制回复频率
|
||||
6.如果存在用户的疑问,或者对某些概念的不确定,你可以使用工具来搜集信息或者查询含义,你可以使用多个工具
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ class DefaultReplyer:
|
||||
reply_reason: str = "",
|
||||
available_actions: Optional[Dict[str, ActionInfo]] = None,
|
||||
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
|
||||
enable_tool: bool = True,
|
||||
from_plugin: bool = True,
|
||||
stream_id: Optional[str] = None,
|
||||
reply_message: Optional[SessionMessage] = None,
|
||||
@@ -87,7 +86,6 @@ class DefaultReplyer:
|
||||
reply_reason: 回复原因
|
||||
available_actions: 可用的动作信息字典
|
||||
chosen_actions: 已选动作
|
||||
enable_tool: 是否启用工具调用
|
||||
from_plugin: 是否来自插件
|
||||
|
||||
Returns:
|
||||
@@ -112,7 +110,6 @@ class DefaultReplyer:
|
||||
extra_info=extra_info,
|
||||
available_actions=available_actions,
|
||||
chosen_actions=chosen_actions,
|
||||
enable_tool=enable_tool,
|
||||
reply_message=reply_message,
|
||||
reply_reason=reply_reason,
|
||||
reply_time_point=reply_time_point,
|
||||
@@ -394,26 +391,20 @@ class DefaultReplyer:
|
||||
|
||||
return f"{expression_habits_title}\n{expression_habits_block}", selected_ids
|
||||
|
||||
async def build_tool_info(self, chat_history: str, sender: str, target: str, enable_tool: bool = True) -> str:
|
||||
async def build_tool_info(self, chat_history: str, sender: str, target: str) -> str:
|
||||
del chat_history
|
||||
del sender
|
||||
del target
|
||||
del enable_tool
|
||||
return ""
|
||||
"""构建工具信息块
|
||||
|
||||
Args:
|
||||
chat_history: 聊天历史记录
|
||||
reply_to: 回复对象,格式为 "发送者:消息内容"
|
||||
enable_tool: 是否启用工具调用
|
||||
|
||||
Returns:
|
||||
str: 工具信息字符串
|
||||
"""
|
||||
|
||||
if not enable_tool:
|
||||
return ""
|
||||
|
||||
try:
|
||||
# 使用工具执行器获取信息
|
||||
tool_results = []
|
||||
@@ -741,7 +732,6 @@ class DefaultReplyer:
|
||||
reply_reason: str = "",
|
||||
available_actions: Optional[Dict[str, ActionInfo]] = None,
|
||||
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
|
||||
enable_tool: bool = True,
|
||||
reply_time_point: float = time.time(),
|
||||
think_level: int = 1,
|
||||
unknown_words: Optional[List[str]] = None,
|
||||
@@ -755,7 +745,6 @@ class DefaultReplyer:
|
||||
available_actions: 可用动作
|
||||
chosen_actions: 已选动作
|
||||
enable_timeout: 是否启用超时处理
|
||||
enable_tool: 是否启用工具调用
|
||||
reply_message: 回复的原始消息
|
||||
Returns:
|
||||
str: 构建好的上下文
|
||||
@@ -840,7 +829,7 @@ class DefaultReplyer:
|
||||
"expression_habits",
|
||||
),
|
||||
self._time_and_run_task(
|
||||
self.build_tool_info(chat_talking_prompt_short, sender, target, enable_tool=enable_tool), "tool_info"
|
||||
self.build_tool_info(chat_talking_prompt_short, sender, target), "tool_info"
|
||||
),
|
||||
self._time_and_run_task(self.get_prompt_info(chat_talking_prompt_short, sender, target), "prompt_info"),
|
||||
self._time_and_run_task(self.build_actions_prompt(available_actions, chosen_actions), "actions_info"),
|
||||
|
||||
@@ -288,7 +288,6 @@ class MaisakaReplyGenerator:
|
||||
reply_reason: str = "",
|
||||
available_actions: Optional[Dict[str, ActionInfo]] = None,
|
||||
chosen_actions: Optional[List[object]] = None,
|
||||
enable_tool: bool = True,
|
||||
from_plugin: bool = True,
|
||||
stream_id: Optional[str] = None,
|
||||
reply_message: Optional[SessionMessage] = None,
|
||||
@@ -303,7 +302,6 @@ class MaisakaReplyGenerator:
|
||||
"""结合上下文生成 Maisaka 的最终可见回复。"""
|
||||
del available_actions
|
||||
del chosen_actions
|
||||
del enable_tool
|
||||
del extra_info
|
||||
del from_plugin
|
||||
del log_reply
|
||||
|
||||
@@ -65,7 +65,6 @@ class PrivateReplyer:
|
||||
reply_reason: str = "",
|
||||
available_actions: Optional[Dict[str, ActionInfo]] = None,
|
||||
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
|
||||
enable_tool: bool = True,
|
||||
from_plugin: bool = True,
|
||||
think_level: int = 1,
|
||||
stream_id: Optional[str] = None,
|
||||
@@ -84,7 +83,6 @@ class PrivateReplyer:
|
||||
reply_reason: 回复原因
|
||||
available_actions: 可用的动作信息字典
|
||||
chosen_actions: 已选动作
|
||||
enable_tool: 是否启用工具调用
|
||||
from_plugin: 是否来自插件
|
||||
|
||||
Returns:
|
||||
@@ -103,7 +101,6 @@ class PrivateReplyer:
|
||||
extra_info=extra_info,
|
||||
available_actions=available_actions,
|
||||
chosen_actions=chosen_actions,
|
||||
enable_tool=enable_tool,
|
||||
reply_message=reply_message,
|
||||
reply_reason=reply_reason,
|
||||
unknown_words=unknown_words,
|
||||
@@ -287,26 +284,20 @@ class PrivateReplyer:
|
||||
|
||||
return f"{expression_habits_title}\n{expression_habits_block}", selected_ids
|
||||
|
||||
async def build_tool_info(self, chat_history: str, sender: str, target: str, enable_tool: bool = True) -> str:
|
||||
async def build_tool_info(self, chat_history: str, sender: str, target: str) -> str:
|
||||
del chat_history
|
||||
del sender
|
||||
del target
|
||||
del enable_tool
|
||||
return ""
|
||||
"""构建工具信息块
|
||||
|
||||
Args:
|
||||
chat_history: 聊天历史记录
|
||||
reply_to: 回复对象,格式为 "发送者:消息内容"
|
||||
enable_tool: 是否启用工具调用
|
||||
|
||||
Returns:
|
||||
str: 工具信息字符串
|
||||
"""
|
||||
|
||||
if not enable_tool:
|
||||
return ""
|
||||
|
||||
try:
|
||||
# 使用工具执行器获取信息
|
||||
tool_results = []
|
||||
@@ -612,7 +603,6 @@ class PrivateReplyer:
|
||||
reply_reason: str = "",
|
||||
available_actions: Optional[Dict[str, ActionInfo]] = None,
|
||||
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
|
||||
enable_tool: bool = True,
|
||||
unknown_words: Optional[List[str]] = None,
|
||||
) -> Tuple[str, List[int]]:
|
||||
"""
|
||||
@@ -624,7 +614,6 @@ class PrivateReplyer:
|
||||
available_actions: 可用动作
|
||||
chosen_actions: 已选动作
|
||||
enable_timeout: 是否启用超时处理
|
||||
enable_tool: 是否启用工具调用
|
||||
reply_message: 回复的原始消息
|
||||
Returns:
|
||||
str: 构建好的上下文
|
||||
@@ -719,7 +708,7 @@ class PrivateReplyer:
|
||||
),
|
||||
# self._time_and_run_task(self.build_relation_info(chat_talking_prompt_short, sender), "relation_info"),
|
||||
self._time_and_run_task(
|
||||
self.build_tool_info(chat_talking_prompt_short, sender, target, enable_tool=enable_tool), "tool_info"
|
||||
self.build_tool_info(chat_talking_prompt_short, sender, target), "tool_info"
|
||||
),
|
||||
self._time_and_run_task(self.get_prompt_info(chat_talking_prompt_short, sender, target), "prompt_info"),
|
||||
self._time_and_run_task(self.build_actions_prompt(available_actions, chosen_actions), "actions_info"),
|
||||
|
||||
@@ -36,7 +36,6 @@ from .official_configs import (
|
||||
ResponsePostProcessConfig,
|
||||
ResponseSplitterConfig,
|
||||
TelemetryConfig,
|
||||
ToolConfig,
|
||||
VoiceConfig,
|
||||
WebUIConfig,
|
||||
)
|
||||
@@ -90,9 +89,6 @@ class Config(ConfigBase):
|
||||
message_receive: MessageReceiveConfig = Field(default_factory=MessageReceiveConfig)
|
||||
"""消息接收配置类"""
|
||||
|
||||
tool: ToolConfig = Field(default_factory=ToolConfig)
|
||||
"""工具配置类"""
|
||||
|
||||
voice: VoiceConfig = Field(default_factory=VoiceConfig)
|
||||
"""语音配置类"""
|
||||
|
||||
|
||||
@@ -265,6 +265,18 @@ def try_migrate_legacy_bot_config_dict(data: dict[str, Any]) -> MigrationResult:
|
||||
migrated_any = True
|
||||
reasons.append("experimental.chat_prompts")
|
||||
|
||||
chat = _as_dict(data.get("chat"))
|
||||
if chat is not None and "think_mode" in chat:
|
||||
chat.pop("think_mode", None)
|
||||
migrated_any = True
|
||||
reasons.append("chat.think_mode_removed")
|
||||
|
||||
tool = _as_dict(data.get("tool"))
|
||||
if tool is not None:
|
||||
data.pop("tool", None)
|
||||
migrated_any = True
|
||||
reasons.append("tool_section_removed")
|
||||
|
||||
# ExpressionConfig 中的 manual_reflect_operator_id:
|
||||
# 旧版本可能是 ""(字符串),新版本期望 Optional[TargetItem]。
|
||||
# 空字符串视为未配置,转换为 None/删除键以避免校验错误。
|
||||
|
||||
@@ -236,20 +236,6 @@ class ChatConfig(ConfigBase):
|
||||
)
|
||||
"""上下文长度"""
|
||||
|
||||
think_mode: Literal["classic", "deep", "dynamic"] = Field(
|
||||
default="dynamic",
|
||||
json_schema_extra={
|
||||
"x-widget": "select",
|
||||
"x-icon": "brain",
|
||||
},
|
||||
)
|
||||
"""
|
||||
思考模式配置
|
||||
- classic: 默认think_level为0(轻量回复,不需要思考和回忆)
|
||||
- deep: 默认think_level为1(深度回复,需要进行回忆和思考)
|
||||
- dynamic: think_level由planner动态给出(根据planner返回的think_level决定)
|
||||
"""
|
||||
|
||||
plan_reply_log_max_per_chat: int = Field(
|
||||
default=1024,
|
||||
json_schema_extra={
|
||||
@@ -651,21 +637,6 @@ class ExpressionConfig(ConfigBase):
|
||||
"""是否在回复前尝试对上下文中的黑话进行解释(关闭可减少一次LLM调用,仅影响回复前的黑话匹配与解释,不影响黑话学习)"""
|
||||
|
||||
|
||||
class ToolConfig(ConfigBase):
|
||||
"""工具配置类"""
|
||||
|
||||
__ui_parent__ = "emoji"
|
||||
|
||||
enable_tool: bool = Field(
|
||||
default=False,
|
||||
json_schema_extra={
|
||||
"x-widget": "switch",
|
||||
"x-icon": "wrench",
|
||||
},
|
||||
)
|
||||
"""是否在聊天中启用工具"""
|
||||
|
||||
|
||||
class VoiceConfig(ConfigBase):
|
||||
"""语音识别配置类"""
|
||||
|
||||
|
||||
@@ -343,11 +343,6 @@ class LLMOrchestrator:
|
||||
)
|
||||
response = execution_result.api_response
|
||||
model_info = execution_result.model_info
|
||||
if self.request_type.startswith("maisaka_"):
|
||||
logger.info(
|
||||
f"LLMOrchestrator[{self.request_type}] generate_response_with_message_async 执行完成 "
|
||||
f"(model={model_info.name}, time_cost={time.time() - start_time:.2f}s)"
|
||||
)
|
||||
|
||||
time_cost = time.time() - start_time
|
||||
logger.debug(f"LLM请求总耗时: {time_cost}")
|
||||
@@ -833,14 +828,7 @@ class LLMOrchestrator:
|
||||
|
||||
message_list = []
|
||||
if message_factory:
|
||||
if self.request_type.startswith("maisaka_"):
|
||||
logger.info(f"LLMOrchestrator[{self.request_type}] 正在通过 message_factory 构建消息列表")
|
||||
message_list = message_factory(client)
|
||||
if self.request_type.startswith("maisaka_"):
|
||||
logger.info(
|
||||
f"LLMOrchestrator[{self.request_type}] message_factory 返回了 {len(message_list)} 条消息"
|
||||
)
|
||||
|
||||
try:
|
||||
request = self._build_client_request(
|
||||
request_type=request_type,
|
||||
|
||||
@@ -121,11 +121,7 @@ def create_builtin_tool_specs() -> List[ToolSpec]:
|
||||
),
|
||||
_build_tool_spec(
|
||||
name="no_reply",
|
||||
brief_description="本轮不发送可见回复,继续下一步思考。",
|
||||
),
|
||||
_build_tool_spec(
|
||||
name="stop",
|
||||
brief_description="暂停当前内部循环,等待新的外部消息。",
|
||||
brief_description="本轮不进行回复,等待其他用户的新消息。",
|
||||
),
|
||||
_build_tool_spec(
|
||||
name="send_emoji",
|
||||
|
||||
@@ -1282,7 +1282,7 @@ class MaisakaReasoningEngine:
|
||||
self._runtime._chat_history.append(history_message)
|
||||
return self._build_tool_success_result(
|
||||
tool_call.func_name,
|
||||
"可见回复已生成并发送。",
|
||||
"回复已生成并发送。",
|
||||
structured_content={
|
||||
"msg_id": target_message_id,
|
||||
"quote": quote_reply,
|
||||
|
||||
@@ -103,7 +103,6 @@ async def generate_reply(
|
||||
available_actions: Optional[Dict[str, ActionInfo]] = None,
|
||||
chosen_actions: Optional[List["ActionPlannerInfo"]] = None,
|
||||
unknown_words: Optional[List[str]] = None,
|
||||
enable_tool: bool = False,
|
||||
enable_splitter: bool = True,
|
||||
enable_chinese_typo: bool = True,
|
||||
request_type: str = "generator_api",
|
||||
@@ -133,7 +132,6 @@ async def generate_reply(
|
||||
extra_info=extra_info,
|
||||
available_actions=available_actions,
|
||||
chosen_actions=chosen_actions,
|
||||
enable_tool=enable_tool,
|
||||
reply_message=reply_message,
|
||||
reply_reason=reply_reason,
|
||||
unknown_words=unknown_words,
|
||||
|
||||
@@ -36,7 +36,6 @@ from src.config.official_configs import (
|
||||
ResponsePostProcessConfig,
|
||||
ResponseSplitterConfig,
|
||||
TelemetryConfig,
|
||||
ToolConfig,
|
||||
VoiceConfig,
|
||||
)
|
||||
from src.webui.config_schema import ConfigSchemaGenerator
|
||||
@@ -113,7 +112,6 @@ async def get_config_section_schema(section_name: str):
|
||||
- experimental: ExperimentalConfig
|
||||
- maim_message: MaimMessageConfig
|
||||
- lpmm_knowledge: LPMMKnowledgeConfig
|
||||
- tool: ToolConfig
|
||||
- memory: MemoryConfig
|
||||
- debug: DebugConfig
|
||||
- voice: VoiceConfig
|
||||
@@ -138,7 +136,6 @@ async def get_config_section_schema(section_name: str):
|
||||
"experimental": ExperimentalConfig,
|
||||
"maim_message": MaimMessageConfig,
|
||||
"lpmm_knowledge": LPMMKnowledgeConfig,
|
||||
"tool": ToolConfig,
|
||||
"memory": MemoryConfig,
|
||||
"debug": DebugConfig,
|
||||
"voice": VoiceConfig,
|
||||
|
||||
Reference in New Issue
Block a user