类class
agentscope.app.hubHubBase
class HubBase
源码Source
agentscope/app/hub/_base.py:10–72中心基类,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.hub 包。
A hub is addressed by :attr:hub_id in the HTTP routes, and a card
is addressed globally by the (hub_id, card_id) pair, so the id
must stay stable across restarts.
Hubs are entered once by the app lifespan and live as long as the process, so an implementation talking to a registry over HTTP can hold one client across requests instead of paying for a fresh handshake on every page of a catalog.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(hub_id: str, display_name: str, description: str = '', icon_url: str | None = None) -> None | 初始化 `HubBase` 实例。 Initialize the hub identity. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def __aenter__() -> Selfasync | 进入异步上下文并返回自身。 Enter the hub — open whatever it talks to the registry with. |
async def __aexit__(*exc: Any) -> Noneasync | 退出异步上下文并清理资源。 Exit the hub — close what :meth:`__aenter__` opened. |
构造器详情Constructor Detail
HubBase
def __init__(hub_id: str, display_name: str, description: str = '', icon_url: str | None = None) -> None
初始化 HubBase 实例。
Initialize the hub identity.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
hub_id | str | 中心标识(类型 `str`)。The stable identifier addressing this hub. Must match `[a-zA-Z0-9_-]+` and be unique among the hubs of the same kind registered on one app. |
display_name | str | 展示名称(类型 `str`)。The user-facing hub name. |
description默认default '' | str | 描述(类型 `str`)。The user-facing hub description. |
icon_url默认default None | str | None | icon URL(类型 `str | None`)。An image identifying the hub in the picker. `None` leaves the UI to fall back rather than show a gap. |
- 可能抛出 `Exception`。`ValueError`:
- 可能抛出 `Exception`。When `hub_id` is not usable as a URL path segment.
源码Source
agentscope/app/hub/_base.py:23–57方法详情Method Detail
__aenter__
async def __aenter__() -> Self
async
进入异步上下文并返回自身。
The default is a no-op, so a hub with nothing to open needs no boilerplate.
Self
返回自身。`HubBase`:
源码Source
agentscope/app/hub/_base.py:59–69__aexit__
async def __aexit__(*exc: Any) -> None
async
退出异步上下文并清理资源。
Exit the hub — close what :meth:__aenter__ opened.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
exc | Any | exc(类型 `Any`)。The exc. |
None
无返回值。No value is returned.
源码Source
agentscope/app/hub/_base.py:71–72