AS AgentScopeAPI 手册 / API Reference
包package agentscope.console

agentscope.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.AgentEvent stream 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
agentAgent | 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'Verbosityverbosity(类型 `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 20int | None最大工具结果 lines(类型 `int | None`)。Truncate the printed tool results to this number of lines. `None` means no truncation.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/console/_console.py:105–175
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.