noesium 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.
- noesium/core/__init__.py +4 -0
- noesium/core/agent/__init__.py +14 -0
- noesium/core/agent/base.py +227 -0
- noesium/core/consts.py +6 -0
- noesium/core/goalith/conflict/conflict.py +104 -0
- noesium/core/goalith/conflict/detector.py +53 -0
- noesium/core/goalith/decomposer/__init__.py +6 -0
- noesium/core/goalith/decomposer/base.py +46 -0
- noesium/core/goalith/decomposer/callable_decomposer.py +65 -0
- noesium/core/goalith/decomposer/llm_decomposer.py +326 -0
- noesium/core/goalith/decomposer/prompts.py +140 -0
- noesium/core/goalith/decomposer/simple_decomposer.py +61 -0
- noesium/core/goalith/errors.py +22 -0
- noesium/core/goalith/goalgraph/graph.py +526 -0
- noesium/core/goalith/goalgraph/node.py +179 -0
- noesium/core/goalith/replanner/base.py +31 -0
- noesium/core/goalith/replanner/replanner.py +36 -0
- noesium/core/goalith/service.py +26 -0
- noesium/core/llm/__init__.py +154 -0
- noesium/core/llm/base.py +152 -0
- noesium/core/llm/litellm.py +528 -0
- noesium/core/llm/llamacpp.py +487 -0
- noesium/core/llm/message.py +184 -0
- noesium/core/llm/ollama.py +459 -0
- noesium/core/llm/openai.py +520 -0
- noesium/core/llm/openrouter.py +89 -0
- noesium/core/llm/prompt.py +551 -0
- noesium/core/memory/__init__.py +11 -0
- noesium/core/memory/base.py +464 -0
- noesium/core/memory/memu/__init__.py +24 -0
- noesium/core/memory/memu/config/__init__.py +26 -0
- noesium/core/memory/memu/config/activity/config.py +46 -0
- noesium/core/memory/memu/config/event/config.py +46 -0
- noesium/core/memory/memu/config/markdown_config.py +241 -0
- noesium/core/memory/memu/config/profile/config.py +48 -0
- noesium/core/memory/memu/llm_adapter.py +129 -0
- noesium/core/memory/memu/memory/__init__.py +31 -0
- noesium/core/memory/memu/memory/actions/__init__.py +40 -0
- noesium/core/memory/memu/memory/actions/add_activity_memory.py +299 -0
- noesium/core/memory/memu/memory/actions/base_action.py +342 -0
- noesium/core/memory/memu/memory/actions/cluster_memories.py +262 -0
- noesium/core/memory/memu/memory/actions/generate_suggestions.py +198 -0
- noesium/core/memory/memu/memory/actions/get_available_categories.py +66 -0
- noesium/core/memory/memu/memory/actions/link_related_memories.py +515 -0
- noesium/core/memory/memu/memory/actions/run_theory_of_mind.py +254 -0
- noesium/core/memory/memu/memory/actions/update_memory_with_suggestions.py +514 -0
- noesium/core/memory/memu/memory/embeddings.py +130 -0
- noesium/core/memory/memu/memory/file_manager.py +306 -0
- noesium/core/memory/memu/memory/memory_agent.py +578 -0
- noesium/core/memory/memu/memory/recall_agent.py +376 -0
- noesium/core/memory/memu/memory_store.py +628 -0
- noesium/core/memory/models.py +149 -0
- noesium/core/msgbus/__init__.py +12 -0
- noesium/core/msgbus/base.py +395 -0
- noesium/core/orchestrix/__init__.py +0 -0
- noesium/core/py.typed +0 -0
- noesium/core/routing/__init__.py +20 -0
- noesium/core/routing/base.py +66 -0
- noesium/core/routing/router.py +241 -0
- noesium/core/routing/strategies/__init__.py +9 -0
- noesium/core/routing/strategies/dynamic_complexity.py +361 -0
- noesium/core/routing/strategies/self_assessment.py +147 -0
- noesium/core/routing/types.py +38 -0
- noesium/core/toolify/__init__.py +39 -0
- noesium/core/toolify/base.py +360 -0
- noesium/core/toolify/config.py +138 -0
- noesium/core/toolify/mcp_integration.py +275 -0
- noesium/core/toolify/registry.py +214 -0
- noesium/core/toolify/toolkits/__init__.py +1 -0
- noesium/core/tracing/__init__.py +37 -0
- noesium/core/tracing/langgraph_hooks.py +308 -0
- noesium/core/tracing/opik_tracing.py +144 -0
- noesium/core/tracing/token_tracker.py +166 -0
- noesium/core/utils/__init__.py +10 -0
- noesium/core/utils/logging.py +172 -0
- noesium/core/utils/statistics.py +12 -0
- noesium/core/utils/typing.py +17 -0
- noesium/core/vector_store/__init__.py +79 -0
- noesium/core/vector_store/base.py +94 -0
- noesium/core/vector_store/pgvector.py +304 -0
- noesium/core/vector_store/weaviate.py +383 -0
- noesium-0.1.0.dist-info/METADATA +525 -0
- noesium-0.1.0.dist-info/RECORD +86 -0
- noesium-0.1.0.dist-info/WHEEL +5 -0
- noesium-0.1.0.dist-info/licenses/LICENSE +21 -0
- noesium-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base interface for the simple memory system.
|
|
3
|
+
|
|
4
|
+
This module defines the core abstract interfaces that all memory implementations
|
|
5
|
+
must implement, providing a consistent API for memory operations across different
|
|
6
|
+
storage backends and use cases.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from abc import ABC, abstractmethod
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
from typing import Any, AsyncGenerator, Dict, List, Optional
|
|
12
|
+
|
|
13
|
+
from .models import MemoryFilter, MemoryItem, MemoryStats, SearchResult
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BaseMemoryStore(ABC):
|
|
17
|
+
"""
|
|
18
|
+
Abstract base class for memory storage systems.
|
|
19
|
+
|
|
20
|
+
This interface defines the core memory operations that all memory store
|
|
21
|
+
implementations must support. It provides a consistent API for storing,
|
|
22
|
+
retrieving, searching, and managing memory items across different backends.
|
|
23
|
+
|
|
24
|
+
The interface supports both synchronous and asynchronous operations,
|
|
25
|
+
allowing implementations to choose the most appropriate approach for
|
|
26
|
+
their storage backend.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
# ==========================================
|
|
30
|
+
# Core CRUD Operations
|
|
31
|
+
# ==========================================
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
async def add(self, memory_item: MemoryItem, **kwargs) -> str:
|
|
35
|
+
"""
|
|
36
|
+
Add a new memory item to the store.
|
|
37
|
+
|
|
38
|
+
This method stores a new memory item and returns its unique identifier.
|
|
39
|
+
The implementation should handle ID generation if not provided and
|
|
40
|
+
ensure the item is properly indexed for search operations.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
memory_item: The memory item to store
|
|
44
|
+
**kwargs: Additional implementation-specific parameters
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
The unique identifier of the stored memory item
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
MemoryError: If the item cannot be stored
|
|
51
|
+
ValidationError: If the memory item is invalid
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
@abstractmethod
|
|
55
|
+
async def get(self, memory_id: str, **kwargs) -> Optional[MemoryItem]:
|
|
56
|
+
"""
|
|
57
|
+
Retrieve a memory item by its unique identifier.
|
|
58
|
+
|
|
59
|
+
This method fetches a specific memory item from the store using its ID.
|
|
60
|
+
Returns None if the item is not found.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
memory_id: Unique identifier of the memory item
|
|
64
|
+
**kwargs: Additional implementation-specific parameters
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
The memory item if found, None otherwise
|
|
68
|
+
|
|
69
|
+
Raises:
|
|
70
|
+
MemoryError: If retrieval fails due to storage issues
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
@abstractmethod
|
|
74
|
+
async def update(self, memory_id: str, updates: Dict[str, Any], **kwargs) -> bool:
|
|
75
|
+
"""
|
|
76
|
+
Update an existing memory item.
|
|
77
|
+
|
|
78
|
+
This method updates specific fields of a memory item. The implementation
|
|
79
|
+
should validate updates and maintain version tracking if supported.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
memory_id: Unique identifier of the memory item to update
|
|
83
|
+
updates: Dictionary of field updates to apply
|
|
84
|
+
**kwargs: Additional implementation-specific parameters
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
True if the update was successful, False if item not found
|
|
88
|
+
|
|
89
|
+
Raises:
|
|
90
|
+
MemoryError: If update fails due to storage issues
|
|
91
|
+
ValidationError: If updates are invalid
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
@abstractmethod
|
|
95
|
+
async def delete(self, memory_id: str, **kwargs) -> bool:
|
|
96
|
+
"""
|
|
97
|
+
Delete a memory item from the store.
|
|
98
|
+
|
|
99
|
+
This method permanently removes a memory item and all associated
|
|
100
|
+
index entries. The operation cannot be undone.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
memory_id: Unique identifier of the memory item to delete
|
|
104
|
+
**kwargs: Additional implementation-specific parameters
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
True if deletion was successful, False if item not found
|
|
108
|
+
|
|
109
|
+
Raises:
|
|
110
|
+
MemoryError: If deletion fails due to storage issues
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
# ==========================================
|
|
114
|
+
# Batch Operations
|
|
115
|
+
# ==========================================
|
|
116
|
+
|
|
117
|
+
@abstractmethod
|
|
118
|
+
async def add_many(self, memory_items: List[MemoryItem], **kwargs) -> List[str]:
|
|
119
|
+
"""
|
|
120
|
+
Add multiple memory items in a batch operation.
|
|
121
|
+
|
|
122
|
+
This method efficiently stores multiple memory items in a single
|
|
123
|
+
operation, which is useful for bulk imports or conversation logging.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
memory_items: List of memory items to store
|
|
127
|
+
**kwargs: Additional implementation-specific parameters
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
List of unique identifiers for the stored items
|
|
131
|
+
|
|
132
|
+
Raises:
|
|
133
|
+
MemoryError: If batch operation fails
|
|
134
|
+
ValidationError: If any memory item is invalid
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
@abstractmethod
|
|
138
|
+
async def delete_many(self, memory_ids: List[str], **kwargs) -> int:
|
|
139
|
+
"""
|
|
140
|
+
Delete multiple memory items in a batch operation.
|
|
141
|
+
|
|
142
|
+
This method efficiently removes multiple memory items in a single
|
|
143
|
+
operation. Useful for cleanup and bulk deletion operations.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
memory_ids: List of memory item IDs to delete
|
|
147
|
+
**kwargs: Additional implementation-specific parameters
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
Number of items actually deleted
|
|
151
|
+
|
|
152
|
+
Raises:
|
|
153
|
+
MemoryError: If batch deletion fails
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
# ==========================================
|
|
157
|
+
# Query and Filtering Operations
|
|
158
|
+
# ==========================================
|
|
159
|
+
|
|
160
|
+
@abstractmethod
|
|
161
|
+
async def get_all(
|
|
162
|
+
self,
|
|
163
|
+
filters: Optional[MemoryFilter] = None,
|
|
164
|
+
limit: Optional[int] = None,
|
|
165
|
+
offset: Optional[int] = None,
|
|
166
|
+
sort_by: Optional[str] = None,
|
|
167
|
+
sort_order: str = "desc",
|
|
168
|
+
**kwargs,
|
|
169
|
+
) -> List[MemoryItem]:
|
|
170
|
+
"""
|
|
171
|
+
Retrieve multiple memory items with optional filtering and pagination.
|
|
172
|
+
|
|
173
|
+
This method provides flexible querying capabilities with support for
|
|
174
|
+
filtering, sorting, and pagination. Essential for browsing and
|
|
175
|
+
managing large memory collections.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
filters: Optional filter criteria to apply
|
|
179
|
+
limit: Maximum number of items to return
|
|
180
|
+
offset: Number of items to skip (for pagination)
|
|
181
|
+
sort_by: Field to sort by (e.g., 'created_at', 'importance')
|
|
182
|
+
sort_order: Sort order ('asc' or 'desc')
|
|
183
|
+
**kwargs: Additional implementation-specific parameters
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
List of memory items matching the criteria
|
|
187
|
+
|
|
188
|
+
Raises:
|
|
189
|
+
MemoryError: If query fails due to storage issues
|
|
190
|
+
ValidationError: If filter criteria are invalid
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
@abstractmethod
|
|
194
|
+
async def count(self, filters: Optional[MemoryFilter] = None, **kwargs) -> int:
|
|
195
|
+
"""
|
|
196
|
+
Count memory items matching the given filters.
|
|
197
|
+
|
|
198
|
+
This method provides efficient counting of memory items without
|
|
199
|
+
retrieving the actual data, useful for pagination and analytics.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
filters: Optional filter criteria to apply
|
|
203
|
+
**kwargs: Additional implementation-specific parameters
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
Number of memory items matching the criteria
|
|
207
|
+
|
|
208
|
+
Raises:
|
|
209
|
+
MemoryError: If count operation fails
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
# ==========================================
|
|
213
|
+
# Search Operations
|
|
214
|
+
# ==========================================
|
|
215
|
+
|
|
216
|
+
@abstractmethod
|
|
217
|
+
async def search(
|
|
218
|
+
self,
|
|
219
|
+
query: str,
|
|
220
|
+
limit: int = 10,
|
|
221
|
+
threshold: float = 0.7,
|
|
222
|
+
memory_types: Optional[List[str]] = None,
|
|
223
|
+
filters: Optional[MemoryFilter] = None,
|
|
224
|
+
**kwargs,
|
|
225
|
+
) -> List[SearchResult]:
|
|
226
|
+
"""
|
|
227
|
+
Perform semantic search across memory items.
|
|
228
|
+
|
|
229
|
+
This method enables intelligent search across memory content using
|
|
230
|
+
semantic similarity. The implementation may use vector embeddings,
|
|
231
|
+
full-text search, or hybrid approaches.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
query: Search query string
|
|
235
|
+
limit: Maximum number of results to return
|
|
236
|
+
threshold: Minimum relevance score (0.0 to 1.0)
|
|
237
|
+
memory_types: Optional list of memory types to search
|
|
238
|
+
filters: Optional additional filter criteria
|
|
239
|
+
**kwargs: Additional implementation-specific parameters
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
List of search results with relevance scores
|
|
243
|
+
|
|
244
|
+
Raises:
|
|
245
|
+
MemoryError: If search operation fails
|
|
246
|
+
ValidationError: If search parameters are invalid
|
|
247
|
+
"""
|
|
248
|
+
|
|
249
|
+
@abstractmethod
|
|
250
|
+
async def similarity_search(
|
|
251
|
+
self,
|
|
252
|
+
reference_items: List[MemoryItem],
|
|
253
|
+
limit: int = 10,
|
|
254
|
+
threshold: float = 0.7,
|
|
255
|
+
filters: Optional[MemoryFilter] = None,
|
|
256
|
+
**kwargs,
|
|
257
|
+
) -> List[SearchResult]:
|
|
258
|
+
"""
|
|
259
|
+
Find memory items similar to a list of reference items.
|
|
260
|
+
|
|
261
|
+
This method finds memory items that are semantically similar to
|
|
262
|
+
a list of reference memory items. Useful for finding related
|
|
263
|
+
conversations or duplicate detection.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
reference_items: List of reference memory items
|
|
267
|
+
limit: Maximum number of results to return
|
|
268
|
+
threshold: Minimum similarity score (0.0 to 1.0)
|
|
269
|
+
filters: Optional additional filter criteria
|
|
270
|
+
**kwargs: Additional implementation-specific parameters
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
List of similar memory items with similarity scores
|
|
274
|
+
|
|
275
|
+
Raises:
|
|
276
|
+
MemoryError: If similarity search fails
|
|
277
|
+
ValidationError: If search parameters are invalid
|
|
278
|
+
"""
|
|
279
|
+
|
|
280
|
+
# ==========================================
|
|
281
|
+
# Memory Management Operations
|
|
282
|
+
# ==========================================
|
|
283
|
+
|
|
284
|
+
@abstractmethod
|
|
285
|
+
async def get_stats(self, filters: Optional[MemoryFilter] = None, **kwargs) -> MemoryStats:
|
|
286
|
+
"""
|
|
287
|
+
Get statistics about the memory store.
|
|
288
|
+
|
|
289
|
+
This method provides insights into memory usage, distribution,
|
|
290
|
+
and performance metrics for monitoring and optimization.
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
filters: Optional filters to scope statistics
|
|
294
|
+
**kwargs: Additional implementation-specific parameters
|
|
295
|
+
|
|
296
|
+
Returns:
|
|
297
|
+
Memory statistics object
|
|
298
|
+
|
|
299
|
+
Raises:
|
|
300
|
+
MemoryError: If statistics calculation fails
|
|
301
|
+
"""
|
|
302
|
+
|
|
303
|
+
@abstractmethod
|
|
304
|
+
async def cleanup_old_memories(
|
|
305
|
+
self,
|
|
306
|
+
older_than: datetime,
|
|
307
|
+
memory_types: Optional[List[str]] = None,
|
|
308
|
+
preserve_important: bool = True,
|
|
309
|
+
dry_run: bool = True,
|
|
310
|
+
**kwargs,
|
|
311
|
+
) -> int:
|
|
312
|
+
"""
|
|
313
|
+
Clean up old memory items based on age and criteria.
|
|
314
|
+
|
|
315
|
+
This method provides maintenance functionality to manage
|
|
316
|
+
memory store size and remove outdated information.
|
|
317
|
+
|
|
318
|
+
Args:
|
|
319
|
+
older_than: Delete items older than this datetime
|
|
320
|
+
memory_types: Optional list of memory types to clean
|
|
321
|
+
preserve_important: Whether to preserve high-importance items
|
|
322
|
+
dry_run: If True, return count without actually deleting
|
|
323
|
+
**kwargs: Additional implementation-specific parameters
|
|
324
|
+
|
|
325
|
+
Returns:
|
|
326
|
+
Number of items that would be/were deleted
|
|
327
|
+
|
|
328
|
+
Raises:
|
|
329
|
+
MemoryError: If cleanup operation fails
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
# ==========================================
|
|
333
|
+
# Stream Operations (Optional)
|
|
334
|
+
# ==========================================
|
|
335
|
+
|
|
336
|
+
async def stream_memories(
|
|
337
|
+
self, filters: Optional[MemoryFilter] = None, chunk_size: int = 100, **kwargs
|
|
338
|
+
) -> AsyncGenerator[List[MemoryItem], None]:
|
|
339
|
+
"""
|
|
340
|
+
Stream memory items in chunks for large dataset processing.
|
|
341
|
+
|
|
342
|
+
This method provides efficient streaming access to large memory
|
|
343
|
+
collections without loading everything into memory at once.
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
filters: Optional filter criteria to apply
|
|
347
|
+
chunk_size: Number of items per chunk
|
|
348
|
+
**kwargs: Additional implementation-specific parameters
|
|
349
|
+
|
|
350
|
+
Yields:
|
|
351
|
+
Chunks of memory items
|
|
352
|
+
|
|
353
|
+
Raises:
|
|
354
|
+
MemoryError: If streaming fails
|
|
355
|
+
"""
|
|
356
|
+
# Default implementation using get_all with pagination
|
|
357
|
+
offset = 0
|
|
358
|
+
while True:
|
|
359
|
+
chunk = await self.get_all(filters=filters, limit=chunk_size, offset=offset, **kwargs)
|
|
360
|
+
if not chunk:
|
|
361
|
+
break
|
|
362
|
+
yield chunk
|
|
363
|
+
if len(chunk) < chunk_size:
|
|
364
|
+
break
|
|
365
|
+
offset += chunk_size
|
|
366
|
+
|
|
367
|
+
# ==========================================
|
|
368
|
+
# Context Manager Support
|
|
369
|
+
# ==========================================
|
|
370
|
+
|
|
371
|
+
async def __aenter__(self):
|
|
372
|
+
"""Async context manager entry."""
|
|
373
|
+
return self
|
|
374
|
+
|
|
375
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
376
|
+
"""Async context manager exit."""
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
class BaseMemoryManager(ABC):
|
|
380
|
+
"""
|
|
381
|
+
Abstract base class for high-level memory management.
|
|
382
|
+
|
|
383
|
+
This interface defines higher-level operations for memory management,
|
|
384
|
+
including automatic memory extraction, summarization, and intelligent
|
|
385
|
+
retrieval based on context and user patterns.
|
|
386
|
+
"""
|
|
387
|
+
|
|
388
|
+
@abstractmethod
|
|
389
|
+
async def extract_and_store_conversation(
|
|
390
|
+
self,
|
|
391
|
+
conversation_messages: List[Dict[str, str]],
|
|
392
|
+
conversation_id: str,
|
|
393
|
+
user_id: Optional[str] = None,
|
|
394
|
+
agent_id: Optional[str] = None,
|
|
395
|
+
extract_profiles: bool = True,
|
|
396
|
+
extract_experiences: bool = True,
|
|
397
|
+
**kwargs,
|
|
398
|
+
) -> Dict[str, List[str]]:
|
|
399
|
+
"""
|
|
400
|
+
Extract memories from a conversation and store them.
|
|
401
|
+
|
|
402
|
+
This method processes a conversation to extract various types of
|
|
403
|
+
memories including user profiles and agent experiences, then
|
|
404
|
+
stores them in the memory store.
|
|
405
|
+
|
|
406
|
+
Args:
|
|
407
|
+
conversation_messages: List of conversation messages
|
|
408
|
+
conversation_id: ID of the conversation
|
|
409
|
+
user_id: Optional user ID
|
|
410
|
+
agent_id: Optional agent ID
|
|
411
|
+
extract_profiles: Whether to extract user profiles
|
|
412
|
+
extract_experiences: Whether to extract agent experiences
|
|
413
|
+
**kwargs: Additional parameters
|
|
414
|
+
|
|
415
|
+
Returns:
|
|
416
|
+
Dictionary mapping memory types to lists of created memory IDs
|
|
417
|
+
|
|
418
|
+
Raises:
|
|
419
|
+
MemoryError: If extraction or storage fails
|
|
420
|
+
"""
|
|
421
|
+
|
|
422
|
+
@abstractmethod
|
|
423
|
+
async def get_relevant_context(
|
|
424
|
+
self, query: str, user_id: Optional[str] = None, agent_id: Optional[str] = None, max_items: int = 5, **kwargs
|
|
425
|
+
) -> List[SearchResult]:
|
|
426
|
+
"""
|
|
427
|
+
Get relevant memory context for a query.
|
|
428
|
+
|
|
429
|
+
This method intelligently retrieves the most relevant memories
|
|
430
|
+
for a given query, considering user and agent context.
|
|
431
|
+
|
|
432
|
+
Args:
|
|
433
|
+
query: Query to find relevant context for
|
|
434
|
+
user_id: Optional user ID for personalization
|
|
435
|
+
agent_id: Optional agent ID for agent-specific context
|
|
436
|
+
max_items: Maximum number of context items to return
|
|
437
|
+
**kwargs: Additional parameters
|
|
438
|
+
|
|
439
|
+
Returns:
|
|
440
|
+
List of relevant memory items with relevance scores
|
|
441
|
+
|
|
442
|
+
Raises:
|
|
443
|
+
MemoryError: If context retrieval fails
|
|
444
|
+
"""
|
|
445
|
+
|
|
446
|
+
@abstractmethod
|
|
447
|
+
async def summarize_conversation_history(self, conversation_id: str, max_length: int = 500, **kwargs) -> str:
|
|
448
|
+
"""
|
|
449
|
+
Generate a summary of conversation history.
|
|
450
|
+
|
|
451
|
+
This method creates a concise summary of a conversation,
|
|
452
|
+
useful for context compression and memory management.
|
|
453
|
+
|
|
454
|
+
Args:
|
|
455
|
+
conversation_id: ID of the conversation to summarize
|
|
456
|
+
max_length: Maximum length of summary in characters
|
|
457
|
+
**kwargs: Additional parameters
|
|
458
|
+
|
|
459
|
+
Returns:
|
|
460
|
+
Summary text of the conversation
|
|
461
|
+
|
|
462
|
+
Raises:
|
|
463
|
+
MemoryError: If summarization fails
|
|
464
|
+
"""
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MemU
|
|
3
|
+
|
|
4
|
+
A Python framework for creating and managing AI agent memories through file-based storage.
|
|
5
|
+
|
|
6
|
+
Simplified unified memory architecture with a single Memory Agent.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__version__ = "0.1.9"
|
|
10
|
+
__author__ = "MemU Team"
|
|
11
|
+
__email__ = "support@nevamind.ai"
|
|
12
|
+
|
|
13
|
+
# Core Memory system - Unified Memory Agent
|
|
14
|
+
from .memory import MemoryAgent, MemoryFileManager
|
|
15
|
+
from .memory.embeddings import create_embedding_client, get_default_embedding_client
|
|
16
|
+
from .memory_store import MemuMemoryStore
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"MemoryAgent",
|
|
20
|
+
"MemoryFileManager",
|
|
21
|
+
"get_default_embedding_client",
|
|
22
|
+
"create_embedding_client",
|
|
23
|
+
"MemuMemoryStore",
|
|
24
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Configuration module for MemU"""
|
|
2
|
+
|
|
3
|
+
# Import markdown configuration (primary public API)
|
|
4
|
+
from .markdown_config import (
|
|
5
|
+
MarkdownConfigManager,
|
|
6
|
+
MarkdownFileConfig,
|
|
7
|
+
detect_file_type,
|
|
8
|
+
get_all_file_configs,
|
|
9
|
+
get_config_manager,
|
|
10
|
+
get_optional_files,
|
|
11
|
+
get_required_files,
|
|
12
|
+
get_simple_summary,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
# Markdown configuration
|
|
17
|
+
"get_config_manager",
|
|
18
|
+
"detect_file_type",
|
|
19
|
+
"MarkdownConfigManager",
|
|
20
|
+
"MarkdownFileConfig",
|
|
21
|
+
# Simplified configuration API
|
|
22
|
+
"get_required_files",
|
|
23
|
+
"get_optional_files",
|
|
24
|
+
"get_simple_summary",
|
|
25
|
+
"get_all_file_configs",
|
|
26
|
+
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Activity type configuration file
|
|
3
|
+
Each md file type has its own folder and configuration
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class ActivityConfig:
|
|
11
|
+
"""Activity file configuration"""
|
|
12
|
+
|
|
13
|
+
# Basic information
|
|
14
|
+
name: str = "activity"
|
|
15
|
+
filename: str = "activity.md"
|
|
16
|
+
description: str = "Record all conversation and activity content"
|
|
17
|
+
|
|
18
|
+
# Folder path
|
|
19
|
+
folder_name: str = "activity"
|
|
20
|
+
prompt_file: str = "prompt.txt"
|
|
21
|
+
config_file: str = "config.py"
|
|
22
|
+
|
|
23
|
+
# RAG configuration
|
|
24
|
+
context: str = "rag" # "all" means put entire content in context, "rag" means use RAG search only
|
|
25
|
+
rag_length: int = 50 # RAG length, -1 means all, other values mean number of lines
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Create configuration instance
|
|
29
|
+
CONFIG = ActivityConfig()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_config():
|
|
33
|
+
"""Get activity configuration"""
|
|
34
|
+
return CONFIG
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_file_info():
|
|
38
|
+
"""Get file information"""
|
|
39
|
+
return {
|
|
40
|
+
"name": CONFIG.name,
|
|
41
|
+
"filename": CONFIG.filename,
|
|
42
|
+
"description": CONFIG.description,
|
|
43
|
+
"folder": CONFIG.folder_name,
|
|
44
|
+
"context": CONFIG.context,
|
|
45
|
+
"rag_length": CONFIG.rag_length,
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Event type configuration file
|
|
3
|
+
Record important events, activities, milestones, etc.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class EventConfig:
|
|
11
|
+
"""Event file configuration"""
|
|
12
|
+
|
|
13
|
+
# Basic information
|
|
14
|
+
name: str = "event"
|
|
15
|
+
filename: str = "event.md"
|
|
16
|
+
description: str = "Record important events, activities and milestones"
|
|
17
|
+
|
|
18
|
+
# Folder path
|
|
19
|
+
folder_name: str = "event"
|
|
20
|
+
prompt_file: str = "prompt.txt"
|
|
21
|
+
config_file: str = "config.py"
|
|
22
|
+
|
|
23
|
+
# RAG configuration
|
|
24
|
+
context: str = "rag" # "all" means put entire content in context, "rag" means use RAG search only
|
|
25
|
+
rag_length: int = 30 # RAG length, -1 means all, other values mean number of lines
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Create configuration instance
|
|
29
|
+
CONFIG = EventConfig()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_config():
|
|
33
|
+
"""Get event configuration"""
|
|
34
|
+
return CONFIG
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_file_info():
|
|
38
|
+
"""Get file information"""
|
|
39
|
+
return {
|
|
40
|
+
"name": CONFIG.name,
|
|
41
|
+
"filename": CONFIG.filename,
|
|
42
|
+
"description": CONFIG.description,
|
|
43
|
+
"folder": CONFIG.folder_name,
|
|
44
|
+
"context": CONFIG.context,
|
|
45
|
+
"rag_length": CONFIG.rag_length,
|
|
46
|
+
}
|