powermem 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- powermem/__init__.py +103 -0
- powermem/agent/__init__.py +35 -0
- powermem/agent/abstract/__init__.py +22 -0
- powermem/agent/abstract/collaboration.py +259 -0
- powermem/agent/abstract/context.py +187 -0
- powermem/agent/abstract/manager.py +232 -0
- powermem/agent/abstract/permission.py +217 -0
- powermem/agent/abstract/privacy.py +267 -0
- powermem/agent/abstract/scope.py +199 -0
- powermem/agent/agent.py +791 -0
- powermem/agent/components/__init__.py +18 -0
- powermem/agent/components/collaboration_coordinator.py +645 -0
- powermem/agent/components/permission_controller.py +586 -0
- powermem/agent/components/privacy_protector.py +767 -0
- powermem/agent/components/scope_controller.py +685 -0
- powermem/agent/factories/__init__.py +16 -0
- powermem/agent/factories/agent_factory.py +266 -0
- powermem/agent/factories/config_factory.py +308 -0
- powermem/agent/factories/memory_factory.py +229 -0
- powermem/agent/implementations/__init__.py +16 -0
- powermem/agent/implementations/hybrid.py +728 -0
- powermem/agent/implementations/multi_agent.py +1040 -0
- powermem/agent/implementations/multi_user.py +1020 -0
- powermem/agent/types.py +53 -0
- powermem/agent/wrappers/__init__.py +14 -0
- powermem/agent/wrappers/agent_memory_wrapper.py +427 -0
- powermem/agent/wrappers/compatibility_wrapper.py +520 -0
- powermem/config_loader.py +318 -0
- powermem/configs.py +249 -0
- powermem/core/__init__.py +19 -0
- powermem/core/async_memory.py +1493 -0
- powermem/core/audit.py +258 -0
- powermem/core/base.py +165 -0
- powermem/core/memory.py +1567 -0
- powermem/core/setup.py +162 -0
- powermem/core/telemetry.py +215 -0
- powermem/integrations/__init__.py +17 -0
- powermem/integrations/embeddings/__init__.py +13 -0
- powermem/integrations/embeddings/aws_bedrock.py +100 -0
- powermem/integrations/embeddings/azure_openai.py +55 -0
- powermem/integrations/embeddings/base.py +31 -0
- powermem/integrations/embeddings/config/base.py +132 -0
- powermem/integrations/embeddings/configs.py +31 -0
- powermem/integrations/embeddings/factory.py +48 -0
- powermem/integrations/embeddings/gemini.py +39 -0
- powermem/integrations/embeddings/huggingface.py +41 -0
- powermem/integrations/embeddings/langchain.py +35 -0
- powermem/integrations/embeddings/lmstudio.py +29 -0
- powermem/integrations/embeddings/mock.py +11 -0
- powermem/integrations/embeddings/ollama.py +53 -0
- powermem/integrations/embeddings/openai.py +49 -0
- powermem/integrations/embeddings/qwen.py +102 -0
- powermem/integrations/embeddings/together.py +31 -0
- powermem/integrations/embeddings/vertexai.py +54 -0
- powermem/integrations/llm/__init__.py +18 -0
- powermem/integrations/llm/anthropic.py +87 -0
- powermem/integrations/llm/base.py +132 -0
- powermem/integrations/llm/config/anthropic.py +56 -0
- powermem/integrations/llm/config/azure.py +56 -0
- powermem/integrations/llm/config/base.py +62 -0
- powermem/integrations/llm/config/deepseek.py +56 -0
- powermem/integrations/llm/config/ollama.py +56 -0
- powermem/integrations/llm/config/openai.py +79 -0
- powermem/integrations/llm/config/qwen.py +68 -0
- powermem/integrations/llm/config/qwen_asr.py +46 -0
- powermem/integrations/llm/config/vllm.py +56 -0
- powermem/integrations/llm/configs.py +26 -0
- powermem/integrations/llm/deepseek.py +106 -0
- powermem/integrations/llm/factory.py +118 -0
- powermem/integrations/llm/gemini.py +201 -0
- powermem/integrations/llm/langchain.py +65 -0
- powermem/integrations/llm/ollama.py +106 -0
- powermem/integrations/llm/openai.py +166 -0
- powermem/integrations/llm/openai_structured.py +80 -0
- powermem/integrations/llm/qwen.py +207 -0
- powermem/integrations/llm/qwen_asr.py +171 -0
- powermem/integrations/llm/vllm.py +106 -0
- powermem/integrations/rerank/__init__.py +20 -0
- powermem/integrations/rerank/base.py +43 -0
- powermem/integrations/rerank/config/__init__.py +7 -0
- powermem/integrations/rerank/config/base.py +27 -0
- powermem/integrations/rerank/configs.py +23 -0
- powermem/integrations/rerank/factory.py +68 -0
- powermem/integrations/rerank/qwen.py +159 -0
- powermem/intelligence/__init__.py +17 -0
- powermem/intelligence/ebbinghaus_algorithm.py +354 -0
- powermem/intelligence/importance_evaluator.py +361 -0
- powermem/intelligence/intelligent_memory_manager.py +284 -0
- powermem/intelligence/manager.py +148 -0
- powermem/intelligence/plugin.py +229 -0
- powermem/prompts/__init__.py +29 -0
- powermem/prompts/graph/graph_prompts.py +217 -0
- powermem/prompts/graph/graph_tools_prompts.py +469 -0
- powermem/prompts/importance_evaluation.py +246 -0
- powermem/prompts/intelligent_memory_prompts.py +163 -0
- powermem/prompts/templates.py +193 -0
- powermem/storage/__init__.py +14 -0
- powermem/storage/adapter.py +896 -0
- powermem/storage/base.py +109 -0
- powermem/storage/config/base.py +13 -0
- powermem/storage/config/oceanbase.py +58 -0
- powermem/storage/config/pgvector.py +52 -0
- powermem/storage/config/sqlite.py +27 -0
- powermem/storage/configs.py +159 -0
- powermem/storage/factory.py +59 -0
- powermem/storage/migration_manager.py +438 -0
- powermem/storage/oceanbase/__init__.py +8 -0
- powermem/storage/oceanbase/constants.py +162 -0
- powermem/storage/oceanbase/oceanbase.py +1384 -0
- powermem/storage/oceanbase/oceanbase_graph.py +1441 -0
- powermem/storage/pgvector/__init__.py +7 -0
- powermem/storage/pgvector/pgvector.py +420 -0
- powermem/storage/sqlite/__init__.py +0 -0
- powermem/storage/sqlite/sqlite.py +218 -0
- powermem/storage/sqlite/sqlite_vector_store.py +311 -0
- powermem/utils/__init__.py +35 -0
- powermem/utils/utils.py +605 -0
- powermem/version.py +23 -0
- powermem-0.1.0.dist-info/METADATA +187 -0
- powermem-0.1.0.dist-info/RECORD +123 -0
- powermem-0.1.0.dist-info/WHEEL +5 -0
- powermem-0.1.0.dist-info/licenses/LICENSE +206 -0
- powermem-0.1.0.dist-info/top_level.txt +1 -0
powermem/__init__.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""
|
|
2
|
+
powermem - Intelligent Memory System
|
|
3
|
+
|
|
4
|
+
An AI-powered intelligent memory management system that provides a persistent memory layer for LLM applications.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import importlib.metadata
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
__version__ = importlib.metadata.version("powermem")
|
|
11
|
+
|
|
12
|
+
# Import core classes
|
|
13
|
+
from .core.memory import Memory, _auto_convert_config
|
|
14
|
+
from .core.async_memory import AsyncMemory
|
|
15
|
+
from .core.base import MemoryBase
|
|
16
|
+
|
|
17
|
+
# Import configuration loader
|
|
18
|
+
from .config_loader import load_config_from_env, create_config, validate_config, auto_config
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def create_memory(
|
|
22
|
+
config: Any = None,
|
|
23
|
+
**kwargs
|
|
24
|
+
):
|
|
25
|
+
"""
|
|
26
|
+
Create a Memory instance with automatic configuration loading.
|
|
27
|
+
|
|
28
|
+
This is the simplest way to create a Memory instance. It automatically:
|
|
29
|
+
1. Loads configuration from .env file if no config is provided
|
|
30
|
+
2. Falls back to defaults if .env is not available
|
|
31
|
+
3. Uses mock providers if API keys are not provided
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
config: Optional configuration dictionary. If None, loads from .env
|
|
35
|
+
**kwargs: Additional parameters to pass to Memory
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Memory instance
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
```python
|
|
42
|
+
from powermem import create_memory
|
|
43
|
+
|
|
44
|
+
# Simplest usage - auto loads from .env
|
|
45
|
+
# No API keys needed - will use mock providers
|
|
46
|
+
memory = create_memory()
|
|
47
|
+
|
|
48
|
+
# With custom config
|
|
49
|
+
memory = create_memory(config=my_config)
|
|
50
|
+
|
|
51
|
+
# With parameters
|
|
52
|
+
memory = create_memory(agent_id="my_agent")
|
|
53
|
+
```
|
|
54
|
+
"""
|
|
55
|
+
if config is None:
|
|
56
|
+
config = auto_config()
|
|
57
|
+
|
|
58
|
+
return Memory(config=config, **kwargs)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def from_config(config: Any = None, **kwargs):
|
|
62
|
+
"""
|
|
63
|
+
Create Memory instance from configuration
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
config: Configuration dictionary
|
|
67
|
+
**kwargs: Additional parameters
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Memory instance
|
|
71
|
+
|
|
72
|
+
Example:
|
|
73
|
+
```python
|
|
74
|
+
from powermem import from_config
|
|
75
|
+
|
|
76
|
+
memory = from_config({
|
|
77
|
+
"llm": {"provider": "openai", "config": {"api_key": "..."}},
|
|
78
|
+
"embedder": {"provider": "openai", "config": {"api_key": "..."}},
|
|
79
|
+
"vector_store": {"provider": "chroma", "config": {...}},
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
# Or auto-load from .env
|
|
83
|
+
memory = from_config()
|
|
84
|
+
```
|
|
85
|
+
"""
|
|
86
|
+
from .core.setup import from_config as _from_config
|
|
87
|
+
return _from_config(config=config, **kwargs)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
Memory.from_config = classmethod(lambda cls, config=None, **kwargs: create_memory(config, **kwargs))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
__all__ = [
|
|
94
|
+
"Memory",
|
|
95
|
+
"AsyncMemory",
|
|
96
|
+
"MemoryBase",
|
|
97
|
+
"load_config_from_env",
|
|
98
|
+
"create_config",
|
|
99
|
+
"validate_config",
|
|
100
|
+
"create_memory",
|
|
101
|
+
"from_config",
|
|
102
|
+
"auto_config",
|
|
103
|
+
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Agent Memory Management System
|
|
3
|
+
|
|
4
|
+
This module provides a unified architecture for managing memories across different
|
|
5
|
+
agent and user scenarios, including multi-agent collaboration, multi-user isolation,
|
|
6
|
+
and hybrid modes.
|
|
7
|
+
|
|
8
|
+
Key Components:
|
|
9
|
+
- MemoryFactory: Factory for creating different memory managers
|
|
10
|
+
- ManagerType: Enumeration of available manager types
|
|
11
|
+
- AgentMemoryManagerBase: Base class for all memory managers
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from .factories.memory_factory import MemoryFactory
|
|
15
|
+
from .abstract.manager import AgentMemoryManagerBase
|
|
16
|
+
from .implementations.multi_agent import MultiAgentMemoryManager
|
|
17
|
+
from .implementations.multi_user import MultiUserMemoryManager
|
|
18
|
+
from .implementations.hybrid import HybridMemoryManager
|
|
19
|
+
from .agent import AgentMemory
|
|
20
|
+
|
|
21
|
+
# Manager types for factory
|
|
22
|
+
class ManagerType:
|
|
23
|
+
MULTI_AGENT = "multi_agent"
|
|
24
|
+
MULTI_USER = "multi_user"
|
|
25
|
+
HYBRID = "hybrid"
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"MemoryFactory",
|
|
29
|
+
"ManagerType",
|
|
30
|
+
"AgentMemoryManagerBase",
|
|
31
|
+
"MultiAgentMemoryManager",
|
|
32
|
+
"MultiUserMemoryManager",
|
|
33
|
+
"HybridMemoryManager",
|
|
34
|
+
"AgentMemory"
|
|
35
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base classes for agent memory management system.
|
|
3
|
+
|
|
4
|
+
This module defines the core interfaces and abstract classes that all
|
|
5
|
+
agent memory managers must implement.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .manager import AgentMemoryManagerBase
|
|
9
|
+
from .context import AgentContextManagerBase
|
|
10
|
+
from .scope import AgentScopeManagerBase
|
|
11
|
+
from .permission import AgentPermissionManagerBase
|
|
12
|
+
from .collaboration import AgentCollaborationManagerBase
|
|
13
|
+
from .privacy import AgentPrivacyManagerBase
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"AgentMemoryManagerBase",
|
|
17
|
+
"AgentContextManagerBase",
|
|
18
|
+
"AgentScopeManagerBase",
|
|
19
|
+
"AgentPermissionManagerBase",
|
|
20
|
+
"AgentCollaborationManagerBase",
|
|
21
|
+
"AgentPrivacyManagerBase"
|
|
22
|
+
]
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base class for agent collaboration managers.
|
|
3
|
+
|
|
4
|
+
This module defines the interface for managing collaboration and coordination
|
|
5
|
+
between agents in the memory system.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from powermem.agent.types import CollaborationType, CollaborationStatus
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AgentCollaborationManagerBase(ABC):
|
|
15
|
+
"""
|
|
16
|
+
Abstract base class for agent collaboration managers.
|
|
17
|
+
|
|
18
|
+
This class defines the interface for managing collaboration and coordination
|
|
19
|
+
between agents in the memory system.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, config: Dict[str, Any]):
|
|
23
|
+
"""
|
|
24
|
+
Initialize the collaboration manager.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
config: Configuration dictionary
|
|
28
|
+
"""
|
|
29
|
+
self.config = config
|
|
30
|
+
self.initialized = False
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def initialize(self) -> None:
|
|
34
|
+
"""
|
|
35
|
+
Initialize the collaboration manager.
|
|
36
|
+
"""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def initiate_collaboration(
|
|
41
|
+
self,
|
|
42
|
+
initiator_id: str,
|
|
43
|
+
participant_ids: List[str],
|
|
44
|
+
collaboration_type: CollaborationType,
|
|
45
|
+
context: Optional[Dict[str, Any]] = None
|
|
46
|
+
) -> Dict[str, Any]:
|
|
47
|
+
"""
|
|
48
|
+
Initiate a collaboration between agents.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
initiator_id: ID of the agent initiating the collaboration
|
|
52
|
+
participant_ids: List of agent IDs participating in the collaboration
|
|
53
|
+
collaboration_type: Type of collaboration
|
|
54
|
+
context: Optional context information
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
Dictionary containing the collaboration initiation result
|
|
58
|
+
"""
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
@abstractmethod
|
|
62
|
+
def join_collaboration(
|
|
63
|
+
self,
|
|
64
|
+
collaboration_id: str,
|
|
65
|
+
agent_id: str
|
|
66
|
+
) -> Dict[str, Any]:
|
|
67
|
+
"""
|
|
68
|
+
Join an existing collaboration.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
collaboration_id: ID of the collaboration
|
|
72
|
+
agent_id: ID of the agent joining
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
Dictionary containing the join result
|
|
76
|
+
"""
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
@abstractmethod
|
|
80
|
+
def leave_collaboration(
|
|
81
|
+
self,
|
|
82
|
+
collaboration_id: str,
|
|
83
|
+
agent_id: str
|
|
84
|
+
) -> Dict[str, Any]:
|
|
85
|
+
"""
|
|
86
|
+
Leave a collaboration.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
collaboration_id: ID of the collaboration
|
|
90
|
+
agent_id: ID of the agent leaving
|
|
91
|
+
|
|
92
|
+
Returns:
|
|
93
|
+
Dictionary containing the leave result
|
|
94
|
+
"""
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
@abstractmethod
|
|
98
|
+
def get_collaboration_status(
|
|
99
|
+
self,
|
|
100
|
+
collaboration_id: str
|
|
101
|
+
) -> CollaborationStatus:
|
|
102
|
+
"""
|
|
103
|
+
Get the status of a collaboration.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
collaboration_id: ID of the collaboration
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
CollaborationStatus enum value
|
|
110
|
+
"""
|
|
111
|
+
pass
|
|
112
|
+
|
|
113
|
+
@abstractmethod
|
|
114
|
+
def update_collaboration_status(
|
|
115
|
+
self,
|
|
116
|
+
collaboration_id: str,
|
|
117
|
+
status: CollaborationStatus,
|
|
118
|
+
updated_by: str
|
|
119
|
+
) -> Dict[str, Any]:
|
|
120
|
+
"""
|
|
121
|
+
Update the status of a collaboration.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
collaboration_id: ID of the collaboration
|
|
125
|
+
status: New status
|
|
126
|
+
updated_by: ID of the agent updating the status
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
Dictionary containing the update result
|
|
130
|
+
"""
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
def get_collaboration_participants(
|
|
135
|
+
self,
|
|
136
|
+
collaboration_id: str
|
|
137
|
+
) -> List[str]:
|
|
138
|
+
"""
|
|
139
|
+
Get list of participants in a collaboration.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
collaboration_id: ID of the collaboration
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
List of agent IDs participating in the collaboration
|
|
146
|
+
"""
|
|
147
|
+
pass
|
|
148
|
+
|
|
149
|
+
@abstractmethod
|
|
150
|
+
def share_memory_in_collaboration(
|
|
151
|
+
self,
|
|
152
|
+
collaboration_id: str,
|
|
153
|
+
memory_id: str,
|
|
154
|
+
shared_by: str
|
|
155
|
+
) -> Dict[str, Any]:
|
|
156
|
+
"""
|
|
157
|
+
Share a memory within a collaboration.
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
collaboration_id: ID of the collaboration
|
|
161
|
+
memory_id: ID of the memory to share
|
|
162
|
+
shared_by: ID of the agent sharing the memory
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
Dictionary containing the share result
|
|
166
|
+
"""
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
@abstractmethod
|
|
170
|
+
def get_collaboration_memories(
|
|
171
|
+
self,
|
|
172
|
+
collaboration_id: str,
|
|
173
|
+
agent_id: Optional[str] = None
|
|
174
|
+
) -> List[Dict[str, Any]]:
|
|
175
|
+
"""
|
|
176
|
+
Get memories shared in a collaboration.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
collaboration_id: ID of the collaboration
|
|
180
|
+
agent_id: Optional ID of the agent requesting
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
List of memory dictionaries
|
|
184
|
+
"""
|
|
185
|
+
pass
|
|
186
|
+
|
|
187
|
+
@abstractmethod
|
|
188
|
+
def resolve_collaboration_conflict(
|
|
189
|
+
self,
|
|
190
|
+
collaboration_id: str,
|
|
191
|
+
conflict_data: Dict[str, Any],
|
|
192
|
+
resolver_id: str
|
|
193
|
+
) -> Dict[str, Any]:
|
|
194
|
+
"""
|
|
195
|
+
Resolve a conflict in a collaboration.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
collaboration_id: ID of the collaboration
|
|
199
|
+
conflict_data: Data about the conflict
|
|
200
|
+
resolver_id: ID of the agent resolving the conflict
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
Dictionary containing the resolution result
|
|
204
|
+
"""
|
|
205
|
+
pass
|
|
206
|
+
|
|
207
|
+
@abstractmethod
|
|
208
|
+
def get_collaboration_history(
|
|
209
|
+
self,
|
|
210
|
+
collaboration_id: str,
|
|
211
|
+
limit: Optional[int] = None
|
|
212
|
+
) -> List[Dict[str, Any]]:
|
|
213
|
+
"""
|
|
214
|
+
Get history of a collaboration.
|
|
215
|
+
|
|
216
|
+
Args:
|
|
217
|
+
collaboration_id: ID of the collaboration
|
|
218
|
+
limit: Optional limit on number of entries
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
List of collaboration history entries
|
|
222
|
+
"""
|
|
223
|
+
pass
|
|
224
|
+
|
|
225
|
+
@abstractmethod
|
|
226
|
+
def get_agent_collaborations(
|
|
227
|
+
self,
|
|
228
|
+
agent_id: str,
|
|
229
|
+
status: Optional[CollaborationStatus] = None
|
|
230
|
+
) -> List[Dict[str, Any]]:
|
|
231
|
+
"""
|
|
232
|
+
Get collaborations for an agent.
|
|
233
|
+
|
|
234
|
+
Args:
|
|
235
|
+
agent_id: ID of the agent
|
|
236
|
+
status: Optional status filter
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
List of collaboration dictionaries
|
|
240
|
+
"""
|
|
241
|
+
pass
|
|
242
|
+
|
|
243
|
+
def is_initialized(self) -> bool:
|
|
244
|
+
"""
|
|
245
|
+
Check if the collaboration manager is initialized.
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
True if initialized, False otherwise
|
|
249
|
+
"""
|
|
250
|
+
return self.initialized
|
|
251
|
+
|
|
252
|
+
def get_config(self) -> Dict[str, Any]:
|
|
253
|
+
"""
|
|
254
|
+
Get the configuration object.
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
Configuration dictionary
|
|
258
|
+
"""
|
|
259
|
+
return self.config
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base class for agent context managers.
|
|
3
|
+
|
|
4
|
+
This module defines the interface for managing agent/user context information
|
|
5
|
+
in the memory system.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AgentContextManagerBase(ABC):
|
|
13
|
+
"""
|
|
14
|
+
Abstract base class for agent context managers.
|
|
15
|
+
|
|
16
|
+
This class defines the interface for managing context information
|
|
17
|
+
for agents and users in the memory system.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, config: Dict[str, Any]):
|
|
21
|
+
"""
|
|
22
|
+
Initialize the context manager.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
config: Configuration dictionary
|
|
26
|
+
"""
|
|
27
|
+
self.config = config
|
|
28
|
+
self.initialized = False
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def initialize(self) -> None:
|
|
32
|
+
"""
|
|
33
|
+
Initialize the context manager.
|
|
34
|
+
"""
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
@abstractmethod
|
|
38
|
+
def get_context(
|
|
39
|
+
self,
|
|
40
|
+
agent_id: str,
|
|
41
|
+
context_type: Optional[str] = None
|
|
42
|
+
) -> Dict[str, Any]:
|
|
43
|
+
"""
|
|
44
|
+
Get context information for an agent/user.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
agent_id: ID of the agent/user
|
|
48
|
+
context_type: Optional context type filter
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Dictionary containing context information
|
|
52
|
+
"""
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
@abstractmethod
|
|
56
|
+
def update_context(
|
|
57
|
+
self,
|
|
58
|
+
agent_id: str,
|
|
59
|
+
context_data: Dict[str, Any]
|
|
60
|
+
) -> Dict[str, Any]:
|
|
61
|
+
"""
|
|
62
|
+
Update context information for an agent/user.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
agent_id: ID of the agent/user
|
|
66
|
+
context_data: Context data to update
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Dictionary containing the update result
|
|
70
|
+
"""
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
@abstractmethod
|
|
74
|
+
def add_context_entry(
|
|
75
|
+
self,
|
|
76
|
+
agent_id: str,
|
|
77
|
+
context_type: str,
|
|
78
|
+
context_value: Any,
|
|
79
|
+
metadata: Optional[Dict[str, Any]] = None
|
|
80
|
+
) -> Dict[str, Any]:
|
|
81
|
+
"""
|
|
82
|
+
Add a new context entry for an agent/user.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
agent_id: ID of the agent/user
|
|
86
|
+
context_type: Type of context entry
|
|
87
|
+
context_value: Value of the context entry
|
|
88
|
+
metadata: Optional metadata for the context entry
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
Dictionary containing the add result
|
|
92
|
+
"""
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
@abstractmethod
|
|
96
|
+
def remove_context_entry(
|
|
97
|
+
self,
|
|
98
|
+
agent_id: str,
|
|
99
|
+
context_type: str,
|
|
100
|
+
context_id: Optional[str] = None
|
|
101
|
+
) -> Dict[str, Any]:
|
|
102
|
+
"""
|
|
103
|
+
Remove a context entry for an agent/user.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
agent_id: ID of the agent/user
|
|
107
|
+
context_type: Type of context entry to remove
|
|
108
|
+
context_id: Optional specific context entry ID
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Dictionary containing the removal result
|
|
112
|
+
"""
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
@abstractmethod
|
|
116
|
+
def get_shared_context(
|
|
117
|
+
self,
|
|
118
|
+
agent_ids: List[str],
|
|
119
|
+
context_type: Optional[str] = None
|
|
120
|
+
) -> Dict[str, Any]:
|
|
121
|
+
"""
|
|
122
|
+
Get shared context information for multiple agents/users.
|
|
123
|
+
|
|
124
|
+
Args:
|
|
125
|
+
agent_ids: List of agent/user IDs
|
|
126
|
+
context_type: Optional context type filter
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
Dictionary containing shared context information
|
|
130
|
+
"""
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
def clear_context(
|
|
135
|
+
self,
|
|
136
|
+
agent_id: str,
|
|
137
|
+
context_type: Optional[str] = None
|
|
138
|
+
) -> Dict[str, Any]:
|
|
139
|
+
"""
|
|
140
|
+
Clear context information for an agent/user.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
agent_id: ID of the agent/user
|
|
144
|
+
context_type: Optional context type to clear
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
Dictionary containing the clear result
|
|
148
|
+
"""
|
|
149
|
+
pass
|
|
150
|
+
|
|
151
|
+
@abstractmethod
|
|
152
|
+
def get_context_history(
|
|
153
|
+
self,
|
|
154
|
+
agent_id: str,
|
|
155
|
+
context_type: Optional[str] = None,
|
|
156
|
+
limit: Optional[int] = None
|
|
157
|
+
) -> List[Dict[str, Any]]:
|
|
158
|
+
"""
|
|
159
|
+
Get context history for an agent/user.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
agent_id: ID of the agent/user
|
|
163
|
+
context_type: Optional context type filter
|
|
164
|
+
limit: Optional limit on number of entries
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
List of context history entries
|
|
168
|
+
"""
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
def is_initialized(self) -> bool:
|
|
172
|
+
"""
|
|
173
|
+
Check if the context manager is initialized.
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
True if initialized, False otherwise
|
|
177
|
+
"""
|
|
178
|
+
return self.initialized
|
|
179
|
+
|
|
180
|
+
def get_config(self) -> Dict[str, Any]:
|
|
181
|
+
"""
|
|
182
|
+
Get the configuration object.
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
Configuration dictionary
|
|
186
|
+
"""
|
|
187
|
+
return self.config
|