包package
agentscope.consoleagentscope.console
module agentscope.console
agentscope.console 属于基础设施,类型、异常、传输与工具函数。 该包共收录 2 个公开类型。
Two public entries serve two different scenarios:
- :class:
ConsoleRenderer: a passive event renderer that turns an :class:~agentscope.event.AgentEventstream into line-based terminal output. Embed it in your own code (scripts, agent pipelines, tests) where you own the loop, the inputs and the human-in-the-loop handling. - :func:
launch_console: an interactive chat loop bound to a single agent — input, tool-call confirmation and Ctrl+C interruption included — for trying an agent without writing any UI code.
源码Source
agentscope/console/__init__.py:1类Classes
ConsoleRenderer类class | 控制台渲染器,为框架提供通用类型与基础能力。 Render :class:`~agentscope.event.AgentEvent` streams as line-based terminal output. Consume :meth:`Agent.reply_stream` and reset the renderer if the stream fails: |
函数Functions
launch_console函数function | 启动终端对话 Chat with the given agent interactively in the terminal. |
函数详情Function Details
launch_console
async def launch_console(agent: Agent | PipelineProtocol, user_name: str = 'user', verbosity: Verbosity = 'default', max_tool_result_lines: int | None = 20) -> None
async
在终端中与指定智能体进行交互式对话,便于本地调试和快速验证。
A lightweight try-out/debugging entry — no session management, no persistence: the conversation lives in agent.state and ends with the process.
示例Example
agent = Agent(name=..., model=..., toolkit=...)
await launch_console(agent)
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | PipelineProtocol | 智能体(类型 `Agent | PipelineProtocol`)。The agent or pipeline to interact with. |
user_name默认default 'user' | str | 用户名称(类型 `str`)。The name attached to the user's input messages, also used as the input prompt. |
verbosity默认default 'default' | Verbosity | verbosity(类型 `Verbosity`)。`"quiet"`: only the streamed reply text and errors. - `"default"`: plus thinking, tool calls/results, hint blocks, token usage and human-in-the-loop notices. - `"debug"`: plus lifecycle events and other events that are invisible by default. |
max_tool_result_lines默认default 20 | int | None | 最大工具结果 lines(类型 `int | None`)。Truncate the printed tool results to this number of lines. `None` means no truncation. |
None
无返回值。No value is returned.
源码Source
agentscope/console/_console.py:105–175