包package
agentscopeagentscope
module agentscope
agentscope 属于基础设施,类型、异常、传输与工具函数。 该包共收录 5 个公开类型。
The agentscope package.
源码Source
agentscope/__init__.py:1子包Subpackages
agentscope.agentagentscope.appagentscope.asragentscope.classifieragentscope.consoleagentscope.credentialagentscope.embeddingagentscope.eventagentscope.exceptionagentscope.formatteragentscope.mcpagentscope.messageagentscope.middlewareagentscope.modelagentscope.permissionagentscope.pipelineagentscope.ragagentscope.realtimeagentscope.skillagentscope.sopagentscope.stateagentscope.toolagentscope.ttsagentscope.tuiagentscope.typesagentscope.workspace
函数Functions
set_id_factory函数function | 覆盖全局 ID 工厂 Override the global ID factory used by all AgentScope entities. |
set_timestamp_factory函数function | 覆盖全局时间戳工厂 Override the global timestamp factory used by all AgentScope entities. |
setup_logger函数function | 初始化日志记录器 Set up the agentscope logger. |
属性Attributes
__version__字段attribute | — |
logger字段attribute | — |
函数详情Function Details
set_id_factory
def set_id_factory(factory: Callable[[], str]) -> None
替换 AgentScope 所有实体使用的 ID 生成策略;应在创建任何实体前调用,常用于测试或自定义标识。
Entity IDs default to uuid.uuid4().hex.
示例Example
>>> from agentscope import set_id_factory
>>> set_id_factory(lambda: uuid7().hex)说明Notes
- 注意:该行为受运行时配置或底层实现影响,建议结合对应源码与版本说明确认。Note: Security-sensitive tokens (gateway tokens, Redis lock tokens) are **not** affected and always use `uuid.uuid4().hex`.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
factory | Callable[[], str] | 工厂(类型 `Callable[[], str]`)。A no-arg callable returning a string ID. |
None
无返回值。No value is returned.
TypeError可能抛出 `TypeError`。If `factory` is not callable.
源码Source
agentscope/_utils/_common.py:32–58set_timestamp_factory
def set_timestamp_factory(factory: Callable[[], str]) -> None
替换 AgentScope 所有实体使用的时间戳生成策略;应在创建任何实体前调用,便于测试与回放。
Override the global timestamp factory used by all AgentScope entities.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
factory | Callable[[], str] | 工厂(类型 `Callable[[], str]`)。A no-arg callable returning a string ID. |
None
无返回值。No value is returned.
TypeError可能抛出 `TypeError`。If `factory` is not callable.
源码Source
agentscope/_utils/_common.py:61–76setup_logger
def setup_logger(level: str, filepath: str | None = None) -> None
配置 agentscope 日志的级别、格式与输出目标,统一框架与业务侧的日志观测。
Set up the agentscope logger.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
level | str | 级别(类型 `str`)。The logging level, chosen from "INFO", "DEBUG", "WARNING", "ERROR", "CRITICAL". |
filepath默认default None | str | None | filepath(类型 `str | None`)。The filepath to save the logging output. |
None
无返回值。No value is returned.
源码Source
agentscope/_logging.py:15–44属性详情Attribute Details
__version__
= '2.0.11'版本字段。
The version field.
源码Source
agentscope/_version.py:4logger
= logging.getLogger('as')日志记录器字段。
The logger field.
源码Source
agentscope/_logging.py:12