ref:重构maisaka内置工具逻辑,拆分文件
This commit is contained in:
34
src/maisaka/builtin_tool/no_reply.py
Normal file
34
src/maisaka/builtin_tool/no_reply.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""no_reply 内置工具。"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from src.core.tooling import ToolExecutionContext, ToolExecutionResult, ToolInvocation, ToolSpec
|
||||
|
||||
from .context import BuiltinToolRuntimeContext
|
||||
|
||||
|
||||
def get_tool_spec() -> ToolSpec:
|
||||
"""获取 no_reply 工具声明。"""
|
||||
|
||||
return ToolSpec(
|
||||
name="no_reply",
|
||||
brief_description="本轮不进行回复,等待其他用户的新消息。",
|
||||
provider_name="maisaka_builtin",
|
||||
provider_type="builtin",
|
||||
)
|
||||
|
||||
|
||||
async def handle_tool(
|
||||
tool_ctx: BuiltinToolRuntimeContext,
|
||||
invocation: ToolInvocation,
|
||||
context: Optional[ToolExecutionContext] = None,
|
||||
) -> ToolExecutionResult:
|
||||
"""执行 no_reply 内置工具。"""
|
||||
|
||||
del context
|
||||
tool_ctx.runtime._enter_stop_state()
|
||||
return tool_ctx.build_success_result(
|
||||
invocation.tool_name,
|
||||
"当前对话循环已暂停,等待新消息到来。",
|
||||
metadata={"pause_execution": True},
|
||||
)
|
||||
Reference in New Issue
Block a user