💾 存储模块¶
evoagentx.storages ¶
StorageHandler ¶
Bases: BaseModule
Implementation of a storage handler for managing various storage backends.
StorageHandler provides an abstraction for reading and writing data (e.g., memory, agents, workflows). It supports multiple storage types, including database, vector, and graph storage, initialized via factories.
Source code in evoagentx/core/module.py
init_module ¶
Initialize all storage backends based on the provided configuration. Calls individual initialization methods for database, vector, and graph stores.
Source code in evoagentx/storages/base.py
load ¶
Load all data from the database storage.
Attributes:
Name | Type | Description |
---|---|---|
tables |
Optional[List[str]]
|
List of table names to load; if None, loads all tables. |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Dict[str, str]]: A dictionary with table names as keys and lists of records as values. You should parse the values by yourself. |
Source code in evoagentx/storages/base.py
save ¶
Save all provided data to the database storage.
Attributes:
Name | Type | Description |
---|---|---|
data |
Dict[str, Any]
|
Dictionary with table names as keys and lists of records to save. |
Raises:
Type | Description |
---|---|
ValueError
|
If an unknown table name is provided. |
Source code in evoagentx/storages/base.py
parse_result ¶
parse_result(results: Dict[str, str], store: Union[AgentStore, WorkflowStore, MemoryStore, HistoryStore]) -> Dict[str, Any]
Parse database results, converting JSON strings to Python objects where applicable.
Attributes:
Name | Type | Description |
---|---|---|
results |
Dict[str, str]
|
Raw database results with column names as keys. |
store |
Union[AgentStore, WorkflowStore, MemoryStore, HistoryStore]
|
Pydantic model for validation. |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: Parsed results with JSON strings deserialized to Python objects. |
Source code in evoagentx/storages/base.py
load_memory ¶
Load a single long-term memory data.
Attributes:
Name | Type | Description |
---|---|---|
memory_id |
str
|
The ID of the long-term memory. |
table |
Optional[str]
|
The table name; defaults to 'memory' if None. |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The data that can be used to create a LongTermMemory instance. |
Source code in evoagentx/storages/base.py
save_memory ¶
Save or update a single memory.
Attributes:
Name | Type | Description |
---|---|---|
memory_data |
Dict[str, Any]
|
The long-term memory's data. |
table |
Optional[str]
|
The table name; defaults to 'memory' if None. |
Source code in evoagentx/storages/base.py
load_agent ¶
Load a single agent's data.
Attributes:
Name | Type | Description |
---|---|---|
agent_name |
str
|
The unique name of the agent to retrieve. |
table |
Optional[str]
|
The table name; defaults to 'agent' if None. |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The data that can be used to create an Agent instance, or None if not found. |
Source code in evoagentx/storages/base.py
remove_agent ¶
Remove an agent from storage if the agent exists.
Attributes:
Name | Type | Description |
---|---|---|
agent_name |
str
|
The name of the agent to be deleted. |
table |
Optional[str]
|
The table name; defaults to 'agent' if None. |
Raises:
Type | Description |
---|---|
ValueError
|
If the agent does not exist in the specified table. |
Source code in evoagentx/storages/base.py
save_agent ¶
Save or update a single agent's data.
Attributes:
Name | Type | Description |
---|---|---|
agent_data |
Dict[str, Any]
|
The agent's data, must include 'name' and 'content' keys. |
table |
Optional[str]
|
The table name; defaults to 'agent' if None. |
Raises:
Type | Description |
---|---|
ValueError
|
If 'name' field is missing or if Pydantic validation fails. |
Source code in evoagentx/storages/base.py
load_workflow ¶
Load a single workflow's data.
Attributes:
Name | Type | Description |
---|---|---|
workflow_id |
str
|
The ID of the workflow. |
table |
Optional[str]
|
The table name; defaults to 'workflow' if None. |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The data that can be used to create a WorkFlow instance, or None if not found. |
Source code in evoagentx/storages/base.py
save_workflow ¶
Save or update a workflow's data.
Attributes:
Name | Type | Description |
---|---|---|
workflow_data |
Dict[str, Any]
|
The workflow's data, must include 'name' field. |
table |
Optional[str]
|
The table name; defaults to 'workflow' if None. |
Raises:
Type | Description |
---|---|
ValueError
|
If 'name' field is missing or if Pydantic validation fails. |
Source code in evoagentx/storages/base.py
load_history ¶
Load a single history entry.
Attributes:
Name | Type | Description |
---|---|---|
memory_id |
str
|
The ID of the memory associated with the history entry. |
table |
Optional[str]
|
The table name; defaults to 'history' if None. |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: The history data, or None if not found. |
Source code in evoagentx/storages/base.py
save_history ¶
Save or update a single history entry.
Attributes:
Name | Type | Description |
---|---|---|
history_data |
Dict[str, Any]
|
The history data, must include 'memory_id' field. |
table |
Optional[str]
|
The table name; defaults to 'history' if None. |
Raises:
Type | Description |
---|---|
ValueError
|
If 'memory_id' field is missing or if Pydantic validation fails. |