Skip to content

Commit 5b92942

Browse files
committed
feat:修改图片展示模式,合并no_reply和stop
1 parent d713aa9 commit 5b92942

8 files changed

Lines changed: 428 additions & 72 deletions

File tree

prompts/zh-CN/maisaka_chat.prompt

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

src/cli/maisaka_cli.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from src.maisaka.tool_handlers import (
3434
ToolHandlerContext,
3535
handle_mcp_tool,
36-
handle_stop,
3736
handle_unknown_tool,
3837
handle_wait,
3938
)
@@ -230,9 +229,8 @@ async def _run_llm_loop(self, chat_history: list[LLMContextMessage]) -> None:
230229
231230
Each round may produce internal thoughts and optionally call tools:
232231
- reply(msg_id): generate a visible reply for the current round
233-
- no_reply(): skip visible output and continue the loop
232+
- no_reply(): pause the inner loop until a new user message arrives
234233
- wait(seconds): wait for new user input
235-
- stop(): stop the current inner loop and return to idle
236234
"""
237235
if self._chat_loop_service is None:
238236
return
@@ -329,11 +327,7 @@ async def _run_llm_loop(self, chat_history: list[LLMContextMessage]) -> None:
329327
tool_context = self._build_tool_context()
330328

331329
for tool_call in response.tool_calls:
332-
if tool_call.func_name == "stop":
333-
await handle_stop(tool_call, chat_history)
334-
should_stop = True
335-
336-
elif tool_call.func_name == "reply":
330+
if tool_call.func_name == "reply":
337331
reply = await self._generate_visible_reply(chat_history, response.content or "")
338332
chat_history.append(
339333
ToolResultMessage(
@@ -354,15 +348,16 @@ async def _run_llm_loop(self, chat_history: list[LLMContextMessage]) -> None:
354348

355349
elif tool_call.func_name == "no_reply":
356350
if global_config.maisaka.show_thinking:
357-
console.print("[muted]本轮未发送可见回复。[/muted]")
351+
console.print("[muted]对话已暂停,等待新的输入...[/muted]")
358352
chat_history.append(
359353
ToolResultMessage(
360-
content="本轮未发送可见回复。",
354+
content="当前对话循环已暂停,等待新消息到来。",
361355
timestamp=datetime.now(),
362356
tool_call_id=tool_call.call_id,
363357
tool_name=tool_call.func_name,
364358
)
365359
)
360+
should_stop = True
366361

367362
elif tool_call.func_name == "wait":
368363
tool_result = await handle_wait(tool_call, chat_history, tool_context)

src/config/official_configs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,15 @@ class MaiSakaConfig(ConfigBase):
15591559
)
15601560
"""是否渲染低分辨率终端预览图片"""
15611561

1562+
terminal_image_display_mode: Literal["legacy", "path_link"] = Field(
1563+
default="legacy",
1564+
json_schema_extra={
1565+
"x-widget": "select",
1566+
"x-icon": "image",
1567+
},
1568+
)
1569+
"""图片展示模式:legacy(仅显示元信息)/ path_link(可点击本地路径)"""
1570+
15621571
terminal_image_preview_width: int = Field(
15631572
default=24,
15641573
ge=8,

src/maisaka/builtin_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def create_builtin_tool_specs() -> List[ToolSpec]:
7373
},
7474
"quote": {
7575
"type": "boolean",
76-
"description": "是否以引用回复的方式发送。",
76+
"description": "当有非常明确的回复目标时,以引用回复的方式发送。",
7777
"default": True,
7878
},
7979
"unknown_words": {

0 commit comments

Comments
 (0)