agentscope.tuiChatUI
class ChatUI(Widget)
agentscope/tui/_chat.py:340–657聊天 UI,为框架提供通用类型与基础能力。位于 agentscope.tui 包,继承自 Widget。核心成员包括 compose、on_mount、is_reply_parked、set_messages、update_message、watch_input_enabled。
Messages, composer and HITL controls without an Agent dependency. Declared in agentscope.tui. Extends Widget.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Submitted | 类class | Submitted,为框架提供通用类型与基础能力。 A class in agentscope.tui that provides shared types and foundational utilities. |
Confirmed | 类class | Confirmed,为框架提供通用类型与基础能力。 A class in agentscope.tui that provides shared types and foundational utilities. |
ExternalExecutionSubmitted | 类class | 外部执行 Submitted,为框架提供通用类型与基础能力。 A class in agentscope.tui that provides shared types and foundational utilities. |
InterruptRequested | 类class | 中断 Requested,为框架提供通用类型与基础能力。 A class in agentscope.tui that provides shared types and foundational utilities. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(messages: Sequence[Msg] = (), *, user_name: str = 'user', input_enabled: bool = True, show_thinking: bool… | 初始化 `ChatUI` 实例。 Creates a new instance. |
属性摘要Property Summary
| 属性Property | 说明Description |
|---|---|
messages | 获取消息。 Returns the messages. |
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
input_enabled | — | 输入已启用字段。 | reactive(True) |
DEFAULT_CSS | — | 默认 CSS字段。 | '\n ChatUI {\n width: 100%;\n height: 100%;\n layout: vertical;\n padding: 0;\n background: transparent;\n }\n\n ChatUI > MessagesUI {\n height: 1fr;\n padding: 0 1;\n }\n\n ComposerUI, HitlUI {\n width: 100%;\n height: auto;\n min-height: 3;\n padding: 0;\n background: transparent;\n }\n\n .as-section-rule {\n width: 100%;\n height: 1;\n color: #766b5b;\n background: transparent;\n }\n\n #as-composer-input {\n width: 100%;\n height: auto;\n min-height: 1;\n max-height: 10;\n scrollbar-visibility: hidden;\n border: none;\n padding: 0 1;\n background: transparent;\n }\n\n #as-composer-input .text-area--cursor-line {\n background: transparent;\n }\n\n .as-composer-hint, .as-hitl-hint {\n width: 100%;\n height: 1;\n padding: 0 1;\n color: $text-muted;\n }\n\n .as-hitl-options {\n width: 100%;\n height: auto;\n max-height: 10;\n margin-top: 1;\n scrollbar-visibility: hidden;\n border: none;\n padding: 0 1;\n background: transparent;\n }\n\n .as-hitl-options:focus {\n border: none;\n background: transparent;\n background-tint: transparent;\n }\n\n .as-hitl-options > .option-list--option-highlighted,\n .as-hitl-options:focus > .option-list--option-highlighted {\n color: #d8b66f;\n background: transparent;\n text-style: bold;\n }\n\n .as-hitl-options > .option-list--option-hover {\n color: #d8b66f;\n background: transparent;\n }\n\n .as-hitl-title {\n height: 1;\n padding: 0 1;\n text-style: bold;\n color: $foreground;\n }\n\n .as-hitl-body {\n height: auto;\n max-height: 10;\n overflow-y: auto;\n scrollbar-visibility: hidden;\n padding: 0 1;\n background: transparent;\n }\n ' |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
def compose() -> ComposeResult | 返回 `compose` 结果。 Performs the compose operation. |
def on_mount() -> None | 处理 `on_mount` 事件。 Handles the mount event. |
def is_reply_parked(reply_id: str) -> bool | 判断是否 `is_reply_parked`。 Whether a reply is waiting for confirmation or external input. |
async def set_messages(messages: Sequence[Msg]) -> Noneasync | 设置消息。 Sets the messages. |
async def update_message(message: Msg) -> Noneasync | 更新消息。 Update one message and its associated interaction controls. |
def watch_input_enabled(enabled: bool) -> None | 设置该参数。 Performs the watch input enabled operation. |
构造器详情Constructor Detail
ChatUI
def __init__(messages: Sequence[Msg] = (), *, user_name: str = 'user', input_enabled: bool = True, show_thinking: bool = True, show_usage: bool = False, id: str | None = None, classes: str | None = None, disabled: bool = False) -> None
初始化 ChatUI 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messages默认default () | Sequence[Msg] | 消息列表(类型 `Sequence[Msg]`)。The messages. |
user_namekw默认default 'user' | str | 用户名称(类型 `str`)。The user name. |
input_enabledkw默认default True | bool | 输入已启用(类型 `bool`)。The input enabled. |
show_thinkingkw默认default True | bool | show thinking(类型 `bool`)。The show thinking. |
show_usagekw默认default False | bool | show 用量(类型 `bool`)。The show usage. |
idkw默认default None | str | None | 标识(类型 `str | None`)。The id. |
classeskw默认default None | str | None | classes(类型 `str | None`)。The classes. |
disabledkw默认default False | bool | 已禁用(类型 `bool`)。The disabled. |
agentscope/tui/_chat.py:462–485属性详情Attribute Detail
input_enabled
= reactive(True)输入已启用字段。
The input enabled field.
agentscope/tui/_chat.py:343DEFAULT_CSS
= '\n ChatUI {\n width: 100%;\n height: 100%;\n layout: vertical;\n padding: 0;\n background: transparent;\n }\n\n ChatUI > MessagesUI {\n height: 1fr;\n padding: 0 1;\n }\n\n ComposerUI, HitlUI {\n width: 100%;\n height: auto;\n min-height: 3;\n padding: 0;\n background: transparent;\n }\n\n .as-section-rule {\n width: 100%;\n height: 1;\n color: #766b5b;\n background: transparent;\n }\n\n #as-composer-input {\n width: 100%;\n height: auto;\n min-height: 1;\n max-height: 10;\n scrollbar-visibility: hidden;\n border: none;\n padding: 0 1;\n background: transparent;\n }\n\n #as-composer-input .text-area--cursor-line {\n background: transparent;\n }\n\n .as-composer-hint, .as-hitl-hint {\n width: 100%;\n height: 1;\n padding: 0 1;\n color: $text-muted;\n }\n\n .as-hitl-options {\n width: 100%;\n height: auto;\n max-height: 10;\n margin-top: 1;\n scrollbar-visibility: hidden;\n border: none;\n padding: 0 1;\n background: transparent;\n }\n\n .as-hitl-options:focus {\n border: none;\n background: transparent;\n background-tint: transparent;\n }\n\n .as-hitl-options > .option-list--option-highlighted,\n .as-hitl-options:focus > .option-list--option-highlighted {\n color: #d8b66f;\n background: transparent;\n text-style: bold;\n }\n\n .as-hitl-options > .option-list--option-hover {\n color: #d8b66f;\n background: transparent;\n }\n\n .as-hitl-title {\n height: 1;\n padding: 0 1;\n text-style: bold;\n color: $foreground;\n }\n\n .as-hitl-body {\n height: auto;\n max-height: 10;\n overflow-y: auto;\n scrollbar-visibility: hidden;\n padding: 0 1;\n background: transparent;\n }\n '默认 CSS字段。
The DEFAULT CSS field.
agentscope/tui/_chat.py:345属性详情Property Detail
messages
def messages() -> tuple[Msg, ...]
获取消息。
Returns the messages.
agentscope/tui/_chat.py:506–507方法详情Method Detail
compose
def compose() -> ComposeResult
返回 compose 结果。
Performs the compose operation.
agentscope/tui/_chat.py:487–500on_mount
def on_mount() -> None
处理 on_mount 事件。
Handles the mount event.
agentscope/tui/_chat.py:502–503is_reply_parked
def is_reply_parked(reply_id: str) -> bool
判断是否 is_reply_parked。
Whether a reply is waiting for confirmation or external input.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
reply_id | str | 回复标识(类型 `str`)。The reply id. |
agentscope/tui/_chat.py:512–523set_messages
async def set_messages(messages: Sequence[Msg]) -> None
设置消息。
Sets the messages.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messages | Sequence[Msg] | 消息列表(类型 `Sequence[Msg]`)。The messages. |
agentscope/tui/_chat.py:525–532update_message
async def update_message(message: Msg) -> None
更新消息。
Update one message and its associated interaction controls.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | Msg | 消息(类型 `Msg`)。The message. |
agentscope/tui/_chat.py:534–541watch_input_enabled
def watch_input_enabled(enabled: bool) -> None
设置该参数。
Performs the watch input enabled operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
enabled | bool | 已启用(类型 `bool`)。The enabled. |
agentscope/tui/_chat.py:543–545嵌套类详情Nested Class Detail
Submitted
class SubmittedSubmitted,为框架提供通用类型与基础能力。位于 agentscope.tui 包,继承自 Message。
A class in agentscope.tui that provides shared types and foundational utilities. Declared in agentscope.tui. Extends Message.
Confirmed
class ConfirmedConfirmed,为框架提供通用类型与基础能力。位于 agentscope.tui 包,继承自 Message。
A class in agentscope.tui that provides shared types and foundational utilities. Declared in agentscope.tui. Extends Message.
ExternalExecutionSubmitted
class ExternalExecutionSubmitted外部执行 Submitted,为框架提供通用类型与基础能力。位于 agentscope.tui 包,继承自 Message。
A class in agentscope.tui that provides shared types and foundational utilities. Declared in agentscope.tui. Extends Message.
InterruptRequested
class InterruptRequested中断 Requested,为框架提供通用类型与基础能力。位于 agentscope.tui 包,继承自 Message。
A class in agentscope.tui that provides shared types and foundational utilities. Declared in agentscope.tui. Extends Message.