autogen_agentchat.ui#

该模块实现了用于格式化/打印代理消息的实用类。

async Console(stream: AsyncGenerator[Annotated[ToolCallRequestEvent | ToolCallExecutionEvent | MemoryQueryEvent | UserInputRequestedEvent | ModelClientStreamingChunkEvent | ThoughtEvent, FieldInfo(annotation=NoneType, required=True, discriminator='type')] | Annotated[TextMessage | MultiModalMessage | StopMessage | 工具调用摘要信息 | HandoffMessage, FieldInfo(annotation=NoneType, required=True, discriminator='type')] | T, ], *, no_inline_images: bool = False, output_stats: bool = False, user_input_manager: UserInputManager | = None) T[源代码]#

run_stream()on_messages_stream()中消费消息流,并将消息渲染到控制台。返回最后处理的TaskResult或Response。

注意

output_stats 是实验性的,统计结果可能不准确。 它将在未来的版本中得到改进。

Parameters:
  • stream (AsyncGenerator[AgentEvent | ChatMessage | TaskResult, None] | AsyncGenerator[AgentEvent | ChatMessage | Response, None]) – 用于渲染的消息流。 这可以来自 run_stream()on_messages_stream()

  • no_inline_images (bool, optional) – 如果终端是iTerm2,将会内联渲染图像。使用此选项可以禁用此行为。默认为False。

  • output_stats (bool, optional) – (实验性)如果为True,将输出消息的摘要和行内令牌使用情况信息。默认为False。

Returns:

last_processed – 如果流来自run_stream(),则为TaskResult, 如果流来自on_messages_stream(),则为Response

class UserInputManager(callback: Callable[[str], str] | Callable[[str, CancellationToken | ], Awaitable[str]])[源代码]#

基础: object

get_wrapped_callback() Callable[[str, CancellationToken | ], Awaitable[str]][源代码]#
notify_event_received(request_id: str) [源代码]#