Skip to content

Commit 503a257

Browse files
committed
remove:无用配置
1 parent a731091 commit 503a257

14 files changed

Lines changed: 25 additions & 95 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
3. 对于参数化泛型,应该使用`typing`模块中的类型注解来指定参数化泛型的类型。
2525
- 例如,使用`List[int]`来表示一个包含整数的列表,使用`Dict[str, Any]`来表示一个键为字符串,值为任意类型的字典。
2626
## 变量规范
27-
1. 变量命名应该具有描述性,能够清晰地表达变量的用途和含义。
28-
2. 变量命名应该遵循下划线命名法。
29-
3. 当确定某个变量/实例是某种类型的时候(优先按照类型注解确定,除非你分析出类型注解是错误的),可以不必使用`or`进行fallback。
27+
1. 当确定某个变量/实例是某种类型的时候(优先按照类型注解确定,除非你分析出类型注解是错误的),可以不必使用`or`进行fallback。
3028
- 例如,`bot_nickname = (global_config.bot.nickname or "").strip()` 可以改为 `bot_nickname = global_config.bot.nickname.strip()`,前提是我们确定`global_config.bot.nickname`一定是一个字符串。
3129
## 类属性使用规范
3230
1. 应该尽量减少使用getattr和setattr方法,除非是在对一个动态类进行处理或者使用Monkeypatch完成Pytest
@@ -36,6 +34,7 @@
3634
# 运行/调试/构建/测试/依赖
3735
优先使用uv
3836
依赖项以 pyproject.toml 为准
37+
不要修改dashboard下的内容,因为这部分内容由另一个仓库build
3938

4039
# 语言规范
4140

docs-src/plugins/api/generator-api.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ async def generate_reply(
5454
reply_to: str = "",
5555
extra_info: str = "",
5656
available_actions: Optional[Dict[str, ActionInfo]] = None,
57-
enable_tool: bool = False,
5857
enable_splitter: bool = True,
5958
enable_chinese_typo: bool = True,
6059
return_prompt: bool = False,
@@ -73,7 +72,6 @@ async def generate_reply(
7372
- `reply_to`: 回复目标,格式为 `{发送者的person_name:消息内容}`
7473
- `extra_info`: 附加信息
7574
- `available_actions`: 可用动作字典,格式为 `{"action_name": ActionInfo}`
76-
- `enable_tool`: 是否启用工具
7775
- `enable_splitter`: 是否启用分割器
7876
- `enable_chinese_typo`: 是否启用中文错别字
7977
- `return_prompt`: 是否返回提示词
@@ -91,7 +89,6 @@ success, reply_set, prompt = await generator_api.generate_reply(
9189
action_data=action_data,
9290
reply_to="麦麦:你好",
9391
available_actions=action_info,
94-
enable_tool=True,
9592
return_prompt=True
9693
)
9794
if success:
@@ -198,4 +195,4 @@ async def generate_response_custom(
198195
2. **聊天流依赖**:需要有效的聊天流对象才能正常工作
199196
3. **性能考虑**:回复生成可能需要一些时间,特别是使用LLM时
200197
4. **回复格式**:返回的回复集合是元组列表,包含类型和内容
201-
5. **上下文感知**:生成器会考虑聊天上下文和历史消息,除非你用的是自定义提示词。
198+
5. **上下文感知**:生成器会考虑聊天上下文和历史消息,除非你用的是自定义提示词。

prompts/zh-CN/maisaka_chat.prompt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414
你可以使用这些工具:
1515
- wait(seconds) - 暂时停止对话,等待(seconds)秒,把话语权交给用户,等待对方新的发言。
16-
- stop() - 当你判断{bot_name}现在不应该发言,结束对话,不进行任何回复,直到对方有新消息。
16+
- no_reply() - 当你判断{bot_name}现在不应该发言,结束对话,不进行任何回复,直到对方有新消息。
1717
- reply():当你判断{bot_name}现在应该正式对用户发出一条可见回复时调用。调用后系统会基于你当前这轮的想法生成一条真正展示给用户的回复。
1818
- query_jargon():当你认为某些词的含义不明确,或用户询问某些词的含义,需要进行查询
1919
- 其他定义的工具,你可以视情况合适使用
2020

2121
工具使用规则:
22-
1.如果{bot_name}已经回复,但用户暂时没有新的回复,且没有新信息需要搜集,使用wait或者stop进行等待
22+
1.如果{bot_name}已经回复,但用户暂时没有新的回复,且没有新信息需要搜集,使用wait或者no_reply进行等待
2323
2.如果用户有新发言,但是你评估用户还有后续发言尚未发送,可以适当等待让用户说完
24-
3.在特定情况下也可以连续回复,例如想要追问,或者补充自己先前的发言,可以不使用stop或者wait
25-
4.你需要控制自己发言的频率,如果用户一对一聊天,可以以均匀地频率发言,如果用户较多,不要每句都回复,控制回复频率。当你决定暂时不发言,可以使用wait暂时等待一定时间或者stop等待新消息
24+
3.在特定情况下也可以连续回复,例如想要追问,或者补充自己先前的发言,可以不使用no_reply或者wait
25+
4.你需要控制自己发言的频率,如果用户一对一聊天,可以以均匀地频率发言,如果用户较多,不要每句都回复,控制回复频率。当你决定暂时不发言,可以使用wait暂时等待一定时间或者no_reply等待新消息
2626
5.不要每条消息都回复,不要直接回复别的用户发送的表情包消息,控制回复频率
2727
6.如果存在用户的疑问,或者对某些概念的不确定,你可以使用工具来搜集信息或者查询含义,你可以使用多个工具
2828

src/chat/replyer/group_generator.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ async def generate_reply_with_context(
6868
reply_reason: str = "",
6969
available_actions: Optional[Dict[str, ActionInfo]] = None,
7070
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
71-
enable_tool: bool = True,
7271
from_plugin: bool = True,
7372
stream_id: Optional[str] = None,
7473
reply_message: Optional[SessionMessage] = None,
@@ -87,7 +86,6 @@ async def generate_reply_with_context(
8786
reply_reason: 回复原因
8887
available_actions: 可用的动作信息字典
8988
chosen_actions: 已选动作
90-
enable_tool: 是否启用工具调用
9189
from_plugin: 是否来自插件
9290
9391
Returns:
@@ -112,7 +110,6 @@ async def generate_reply_with_context(
112110
extra_info=extra_info,
113111
available_actions=available_actions,
114112
chosen_actions=chosen_actions,
115-
enable_tool=enable_tool,
116113
reply_message=reply_message,
117114
reply_reason=reply_reason,
118115
reply_time_point=reply_time_point,
@@ -394,26 +391,20 @@ async def build_expression_habits(
394391

395392
return f"{expression_habits_title}\n{expression_habits_block}", selected_ids
396393

397-
async def build_tool_info(self, chat_history: str, sender: str, target: str, enable_tool: bool = True) -> str:
394+
async def build_tool_info(self, chat_history: str, sender: str, target: str) -> str:
398395
del chat_history
399396
del sender
400397
del target
401-
del enable_tool
402398
return ""
403399
"""构建工具信息块
404400
405401
Args:
406402
chat_history: 聊天历史记录
407403
reply_to: 回复对象,格式为 "发送者:消息内容"
408-
enable_tool: 是否启用工具调用
409-
410404
Returns:
411405
str: 工具信息字符串
412406
"""
413407

414-
if not enable_tool:
415-
return ""
416-
417408
try:
418409
# 使用工具执行器获取信息
419410
tool_results = []
@@ -741,7 +732,6 @@ async def build_prompt_reply_context(
741732
reply_reason: str = "",
742733
available_actions: Optional[Dict[str, ActionInfo]] = None,
743734
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
744-
enable_tool: bool = True,
745735
reply_time_point: float = time.time(),
746736
think_level: int = 1,
747737
unknown_words: Optional[List[str]] = None,
@@ -755,7 +745,6 @@ async def build_prompt_reply_context(
755745
available_actions: 可用动作
756746
chosen_actions: 已选动作
757747
enable_timeout: 是否启用超时处理
758-
enable_tool: 是否启用工具调用
759748
reply_message: 回复的原始消息
760749
Returns:
761750
str: 构建好的上下文
@@ -840,7 +829,7 @@ async def build_prompt_reply_context(
840829
"expression_habits",
841830
),
842831
self._time_and_run_task(
843-
self.build_tool_info(chat_talking_prompt_short, sender, target, enable_tool=enable_tool), "tool_info"
832+
self.build_tool_info(chat_talking_prompt_short, sender, target), "tool_info"
844833
),
845834
self._time_and_run_task(self.get_prompt_info(chat_talking_prompt_short, sender, target), "prompt_info"),
846835
self._time_and_run_task(self.build_actions_prompt(available_actions, chosen_actions), "actions_info"),

src/chat/replyer/maisaka_generator.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ async def generate_reply_with_context(
288288
reply_reason: str = "",
289289
available_actions: Optional[Dict[str, ActionInfo]] = None,
290290
chosen_actions: Optional[List[object]] = None,
291-
enable_tool: bool = True,
292291
from_plugin: bool = True,
293292
stream_id: Optional[str] = None,
294293
reply_message: Optional[SessionMessage] = None,
@@ -303,7 +302,6 @@ async def generate_reply_with_context(
303302
"""结合上下文生成 Maisaka 的最终可见回复。"""
304303
del available_actions
305304
del chosen_actions
306-
del enable_tool
307305
del extra_info
308306
del from_plugin
309307
del log_reply

src/chat/replyer/private_generator.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ async def generate_reply_with_context(
6565
reply_reason: str = "",
6666
available_actions: Optional[Dict[str, ActionInfo]] = None,
6767
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
68-
enable_tool: bool = True,
6968
from_plugin: bool = True,
7069
think_level: int = 1,
7170
stream_id: Optional[str] = None,
@@ -84,7 +83,6 @@ async def generate_reply_with_context(
8483
reply_reason: 回复原因
8584
available_actions: 可用的动作信息字典
8685
chosen_actions: 已选动作
87-
enable_tool: 是否启用工具调用
8886
from_plugin: 是否来自插件
8987
9088
Returns:
@@ -103,7 +101,6 @@ async def generate_reply_with_context(
103101
extra_info=extra_info,
104102
available_actions=available_actions,
105103
chosen_actions=chosen_actions,
106-
enable_tool=enable_tool,
107104
reply_message=reply_message,
108105
reply_reason=reply_reason,
109106
unknown_words=unknown_words,
@@ -287,26 +284,20 @@ async def build_expression_habits(
287284

288285
return f"{expression_habits_title}\n{expression_habits_block}", selected_ids
289286

290-
async def build_tool_info(self, chat_history: str, sender: str, target: str, enable_tool: bool = True) -> str:
287+
async def build_tool_info(self, chat_history: str, sender: str, target: str) -> str:
291288
del chat_history
292289
del sender
293290
del target
294-
del enable_tool
295291
return ""
296292
"""构建工具信息块
297293
298294
Args:
299295
chat_history: 聊天历史记录
300296
reply_to: 回复对象,格式为 "发送者:消息内容"
301-
enable_tool: 是否启用工具调用
302-
303297
Returns:
304298
str: 工具信息字符串
305299
"""
306300

307-
if not enable_tool:
308-
return ""
309-
310301
try:
311302
# 使用工具执行器获取信息
312303
tool_results = []
@@ -612,7 +603,6 @@ async def build_prompt_reply_context(
612603
reply_reason: str = "",
613604
available_actions: Optional[Dict[str, ActionInfo]] = None,
614605
chosen_actions: Optional[List[ActionPlannerInfo]] = None,
615-
enable_tool: bool = True,
616606
unknown_words: Optional[List[str]] = None,
617607
) -> Tuple[str, List[int]]:
618608
"""
@@ -624,7 +614,6 @@ async def build_prompt_reply_context(
624614
available_actions: 可用动作
625615
chosen_actions: 已选动作
626616
enable_timeout: 是否启用超时处理
627-
enable_tool: 是否启用工具调用
628617
reply_message: 回复的原始消息
629618
Returns:
630619
str: 构建好的上下文
@@ -719,7 +708,7 @@ async def build_prompt_reply_context(
719708
),
720709
# self._time_and_run_task(self.build_relation_info(chat_talking_prompt_short, sender), "relation_info"),
721710
self._time_and_run_task(
722-
self.build_tool_info(chat_talking_prompt_short, sender, target, enable_tool=enable_tool), "tool_info"
711+
self.build_tool_info(chat_talking_prompt_short, sender, target), "tool_info"
723712
),
724713
self._time_and_run_task(self.get_prompt_info(chat_talking_prompt_short, sender, target), "prompt_info"),
725714
self._time_and_run_task(self.build_actions_prompt(available_actions, chosen_actions), "actions_info"),

src/config/config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
ResponsePostProcessConfig,
3737
ResponseSplitterConfig,
3838
TelemetryConfig,
39-
ToolConfig,
4039
VoiceConfig,
4140
WebUIConfig,
4241
)
@@ -90,9 +89,6 @@ class Config(ConfigBase):
9089
message_receive: MessageReceiveConfig = Field(default_factory=MessageReceiveConfig)
9190
"""消息接收配置类"""
9291

93-
tool: ToolConfig = Field(default_factory=ToolConfig)
94-
"""工具配置类"""
95-
9692
voice: VoiceConfig = Field(default_factory=VoiceConfig)
9793
"""语音配置类"""
9894

src/config/legacy_migration.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ def try_migrate_legacy_bot_config_dict(data: dict[str, Any]) -> MigrationResult:
265265
migrated_any = True
266266
reasons.append("experimental.chat_prompts")
267267

268+
chat = _as_dict(data.get("chat"))
269+
if chat is not None and "think_mode" in chat:
270+
chat.pop("think_mode", None)
271+
migrated_any = True
272+
reasons.append("chat.think_mode_removed")
273+
274+
tool = _as_dict(data.get("tool"))
275+
if tool is not None:
276+
data.pop("tool", None)
277+
migrated_any = True
278+
reasons.append("tool_section_removed")
279+
268280
# ExpressionConfig 中的 manual_reflect_operator_id:
269281
# 旧版本可能是 ""(字符串),新版本期望 Optional[TargetItem]。
270282
# 空字符串视为未配置,转换为 None/删除键以避免校验错误。

src/config/official_configs.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -236,20 +236,6 @@ class ChatConfig(ConfigBase):
236236
)
237237
"""上下文长度"""
238238

239-
think_mode: Literal["classic", "deep", "dynamic"] = Field(
240-
default="dynamic",
241-
json_schema_extra={
242-
"x-widget": "select",
243-
"x-icon": "brain",
244-
},
245-
)
246-
"""
247-
思考模式配置
248-
- classic: 默认think_level为0(轻量回复,不需要思考和回忆)
249-
- deep: 默认think_level为1(深度回复,需要进行回忆和思考)
250-
- dynamic: think_level由planner动态给出(根据planner返回的think_level决定)
251-
"""
252-
253239
plan_reply_log_max_per_chat: int = Field(
254240
default=1024,
255241
json_schema_extra={
@@ -651,21 +637,6 @@ class ExpressionConfig(ConfigBase):
651637
"""是否在回复前尝试对上下文中的黑话进行解释(关闭可减少一次LLM调用,仅影响回复前的黑话匹配与解释,不影响黑话学习)"""
652638

653639

654-
class ToolConfig(ConfigBase):
655-
"""工具配置类"""
656-
657-
__ui_parent__ = "emoji"
658-
659-
enable_tool: bool = Field(
660-
default=False,
661-
json_schema_extra={
662-
"x-widget": "switch",
663-
"x-icon": "wrench",
664-
},
665-
)
666-
"""是否在聊天中启用工具"""
667-
668-
669640
class VoiceConfig(ConfigBase):
670641
"""语音识别配置类"""
671642

src/llm_models/utils_model.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,6 @@ async def generate_response_with_message_async(
343343
)
344344
response = execution_result.api_response
345345
model_info = execution_result.model_info
346-
if self.request_type.startswith("maisaka_"):
347-
logger.info(
348-
f"LLMOrchestrator[{self.request_type}] generate_response_with_message_async 执行完成 "
349-
f"(model={model_info.name}, time_cost={time.time() - start_time:.2f}s)"
350-
)
351346

352347
time_cost = time.time() - start_time
353348
logger.debug(f"LLM请求总耗时: {time_cost}")
@@ -833,14 +828,7 @@ async def _execute_request(
833828

834829
message_list = []
835830
if message_factory:
836-
if self.request_type.startswith("maisaka_"):
837-
logger.info(f"LLMOrchestrator[{self.request_type}] 正在通过 message_factory 构建消息列表")
838831
message_list = message_factory(client)
839-
if self.request_type.startswith("maisaka_"):
840-
logger.info(
841-
f"LLMOrchestrator[{self.request_type}] message_factory 返回了 {len(message_list)} 条消息"
842-
)
843-
844832
try:
845833
request = self._build_client_request(
846834
request_type=request_type,

0 commit comments

Comments
 (0)