agentscope.session¶
The session module in agentscope.
- class SessionBase[源代码]¶
基类:
object
The base class for session in agentscope.
- abstract async save_session_state(session_id, **state_modules_mapping)[源代码]¶
Save the session state
- 参数:
session_id (str) -- The session id.
**state_modules_mapping (dict[str, StateModule]) -- A dictionary mapping of state module names to their instances.
- 返回类型:
None
- abstract async load_session_state(session_id, allow_not_exist=True, **state_modules_mapping)[源代码]¶
Load the session state
- 参数:
session_id (str)
allow_not_exist (bool)
state_modules_mapping (StateModule)
- 返回类型:
None
- class JSONSession[源代码]¶
基类:
SessionBase
The JSON session class.
- __init__(session_id=None, save_dir='./')[源代码]¶
Initialize the JSON session class.
- 参数:
session_id (str) -- The session id, deprecated and move to the save_session_state and load_session_state methods to support different session ids.
save_dir (str, defaults to `"./") -- The directory to save the session state.
- 返回类型:
None
- async save_session_state(session_id, **state_modules_mapping)[源代码]¶
Load the state dictionary from a JSON file.
- 参数:
session_id (str) -- The session id.
**state_modules_mapping (dict[str, StateModule]) -- A dictionary mapping of state module names to their instances.
- 返回类型:
None
- async load_session_state(session_id, allow_not_exist=True, **state_modules_mapping)[源代码]¶
Get the state dictionary to be saved to a JSON file.
- 参数:
session_id (str) -- The session id.
allow_not_exist (bool, defaults to True) -- Whether to allow the session to not exist. If False, raises an error if the session does not exist.
state_modules_mapping (list[StateModule]) -- The list of state modules to be loaded.
- 返回类型:
None