agentscope.manager package
Module contents
Import all manager related classes and functions.
- class agentscope.manager.FileManager(*args: Any, **kwargs: Any)[源代码]
基类:
object
A singleton class for managing the file system for saving files, code and logs.
- initialize(run_dir: str | None, save_log: bool, save_code: bool, save_api_invoke: bool, cache_dir: str) None [源代码]
Set the directory for saving files.
- 参数:
run_dir (Union[str, None]) – The running directory, used to save files, logs and code.
save_log (bool) – Whether to save logs locally.
save_code (bool) – Whether to save code locally.
save_api_invoke (bool) – Whether to save API invocations locally.
cache_dir (str) – The directory to save cache files.
- property embedding_cache_dir: str
Obtain the embedding cache directory.
- property file_dir: str
The directory for saving files, including images, audios and videos.
- property code_dir: str
The directory for saving codes.
- property invoke_dir: str
The directory for saving api invocations.
- classmethod get_instance() FileManager [源代码]
Get the singleton instance.
- save_image(image: str | ndarray | bytes | Image, filename: str | None = None) str [源代码]
Save image file locally, and return the local image path.
- 参数:
image (Union[str, np.ndarray]) – The image url, or the image array.
filename (Optional[str]) – The filename of the image. If not specified, a random filename will be used.
- save_file(generator: Generator[bytes, None, None], filename: str) str [源代码]
Save file locally from a binary generator, and return the local file path.
Note we don’t block this function when self.disable_saving==True, because in distribution mode or calling image generation model with save_local == True, we still have to save files locally. However, we save them in “./” instead.
- 参数:
generator (Generator[bytes, None, None]) – The generator of the binary file content.
filename (str) – The filename of the file.
- 返回:
The local file path.
- 返回类型:
str
- cache_text_embedding(text: str, embedding: List[float], embedding_model: str | dict) None [源代码]
Cache the text embedding locally.
- class agentscope.manager.ModelManager(*args: Any, **kwargs: Any)[源代码]
基类:
object
The model manager for AgentScope, which is responsible for loading and managing model configurations and models.
- classmethod get_instance() ModelManager [源代码]
Get the instance of the singleton class.
- model_configs: dict[str, dict] = {}
The model configs
- initialize(model_configs: dict | str | list | None = None) None [源代码]
Initialize the model manager with model configs.
- load_model_configs(model_configs: dict | str | list, clear_existing: bool = False) None [源代码]
read model configs from a path or a list of dicts.
- 参数:
model_configs (Union[str, list, dict]) – The path of the model configs | a config dict | a list of model configs.
clear_existing (bool, defaults to False) – Whether to clear the loaded model configs before reading.
- 返回:
The model configs.
- 返回类型:
dict
- get_model_by_config_name(config_name: str) ModelWrapperBase [源代码]
Load the model by config name, and return the model wrapper.
- class agentscope.manager.MonitorManager(*args: Any, **kwargs: Any)[源代码]
基类:
object
The manager of monitor module.
- property path_db: str | None
The path to the database
- initialize(use_monitor: bool) None [源代码]
Initialize the monitor manager.
- 参数:
use_monitor (bool) – Whether to use the monitor.
- classmethod get_instance() MonitorManager [源代码]
Get the instance of the singleton class.
- update_image_tokens(model_name: str, resolution: str, image_count: int) None [源代码]
Update the record of the image models.
- class agentscope.manager.ASManager(*args: Any, **kwargs: Any)[源代码]
基类:
object
A manager for AgentScope.
- __init__() None [源代码]
Initialize the manager. Note we initialize the managers by default arguments to avoid unnecessary errors when user doesn’t call agentscope.init function
- initialize(model_configs: dict | str | list | None, project: str | None, name: str | None, disable_saving: bool, save_dir: str, save_log: bool, save_code: bool, save_api_invoke: bool, cache_dir: str, use_monitor: bool, logger_level: Literal['TRACE', 'DEBUG', 'INFO', 'SUCCESS', 'WARNING', 'ERROR', 'CRITICAL'], run_id: str | None, studio_url: str | None) None [源代码]
Initialize the package.