agentscope.session

agentscope 中的会话模块。

class SessionBase[source]

基础:object

agentscope中会话的基础类。

__init__(session_id)[source]

初始化会话基类

Parameters:

session_id (str)

Return type:

session_id: str

会话 ID

abstract async save_session_state(**state_modules_mapping)[source]

保存会话状态

Parameters:

state_modules_mapping (StateModule)

Return type:

abstract async load_session_state(*args, **kwargs)[source]

加载会话状态

Parameters:
  • 参数 (任意类型)

  • kwargs (任何)

Return type:

class JSONSession[source]

基类: SessionBase

JSON 会话类。

__init__(session_id, save_dir)[source]

初始化JSON会话类。

Parameters:
  • session_id (str) – 会话标识符。

  • save_dir (str) – 用于保存会话状态的目录。

Return type:

property save_path: str

保存会话状态的路径。

async save_session_state(**state_modules_mapping)[source]

从JSON文件加载状态字典。

Parameters:

**state_modules_mapping (dict[str, StateModule]) – 状态模块名称到其实例的字典映射。

Return type:

async load_session_state(**state_modules_mapping)[source]

获取需保存至JSON文件的状态字典。

Parameters:

state_modules_mapping (list[StateModule]) – 要加载的状态模块列表。

Return type: