API Reference
This page provides comprehensive API documentation for memg-core.
Public API
The main interface for memg-core is through the public API module:
Public API for memg-core - designed for long-running servers.
Provides MemgClient for explicit initialization and module-level functions for environment-based usage.
_CLIENT = None
module-attribute
DatabaseClients
DDL-only database setup - creates schemas and returns raw clients.
NO INTERFACES - pure schema creation only. Consumer must create interfaces separately using returned raw clients.
Attributes:
| Name | Type | Description |
|---|---|---|
qdrant_client |
QdrantClient | None
|
Pre-initialized QdrantClient. |
kuzu_connection |
Connection | None
|
Pre-initialized Kuzu connection. |
db_name |
str | None
|
Database name. |
qdrant_path |
Path to Qdrant database. |
|
kuzu_path |
Path to Kuzu database. |
|
yaml_translator |
YAML translator instance. |
Source code in src/memg_core/utils/db_clients.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
__init__(yaml_path=None, embedder=None)
Create DDL-only database client wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
str | None
|
Path to YAML schema file. User must provide - no defaults. |
None
|
embedder
|
EmbedderProtocol | None
|
Optional custom embedder implementation. If not provided, uses the default FastEmbed-based embedder. |
None
|
Source code in src/memg_core/utils/db_clients.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
close()
Close all database connections and cleanup resources.
Should be called when database clients are no longer needed.
Source code in src/memg_core/utils/db_clients.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
get_embedder()
Get embedder instance.
Returns:
| Name | Type | Description |
|---|---|---|
EmbedderProtocol |
EmbedderProtocol
|
Instance for generating vectors. Either the custom embedder provided during initialization or the default FastEmbed-based embedder. |
Source code in src/memg_core/utils/db_clients.py
187 188 189 190 191 192 193 194 195 196 | |
get_kuzu_interface()
Get Kuzu interface using the initialized connection.
Returns:
| Name | Type | Description |
|---|---|---|
KuzuInterface |
KuzuInterface
|
Configured with the DDL-created connection (no yaml_translator needed). |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If connection not initialized (call init_dbs first). |
Source code in src/memg_core/utils/db_clients.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
get_qdrant_interface()
Get Qdrant interface using the initialized client.
Returns:
| Name | Type | Description |
|---|---|---|
QdrantInterface |
QdrantInterface
|
Configured with the DDL-created client and collection. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If client not initialized (call init_dbs first). |
Source code in src/memg_core/utils/db_clients.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
get_yaml_translator()
Get the YAML translator used for schema operations.
Returns:
| Name | Type | Description |
|---|---|---|
YamlTranslator |
YamlTranslator
|
Instance used during DDL operations. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If YAML translator not initialized. |
Source code in src/memg_core/utils/db_clients.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
init_dbs(db_path, db_name)
Initialize databases with structured paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_path
|
str
|
Base database directory. |
required |
db_name
|
str
|
Database name (used for collection and file names). |
required |
Source code in src/memg_core/utils/db_clients.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
EmbedderProtocol
Bases: Protocol
Protocol defining the embedder interface (structural typing - duck typing with type hints).
This is NOT an abstract base class - you don't need to inherit from it. Any object with get_embedding() and get_embeddings() methods will work. The Protocol is purely for type checkers (mypy, pyright) and IDE support.
This allows consumers to provide their own embedding implementations (OpenAI, Cohere, custom models, etc.) without modifying memg-core code.
Example
class MyEmbedder: # No inheritance needed! ... def get_embedding(self, text: str) -> list[float]: ... return [0.1, 0.2, 0.3] # Your implementation ... def get_embeddings(self, texts: list[str]) -> list[list[float]]: ... return [[0.1, 0.2, 0.3] for _ in texts]
from memg_core.api import MemgClient client = MemgClient(yaml_path="...", db_path="...", embedder=MyEmbedder())
Source code in src/memg_core/core/interfaces/embedder_protocol.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
get_embedding(text)
Generate embedding vector for a single text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input text to embed. |
required |
Returns:
| Type | Description |
|---|---|
list[float]
|
Embedding vector as list of floats. |
Source code in src/memg_core/core/interfaces/embedder_protocol.py
33 34 35 36 37 38 39 40 41 42 | |
get_embeddings(texts)
Generate embedding vectors for multiple texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
list[str]
|
List of input texts to embed. |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
List of embedding vectors. |
Source code in src/memg_core/core/interfaces/embedder_protocol.py
44 45 46 47 48 49 50 51 52 53 | |
MemgClient
Client for memg-core operations - initialize once, use throughout server lifetime.
Provides a clean interface for memory operations with explicit resource management.
Source code in src/memg_core/api/public.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
__init__(yaml_path, db_path, embedder=None)
Initialize client for long-running server usage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
str
|
Path to YAML schema configuration file. |
required |
db_path
|
str
|
Base directory path for database storage. |
required |
embedder
|
EmbedderProtocol | None
|
Optional custom embedder. If provided, will be used instead of the default FastEmbed-based embedder. Must implement EmbedderProtocol (get_embedding and get_embeddings methods). |
None
|
Source code in src/memg_core/api/public.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
add_memory(memory_type, payload, user_id)
Add memory and return HRID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_type
|
str
|
Entity type from YAML schema (e.g., 'task', 'note'). |
required |
payload
|
dict[str, Any]
|
Memory data conforming to YAML schema. |
required |
user_id
|
str
|
Owner of the memory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Human-readable ID (HRID) for the created memory. |
Source code in src/memg_core/api/public.py
47 48 49 50 51 52 53 54 55 56 57 58 | |
add_relationship(from_memory_hrid, to_memory_hrid, relation_type, from_memory_type, to_memory_type, user_id, properties=None)
Add relationship between memories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_memory_hrid
|
str
|
Source memory HRID. |
required |
to_memory_hrid
|
str
|
Target memory HRID. |
required |
relation_type
|
str
|
Relationship type from YAML schema. |
required |
from_memory_type
|
str
|
Source memory entity type. |
required |
to_memory_type
|
str
|
Target memory entity type. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
properties
|
dict[str, Any] | None
|
Optional relationship properties. |
None
|
Source code in src/memg_core/api/public.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
close()
Close client and cleanup resources.
Should be called when the client is no longer needed to free database connections.
Source code in src/memg_core/api/public.py
261 262 263 264 265 266 267 | |
delete_memory(hrid, user_id, memory_type=None)
Delete memory by HRID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable ID of the memory to delete. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded, False otherwise. |
Source code in src/memg_core/api/public.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
delete_relationship(from_memory_hrid, to_memory_hrid, relation_type, from_memory_type=None, to_memory_type=None, user_id=None)
Delete relationship between memories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_memory_hrid
|
str
|
Source memory HRID. |
required |
to_memory_hrid
|
str
|
Target memory HRID. |
required |
relation_type
|
str
|
Relationship type from YAML schema. |
required |
from_memory_type
|
str | None
|
Source memory entity type (inferred from HRID if not provided). |
None
|
to_memory_type
|
str | None
|
Target memory entity type (inferred from HRID if not provided). |
None
|
user_id
|
str | None
|
User ID for ownership verification (required). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded, False if relationship not found. |
Source code in src/memg_core/api/public.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
get_memories(user_id, memory_type=None, filters=None, limit=50, offset=0, include_neighbors=False, hops=1)
Get multiple memories with filtering and optional graph expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type filter (e.g., "task", "note"). |
None
|
filters
|
dict[str, Any] | None
|
Optional field filters (e.g., {"status": "open", "priority": "high"}). |
None
|
limit
|
int
|
Maximum number of memories to return (default 50). |
50
|
offset
|
int
|
Number of memories to skip for pagination (default 0). |
0
|
include_neighbors
|
bool
|
Whether to include neighbor nodes via graph traversal. |
False
|
hops
|
int
|
Number of hops for neighbor expansion (default 1). |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
SearchResult |
SearchResult
|
SearchResult with memories as seeds and optional neighbors. |
Source code in src/memg_core/api/public.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
get_memory(hrid, user_id, memory_type=None, include_neighbors=False, hops=1, relation_types=None, neighbor_limit=5)
Get a single memory by HRID with optional neighbor expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable identifier of the memory. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint (inferred from HRID if not provided). |
None
|
include_neighbors
|
bool
|
Whether to include neighbor nodes via graph traversal. |
False
|
hops
|
int
|
Number of hops for neighbor expansion (default 1). |
1
|
relation_types
|
list[str] | None
|
Filter by specific relationship types (None = all relations). |
None
|
neighbor_limit
|
int
|
Maximum neighbors to return per hop (default 5). |
5
|
Returns:
| Type | Description |
|---|---|
SearchResult | None
|
SearchResult | None: SearchResult with single memory as seed and optional neighbors, or None if not found. |
Source code in src/memg_core/api/public.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
search(query, user_id, memory_type=None, limit=10, score_threshold=None, decay_rate=None, decay_threshold=None, datetime_format=None, **kwargs)
Search memories with explicit seed/neighbor separation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text to search for. |
required |
user_id
|
str
|
User ID for filtering results. |
required |
memory_type
|
str | None
|
Optional memory type filter. |
None
|
limit
|
int
|
Maximum number of results to return. |
10
|
score_threshold
|
float | None
|
Minimum similarity score threshold (0.0-1.0). |
None
|
decay_rate
|
float | None
|
Score decay factor per hop (default: 1.0 = no decay). |
None
|
decay_threshold
|
float | None
|
Explicit neighbor score threshold (overrides decay_rate). |
None
|
datetime_format
|
str | None
|
Optional datetime format string (e.g., "%Y-%m-%d %H:%M:%S"). |
None
|
**kwargs
|
Additional search parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
SearchResult |
SearchResult
|
Search result with explicit seed/neighbor separation, including full payloads for seeds and relationships. |
Source code in src/memg_core/api/public.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
update_memory(hrid, payload_updates, user_id, memory_type=None)
Update memory with partial payload changes (patch-style update).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Memory HRID to update. |
required |
payload_updates
|
dict[str, Any]
|
Dictionary of fields to update (only changed fields). |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint (inferred from HRID if not provided). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if update succeeded, False otherwise. |
Source code in src/memg_core/api/public.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
MemoryService
Unified memory service - handles indexing, search, and deletion operations.
Provides a clean, class-based interface for all memory operations using DatabaseClients for both DDL initialization and CRUD interface access. Eliminates the need for scattered interface creation.
Attributes:
| Name | Type | Description |
|---|---|---|
qdrant |
Qdrant interface instance. |
|
kuzu |
Kuzu interface instance. |
|
embedder |
Embedder instance. |
|
yaml_translator |
YAML translator instance. |
|
hrid_tracker |
HRID tracker instance. |
Source code in src/memg_core/core/pipelines/indexer.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
__init__(db_clients)
Initialize MemoryService with DatabaseClients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_clients
|
DatabaseClients instance (after init_dbs() called). |
required |
Source code in src/memg_core/core/pipelines/indexer.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
add_memory(memory_type, payload, user_id)
Add a memory to both graph and vector storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_type
|
str
|
Entity type from YAML schema (e.g., 'task', 'note'). |
required |
payload
|
dict[str, Any]
|
Memory data conforming to YAML schema. |
required |
user_id
|
str
|
Owner of the memory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Memory HRID (Human-readable ID string). |
Raises:
| Type | Description |
|---|---|
ProcessingError
|
If validation fails or storage operations fail. |
Source code in src/memg_core/core/pipelines/indexer.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
add_relationship(from_memory_hrid, to_memory_hrid, relation_type, from_memory_type, to_memory_type, user_id, properties=None)
Add a relationship between two memories using HRIDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_memory_hrid
|
str
|
Source memory HRID. |
required |
to_memory_hrid
|
str
|
Target memory HRID. |
required |
relation_type
|
str
|
Relationship type from YAML schema (e.g., 'ANNOTATES'). |
required |
from_memory_type
|
str
|
Source memory entity type. |
required |
to_memory_type
|
str
|
Target memory entity type. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
properties
|
dict[str, Any] | None
|
Optional relationship properties. |
None
|
Raises:
| Type | Description |
|---|---|
ProcessingError
|
If relationship creation fails. |
Source code in src/memg_core/core/pipelines/indexer.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
delete_memory(memory_hrid, memory_type, user_id)
Delete a memory from both storages using HRID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_hrid
|
str
|
Memory HRID to delete. |
required |
memory_type
|
str
|
Memory entity type. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded. |
Source code in src/memg_core/core/pipelines/indexer.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
delete_relationship(from_memory_hrid, to_memory_hrid, relation_type, from_memory_type=None, to_memory_type=None, user_id=None)
Delete a relationship between two memories using HRIDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_memory_hrid
|
str
|
Source memory HRID. |
required |
to_memory_hrid
|
str
|
Target memory HRID. |
required |
relation_type
|
str
|
Relationship type from YAML schema (e.g., 'ANNOTATES'). |
required |
from_memory_type
|
str | None
|
Source memory entity type (inferred from HRID if not provided). |
None
|
to_memory_type
|
str | None
|
Target memory entity type (inferred from HRID if not provided). |
None
|
user_id
|
str | None
|
User ID for ownership verification (required). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded, False if relationship not found. |
Raises:
| Type | Description |
|---|---|
ProcessingError
|
If relationship deletion fails or parameters invalid. |
Source code in src/memg_core/core/pipelines/indexer.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
update_memory(hrid, payload_updates, user_id, memory_type=None)
Update memory with partial payload changes (patch-style update).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Memory HRID to update. |
required |
payload_updates
|
dict[str, Any]
|
Dictionary of fields to update (only changed fields). |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint (inferred from HRID if not provided). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if update succeeded. |
Raises:
| Type | Description |
|---|---|
ProcessingError
|
If update fails or memory not found. |
Source code in src/memg_core/core/pipelines/indexer.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
SearchResult
Bases: BaseModel
Search result with explicit seed/neighbor separation.
Attributes:
| Name | Type | Description |
|---|---|---|
memories |
list[MemorySeed]
|
List of memory seeds with full payloads and relationships. |
neighbors |
list[MemoryNeighbor]
|
List of memory neighbors with anchor-only payloads. |
Source code in src/memg_core/core/models.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
SearchService
Search orchestration service - coordinates specialized handlers for GraphRAG operations.
Clean orchestration layer that delegates to specialized handlers: - VectorSearchHandler: Qdrant vector search and seed generation - GraphExpansionHandler: Kuzu graph traversal and neighbor expansion - MemorySerializer: Memory object packing/unpacking and conversion - PayloadProjector: Payload filtering and projection
Attributes:
| Name | Type | Description |
|---|---|---|
vector_handler |
Handles vector search operations. |
|
graph_handler |
Handles graph expansion operations. |
|
memory_serializer |
Handles memory serialization and construction. |
|
payload_projector |
Handles payload projection. |
Source code in src/memg_core/core/pipelines/retrieval.py
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | |
__init__(db_clients)
Initialize SearchService with DatabaseClients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_clients
|
DatabaseClients instance (after init_dbs() called). |
required |
Source code in src/memg_core/core/pipelines/retrieval.py
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 | |
get_memories(user_id, memory_type=None, filters=None, limit=50, offset=0, include_neighbors=False, hops=1, datetime_format=None)
Get multiple memories with filtering and optional graph expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type filter (e.g., "task", "note"). |
None
|
filters
|
dict[str, Any] | None
|
Optional field filters (e.g., {"status": "open", "priority": "high"}). |
None
|
limit
|
int
|
Maximum number of memories to return (default 50). |
50
|
offset
|
int
|
Number of memories to skip for pagination (default 0). |
0
|
include_neighbors
|
bool
|
Whether to include neighbor nodes via graph traversal. |
False
|
hops
|
int
|
Number of hops for neighbor expansion (default 1). |
1
|
datetime_format
|
str | None
|
Optional datetime format string. If None, uses YAML schema default. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SearchResult |
SearchResult
|
SearchResult with memories as seeds and optional neighbors. |
Source code in src/memg_core/core/pipelines/retrieval.py
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | |
get_memory(hrid, user_id, memory_type=None, include_neighbors=False, hops=1, relation_types=None, neighbor_limit=5, datetime_format=None)
Get a single memory by HRID with optional neighbor expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable identifier of the memory. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint (inferred from HRID if not provided). |
None
|
include_neighbors
|
bool
|
Whether to include neighbor nodes via graph traversal. |
False
|
hops
|
int
|
Number of hops for neighbor expansion (default 1). |
1
|
relation_types
|
list[str] | None
|
Filter by specific relationship types (None = all relations). |
None
|
neighbor_limit
|
int
|
Maximum neighbors to return per hop (default 5). |
5
|
datetime_format
|
str | None
|
Optional datetime format string. If None, uses YAML schema default. |
None
|
Returns:
| Type | Description |
|---|---|
SearchResult | None
|
SearchResult | None: SearchResult with single memory as seed and optional neighbors, or None if not found. |
Source code in src/memg_core/core/pipelines/retrieval.py
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | |
search(query, user_id, limit=5, *, memory_type=None, relation_names=None, neighbor_limit=5, hops=1, include_details='self', modified_within_days=None, filters=None, projection=None, score_threshold=None, decay_rate=None, decay_threshold=None, datetime_format=None)
GraphRAG search orchestration: vector seeds → graph expansion → result composition.
Pure orchestration method that delegates to specialized handlers for clean separation of concerns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query text (required). |
required |
user_id
|
str
|
User ID for filtering (required). |
required |
limit
|
int
|
Maximum results to return (default: 5). |
5
|
memory_type
|
str | None
|
Optional memory type filter. |
None
|
relation_names
|
list[str] | None
|
Specific relations to expand (None = all relations). |
None
|
neighbor_limit
|
int
|
Max neighbors per seed (default: 5). |
5
|
hops
|
int
|
Number of graph hops to expand (default: 1). |
1
|
include_details
|
str
|
"self" (full payload for seeds, anchor only for neighbors), "all" (full payload for both), or "none" (anchor only for both). |
'self'
|
modified_within_days
|
int | None
|
Filter by recency (e.g., last 7 days). |
None
|
filters
|
dict[str, Any] | None
|
Custom field-based filtering (e.g., {"project": "memg-core"}). |
None
|
projection
|
dict[str, list[str]] | None
|
Control which fields to return per memory type. |
None
|
score_threshold
|
float | None
|
Minimum similarity score threshold (0.0-1.0). |
None
|
decay_rate
|
float | None
|
Score decay factor per hop (default: 1.0 = no decay). |
None
|
decay_threshold
|
float | None
|
Explicit neighbor score threshold (overrides decay_rate). |
None
|
datetime_format
|
str | None
|
Optional datetime format string. If None, uses YAML schema default. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SearchResult |
SearchResult
|
Search result with explicit seed/neighbor separation. |
Source code in src/memg_core/core/pipelines/retrieval.py
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | |
YamlTranslator
Translates YAML schema definitions to Pydantic models for strict validation.
Attributes:
| Name | Type | Description |
|---|---|---|
yaml_path |
Path to YAML schema file. |
|
_schema |
dict[str, Any] | None
|
Cached schema dictionary. |
Source code in src/memg_core/core/yaml_translator.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | |
schema
property
Get the loaded YAML schema, loading it if necessary.
__init__(yaml_path=None)
Initialize YamlTranslator with YAML schema path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
str | None
|
Path to YAML schema file. If None, uses MEMG_YAML_SCHEMA env var. |
None
|
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If YAML path not provided or TypeRegistry initialization fails. |
Source code in src/memg_core/core/yaml_translator.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
build_anchor_text(memory)
Build anchor text for embedding from YAML-defined anchor field.
NO hardcoded field names - reads anchor field from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
Memory object containing payload data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Anchor text for embedding. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If anchor field is missing or invalid. |
Source code in src/memg_core/core/yaml_translator.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
create_memory_from_yaml(memory_type, payload, user_id)
Create a Memory object from YAML-validated payload.
Source code in src/memg_core/core/yaml_translator.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
debug_relation_map()
Return a nested relation map for debugging/printing.
Structure: { source: { target: [ {name, predicate, directed, description} ... ] } }
Source code in src/memg_core/core/yaml_translator.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
get_anchor_field(entity_name)
Get the anchor field name for the given entity type from YAML schema.
Now reads from vector.anchored_to instead of separate anchor field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Name of the entity type. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Anchor field name. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If anchor field not found. |
Source code in src/memg_core/core/yaml_translator.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
get_default_datetime_format()
Get the default datetime format from YAML schema.
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Datetime format string from schema defaults, or None if not set. |
Source code in src/memg_core/core/yaml_translator.py
360 361 362 363 364 365 366 367 368 | |
get_display_field_name(entity_name)
Get the field name to use for display from YAML schema override section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Field name to use for display, or anchor field if no override. |
Source code in src/memg_core/core/yaml_translator.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
get_display_text(memory)
Get display text for a memory, using YAML-defined display field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
Memory object containing payload data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Display text for the memory. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If display field is missing or invalid. |
Source code in src/memg_core/core/yaml_translator.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
get_entity_model(entity_name)
Get Pydantic model from TypeRegistry - NO REDUNDANCY.
Source code in src/memg_core/core/yaml_translator.py
681 682 683 | |
get_entity_types()
Get list of available entity types from YAML schema.
Source code in src/memg_core/core/yaml_translator.py
123 124 125 | |
get_exclude_display_fields(entity_name)
Get the list of fields that should never be displayed from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of field names to always exclude from display. |
Source code in src/memg_core/core/yaml_translator.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
get_force_display_fields(entity_name)
Get the list of fields that should always be displayed from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of field names to always include in display. |
Source code in src/memg_core/core/yaml_translator.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
get_relations_for_source(entity_name)
Get normalized relation specs for a source entity in target-first schema.
Returns list of dicts with keys
- source (str)
- target (str)
- name (str | None)
- description (str | None)
- predicate (str)
- directed (bool)
Source code in src/memg_core/core/yaml_translator.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
get_see_also_config(entity_name)
Get the see_also configuration for the given entity type from YAML schema.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Dict with keys: enabled, threshold, limit, target_types |
dict[str, Any] | None
|
None if see_also is not configured for this entity |
Source code in src/memg_core/core/yaml_translator.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
validate_memory_against_yaml(memory_type, payload)
Validate memory payload against YAML schema and return cleaned payload.
Source code in src/memg_core/core/yaml_translator.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
_get_client()
Get or create singleton client from environment variables.
Returns:
| Name | Type | Description |
|---|---|---|
MemgClient |
MemgClient
|
Singleton client instance. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If required environment variables are not set. |
Source code in src/memg_core/api/public.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
add_memory(memory_type, payload, user_id)
Add memory using environment-based client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_type
|
str
|
Entity type from YAML schema (e.g., 'task', 'note'). |
required |
payload
|
dict[str, Any]
|
Memory data conforming to YAML schema. |
required |
user_id
|
str
|
Owner of the memory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Human-readable ID (HRID) for the created memory. |
Source code in src/memg_core/api/public.py
296 297 298 299 300 301 302 303 304 305 306 307 | |
add_relationship(from_memory_hrid, to_memory_hrid, relation_type, from_memory_type, to_memory_type, user_id, properties=None)
Add relationship using environment-based client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_memory_hrid
|
str
|
Source memory HRID. |
required |
to_memory_hrid
|
str
|
Target memory HRID. |
required |
relation_type
|
str
|
Relationship type from YAML schema. |
required |
from_memory_type
|
str
|
Source memory entity type. |
required |
to_memory_type
|
str
|
Target memory entity type. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
properties
|
dict[str, Any] | None
|
Optional relationship properties. |
None
|
Source code in src/memg_core/api/public.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
create_memory_service(db_clients)
Factory function to create a MemoryService instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_clients
|
DatabaseClients instance (after init_dbs() called). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MemoryService |
MemoryService
|
Configured MemoryService instance. |
Source code in src/memg_core/core/pipelines/indexer.py
417 418 419 420 421 422 423 424 425 426 | |
create_search_service(db_clients)
Factory function to create a SearchService instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_clients
|
DatabaseClients instance (after init_dbs() called). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SearchService |
SearchService
|
Configured SearchService instance. |
Source code in src/memg_core/core/pipelines/retrieval.py
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | |
delete_memory(hrid, user_id, memory_type=None)
Delete memory using environment-based client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable ID of the memory to delete. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded, False otherwise. |
Source code in src/memg_core/api/public.py
351 352 353 354 355 356 357 358 359 360 361 362 | |
delete_relationship(from_memory_hrid, to_memory_hrid, relation_type, from_memory_type=None, to_memory_type=None, user_id=None)
Delete relationship using environment-based client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_memory_hrid
|
str
|
Source memory HRID. |
required |
to_memory_hrid
|
str
|
Target memory HRID. |
required |
relation_type
|
str
|
Relationship type from YAML schema. |
required |
from_memory_type
|
str | None
|
Source memory entity type (inferred from HRID if not provided). |
None
|
to_memory_type
|
str | None
|
Target memory entity type (inferred from HRID if not provided). |
None
|
user_id
|
str | None
|
User ID for ownership verification (required). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded, False if relationship not found. |
Source code in src/memg_core/api/public.py
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
get_config()
Get system configuration, preferring environment variables.
Returns:
| Name | Type | Description |
|---|---|---|
MemorySystemConfig |
MemorySystemConfig
|
System configuration instance. |
Source code in src/memg_core/core/config.py
174 175 176 177 178 179 180 | |
get_memories(user_id, memory_type=None, filters=None, limit=50, offset=0, include_neighbors=False, hops=1)
Get memories using environment-based client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type filter (e.g., "task", "note"). |
None
|
filters
|
dict[str, Any] | None
|
Optional field filters (e.g., {"status": "open", "priority": "high"}). |
None
|
limit
|
int
|
Maximum number of memories to return (default 50). |
50
|
offset
|
int
|
Number of memories to skip for pagination (default 0). |
0
|
include_neighbors
|
bool
|
Whether to include neighbor nodes via graph traversal. |
False
|
hops
|
int
|
Number of hops for neighbor expansion (default 1). |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
SearchResult |
SearchResult
|
SearchResult with memories as seeds and optional neighbors. |
Source code in src/memg_core/api/public.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
get_memory(hrid, user_id, memory_type=None, include_neighbors=False, hops=1, relation_types=None, neighbor_limit=5)
Get memory using environment-based client with optional neighbor expansion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable identifier of the memory. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint (inferred from HRID if not provided). |
None
|
include_neighbors
|
bool
|
Whether to include neighbor nodes via graph traversal. |
False
|
hops
|
int
|
Number of hops for neighbor expansion (default 1). |
1
|
relation_types
|
list[str] | None
|
Filter by specific relationship types (None = all relations). |
None
|
neighbor_limit
|
int
|
Maximum neighbors to return per hop (default 5). |
5
|
Returns:
| Type | Description |
|---|---|
SearchResult | None
|
SearchResult | None: SearchResult with single memory as seed and optional neighbors, or None if not found. |
Source code in src/memg_core/api/public.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |
get_services()
Get services from singleton client (MCP server compatibility).
Returns:
| Type | Description |
|---|---|
tuple[MemoryService, SearchService, YamlTranslator]
|
tuple[MemoryService, SearchService, YamlTranslator]: Service instances for direct access. |
Source code in src/memg_core/api/public.py
515 516 517 518 519 520 521 522 523 | |
search(query, user_id, memory_type=None, limit=10, score_threshold=None, decay_rate=None, decay_threshold=None, datetime_format=None, **kwargs)
Search memories using environment-based client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Text to search for. |
required |
user_id
|
str
|
User ID for filtering results. |
required |
memory_type
|
str | None
|
Optional memory type filter. |
None
|
limit
|
int
|
Maximum number of results to return. |
10
|
score_threshold
|
float | None
|
Minimum similarity score threshold (0.0-1.0). |
None
|
decay_rate
|
float | None
|
Score decay factor per hop (default: 1.0 = no decay). |
None
|
decay_threshold
|
float | None
|
Explicit neighbor score threshold (overrides decay_rate). |
None
|
datetime_format
|
str | None
|
Optional datetime format string (e.g., "%Y-%m-%d %H:%M:%S"). |
None
|
**kwargs
|
Additional search parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
SearchResult |
SearchResult
|
Search result with explicit seed/neighbor separation, including full payloads for seeds and relationships. |
Source code in src/memg_core/api/public.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
shutdown_services()
Shutdown singleton client.
Closes database connections and cleans up resources.
Source code in src/memg_core/api/public.py
503 504 505 506 507 508 509 510 511 | |
update_memory(hrid, payload_updates, user_id, memory_type=None)
Update memory using environment-based client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Memory HRID to update. |
required |
payload_updates
|
dict[str, Any]
|
Dictionary of fields to update (only changed fields). |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
memory_type
|
str | None
|
Optional memory type hint (inferred from HRID if not provided). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if update succeeded, False otherwise. |
Source code in src/memg_core/api/public.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
Core Models
Core data models and types:
Core models for the memory system.
_MAX_SCORE_TOLERANCE = 1.001
module-attribute
Memory
Bases: BaseModel
Core memory model with YAML-driven payload validation.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier (UUID or HRID). |
user_id |
str
|
Owner of the memory. |
memory_type |
str
|
Entity type from YAML schema. |
payload |
dict[str, Any]
|
Entity-specific fields. |
vector |
list[float] | None
|
Embedding vector. |
created_at |
datetime
|
Creation timestamp. |
updated_at |
datetime | None
|
Last update timestamp. |
hrid |
str | None
|
Human-readable identifier. |
Source code in src/memg_core/core/models.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
__getattr__(item)
Dynamic attribute access for YAML-defined payload fields ONLY.
No fallback logic, no backward compatibility. If the field is not in the payload dictionary, raises AttributeError immediately. This enforces strict YAML schema compliance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
str
|
Field name to access. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Field value from payload. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If field is not in payload. |
Source code in src/memg_core/core/models.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
memory_type_not_empty(v)
classmethod
Validate that memory_type is not empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str
|
Memory type value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Stripped memory type. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If memory_type is empty or whitespace. |
Source code in src/memg_core/core/models.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
to_entity_model()
Project this Memory into a dynamic Pydantic entity model.
Returns an instance of the auto-generated model class that matches the entity type defined in the YAML schema. Only non-system fields are included.
Returns:
| Name | Type | Description |
|---|---|---|
BaseModel |
Dynamic Pydantic model instance. |
Source code in src/memg_core/core/models.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
MemoryNeighbor
Bases: BaseModel
Memory neighbor with configurable payload detail level.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
str
|
Owner of the memory. |
hrid |
str
|
Human-readable identifier. |
memory_type |
str
|
Entity type from YAML schema. |
created_at |
datetime | str
|
Creation timestamp (datetime or formatted string). |
updated_at |
datetime | str | None
|
Last update timestamp (datetime or formatted string). |
payload |
dict[str, Any]
|
Payload with detail level based on include_details setting. |
score |
float
|
Recursive relevance score (seed_score × neighbor_similarity). |
Source code in src/memg_core/core/models.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
MemoryPoint
Bases: BaseModel
Memory with embedding vector for Qdrant.
Attributes:
| Name | Type | Description |
|---|---|---|
memory |
Memory
|
Memory instance. |
vector |
list[float]
|
Embedding vector. |
point_id |
str | None
|
Qdrant point ID. |
Source code in src/memg_core/core/models.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
vector_not_empty(v)
classmethod
Validate that vector is not empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Vector to validate. |
required |
Returns:
| Type | Description |
|---|---|
|
list[float]: Validated vector. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If vector is empty. |
Source code in src/memg_core/core/models.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
MemorySeed
Bases: BaseModel
Memory seed with full payload and explicit relationships.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
str
|
Owner of the memory. |
hrid |
str
|
Human-readable identifier. |
memory_type |
str
|
Entity type from YAML schema. |
created_at |
datetime | str
|
Creation timestamp (datetime or formatted string). |
updated_at |
datetime | str | None
|
Last update timestamp (datetime or formatted string). |
payload |
dict[str, Any]
|
Full entity payload. |
score |
float
|
Vector similarity score to query. |
relationships |
list[RelationshipInfo]
|
List of relationships to other memories. |
Source code in src/memg_core/core/models.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
normalize_score(v)
classmethod
Normalize similarity scores to handle floating-point precision errors.
Source code in src/memg_core/core/models.py
192 193 194 195 196 197 198 199 200 | |
ProcessingResult
Bases: BaseModel
Result from memory processing pipelines - type-agnostic.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Whether processing succeeded. |
memories_created |
list[Memory]
|
List of created memories. |
errors |
list[str]
|
List of error messages. |
processing_time_ms |
float | None
|
Processing time in milliseconds. |
Source code in src/memg_core/core/models.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
total_created
property
Total memories created (all types).
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of memories created. |
RelationshipInfo
Bases: BaseModel
Relationship information between memories.
Attributes:
| Name | Type | Description |
|---|---|---|
relation_type |
str
|
Type of relationship (e.g., FIXES, ADDRESSES). |
target_hrid |
str
|
HRID of the target memory. |
score |
float
|
Relationship relevance score with natural decay. |
relationships |
list[RelationshipInfo]
|
Nested relationships for multi-hop expansion. |
Source code in src/memg_core/core/models.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
SearchResult
Bases: BaseModel
Search result with explicit seed/neighbor separation.
Attributes:
| Name | Type | Description |
|---|---|---|
memories |
list[MemorySeed]
|
List of memory seeds with full payloads and relationships. |
neighbors |
list[MemoryNeighbor]
|
List of memory neighbors with anchor-only payloads. |
Source code in src/memg_core/core/models.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
get_entity_model(entity_name)
Get Pydantic model for entity from global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Name of the entity. |
required |
Returns:
| Type | Description |
|---|---|
type[BaseModel]
|
type[BaseModel]: Pydantic model class. |
Source code in src/memg_core/core/types.py
434 435 436 437 438 439 440 441 442 443 | |
Configuration
Configuration management:
Memory System Configuration - minimal and essential settings
DEFAULT_MEMG_CONFIG = MemGConfig()
module-attribute
DEFAULT_SYSTEM_CONFIG = MemorySystemConfig()
module-attribute
MemGConfig
dataclass
Core memory system configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
similarity_threshold |
float
|
Threshold for conflict detection (0.0-1.0). |
score_threshold |
float
|
Minimum score for search results (0.0-1.0). |
high_similarity_threshold |
float
|
Threshold for duplicate detection (0.0-1.0). |
decay_rate |
float
|
Graph traversal decay rate per hop (0.0-1.0). |
decay_threshold |
float
|
Minimum neighbor relevance threshold (0.0-1.0). |
enable_ai_type_verification |
bool
|
Enable AI-based type detection. |
enable_temporal_reasoning |
bool
|
Enable temporal reasoning. |
vector_dimension |
int
|
Embedding dimension size. |
batch_processing_size |
int
|
Batch size for bulk operations. |
embedder_model |
str
|
FastEmbed model name. |
template_name |
str
|
Active template name. |
qdrant_collection_name |
str
|
Qdrant collection name. |
kuzu_database_path |
str
|
Kuzu database path. |
Source code in src/memg_core/core/config.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
__post_init__()
Validate configuration parameters.
Raises:
| Type | Description |
|---|---|
ValueError
|
If any threshold values are outside valid range [0.0, 1.0]. |
Source code in src/memg_core/core/config.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
from_dict(config_dict)
classmethod
Create configuration from dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_dict
|
dict[str, Any]
|
Dictionary containing configuration values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MemGConfig |
MemGConfig
|
Configuration instance. |
Source code in src/memg_core/core/config.py
89 90 91 92 93 94 95 96 97 98 99 | |
from_env()
classmethod
Create configuration from environment variables.
Each instance should use explicit environment variables for isolation. The core memory system doesn't know or care about server ports.
Returns:
| Name | Type | Description |
|---|---|---|
MemGConfig |
MemGConfig
|
Configuration instance with environment-derived values. |
Source code in src/memg_core/core/config.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
to_dict()
Convert configuration to dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Dictionary representation of configuration. |
Source code in src/memg_core/core/config.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
MemorySystemConfig
dataclass
Core memory system configuration - NO SERVER CONCERNS.
Attributes:
| Name | Type | Description |
|---|---|---|
memg |
MemGConfig
|
Core memory configuration instance. |
debug_mode |
bool
|
Enable debug mode. |
log_level |
str
|
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL). |
Source code in src/memg_core/core/config.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
__post_init__()
Validate core system configuration.
Raises:
| Type | Description |
|---|---|
ValueError
|
If log_level is not a valid logging level. |
Source code in src/memg_core/core/config.py
146 147 148 149 150 151 152 153 | |
from_env()
classmethod
Create core memory system configuration from environment variables.
Returns:
| Name | Type | Description |
|---|---|---|
MemorySystemConfig |
MemorySystemConfig
|
Configuration instance with environment-derived values. |
Source code in src/memg_core/core/config.py
155 156 157 158 159 160 161 162 163 164 165 166 | |
get_config()
Get system configuration, preferring environment variables.
Returns:
| Name | Type | Description |
|---|---|---|
MemorySystemConfig |
MemorySystemConfig
|
System configuration instance. |
Source code in src/memg_core/core/config.py
174 175 176 177 178 179 180 | |
Exceptions
Exception classes:
Custom exception hierarchy for the memory system - minimal set.
ConfigurationError
Bases: MemorySystemError
Configuration-related errors (env vars, validation).
Source code in src/memg_core/core/exceptions.py
38 39 | |
DatabaseError
Bases: MemorySystemError
Database operation failures (Qdrant, Kuzu).
Source code in src/memg_core/core/exceptions.py
42 43 | |
MemorySystemError
Bases: Exception
Base exception for all memory system errors.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Error message. |
|
operation |
Operation that caused the error. |
|
context |
Additional context information. |
|
original_error |
Original exception that was wrapped. |
Source code in src/memg_core/core/exceptions.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
ProcessingError
Bases: MemorySystemError
Memory processing operation failures (catch-all for processing).
Source code in src/memg_core/core/exceptions.py
50 51 | |
ValidationError
Bases: MemorySystemError
Data validation failures (schema, input format).
Source code in src/memg_core/core/exceptions.py
46 47 | |
handle_with_context(operation)
Decorator for consistent error handling with context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Operation name for error context. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
callable |
Decorated function with error handling. |
Source code in src/memg_core/core/exceptions.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
wrap_exception(original_error, operation, context=None)
Wrap a generic exception in an appropriate MemorySystemError subclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original_error
|
Exception
|
Original exception to wrap. |
required |
operation
|
str
|
Operation that caused the error. |
required |
context
|
dict[str, Any] | None
|
Additional context information. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MemorySystemError |
MemorySystemError
|
Wrapped exception with appropriate subclass. |
Source code in src/memg_core/core/exceptions.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
YAML Schema
YAML schema handling:
YAML Translator: validates payloads using TypeRegistry and resolves anchor text.
STRICT YAML-FIRST: This module enforces the single-YAML-orchestrates-everything principle. NO flexibility, NO migration support, NO fallbacks.
Uses TypeRegistry as SINGLE SOURCE OF TRUTH for all entity definitions. All type building and validation delegated to TypeRegistry - zero redundancy.
Memory
Bases: BaseModel
Core memory model with YAML-driven payload validation.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier (UUID or HRID). |
user_id |
str
|
Owner of the memory. |
memory_type |
str
|
Entity type from YAML schema. |
payload |
dict[str, Any]
|
Entity-specific fields. |
vector |
list[float] | None
|
Embedding vector. |
created_at |
datetime
|
Creation timestamp. |
updated_at |
datetime | None
|
Last update timestamp. |
hrid |
str | None
|
Human-readable identifier. |
Source code in src/memg_core/core/models.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
__getattr__(item)
Dynamic attribute access for YAML-defined payload fields ONLY.
No fallback logic, no backward compatibility. If the field is not in the payload dictionary, raises AttributeError immediately. This enforces strict YAML schema compliance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
str
|
Field name to access. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Field value from payload. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If field is not in payload. |
Source code in src/memg_core/core/models.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
memory_type_not_empty(v)
classmethod
Validate that memory_type is not empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str
|
Memory type value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Stripped memory type. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If memory_type is empty or whitespace. |
Source code in src/memg_core/core/models.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
to_entity_model()
Project this Memory into a dynamic Pydantic entity model.
Returns an instance of the auto-generated model class that matches the entity type defined in the YAML schema. Only non-system fields are included.
Returns:
| Name | Type | Description |
|---|---|---|
BaseModel |
Dynamic Pydantic model instance. |
Source code in src/memg_core/core/models.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
MemorySystemError
Bases: Exception
Base exception for all memory system errors.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Error message. |
|
operation |
Operation that caused the error. |
|
context |
Additional context information. |
|
original_error |
Original exception that was wrapped. |
Source code in src/memg_core/core/exceptions.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
YamlTranslator
Translates YAML schema definitions to Pydantic models for strict validation.
Attributes:
| Name | Type | Description |
|---|---|---|
yaml_path |
Path to YAML schema file. |
|
_schema |
dict[str, Any] | None
|
Cached schema dictionary. |
Source code in src/memg_core/core/yaml_translator.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | |
schema
property
Get the loaded YAML schema, loading it if necessary.
__init__(yaml_path=None)
Initialize YamlTranslator with YAML schema path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
str | None
|
Path to YAML schema file. If None, uses MEMG_YAML_SCHEMA env var. |
None
|
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If YAML path not provided or TypeRegistry initialization fails. |
Source code in src/memg_core/core/yaml_translator.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
build_anchor_text(memory)
Build anchor text for embedding from YAML-defined anchor field.
NO hardcoded field names - reads anchor field from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
Memory object containing payload data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Anchor text for embedding. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If anchor field is missing or invalid. |
Source code in src/memg_core/core/yaml_translator.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
create_memory_from_yaml(memory_type, payload, user_id)
Create a Memory object from YAML-validated payload.
Source code in src/memg_core/core/yaml_translator.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
debug_relation_map()
Return a nested relation map for debugging/printing.
Structure: { source: { target: [ {name, predicate, directed, description} ... ] } }
Source code in src/memg_core/core/yaml_translator.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
get_anchor_field(entity_name)
Get the anchor field name for the given entity type from YAML schema.
Now reads from vector.anchored_to instead of separate anchor field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Name of the entity type. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Anchor field name. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If anchor field not found. |
Source code in src/memg_core/core/yaml_translator.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
get_default_datetime_format()
Get the default datetime format from YAML schema.
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Datetime format string from schema defaults, or None if not set. |
Source code in src/memg_core/core/yaml_translator.py
360 361 362 363 364 365 366 367 368 | |
get_display_field_name(entity_name)
Get the field name to use for display from YAML schema override section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Field name to use for display, or anchor field if no override. |
Source code in src/memg_core/core/yaml_translator.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
get_display_text(memory)
Get display text for a memory, using YAML-defined display field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
Memory object containing payload data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Display text for the memory. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If display field is missing or invalid. |
Source code in src/memg_core/core/yaml_translator.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
get_entity_model(entity_name)
Get Pydantic model from TypeRegistry - NO REDUNDANCY.
Source code in src/memg_core/core/yaml_translator.py
681 682 683 | |
get_entity_types()
Get list of available entity types from YAML schema.
Source code in src/memg_core/core/yaml_translator.py
123 124 125 | |
get_exclude_display_fields(entity_name)
Get the list of fields that should never be displayed from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of field names to always exclude from display. |
Source code in src/memg_core/core/yaml_translator.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
get_force_display_fields(entity_name)
Get the list of fields that should always be displayed from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of field names to always include in display. |
Source code in src/memg_core/core/yaml_translator.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
get_relations_for_source(entity_name)
Get normalized relation specs for a source entity in target-first schema.
Returns list of dicts with keys
- source (str)
- target (str)
- name (str | None)
- description (str | None)
- predicate (str)
- directed (bool)
Source code in src/memg_core/core/yaml_translator.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
get_see_also_config(entity_name)
Get the see_also configuration for the given entity type from YAML schema.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Dict with keys: enabled, threshold, limit, target_types |
dict[str, Any] | None
|
None if see_also is not configured for this entity |
Source code in src/memg_core/core/yaml_translator.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
validate_memory_against_yaml(memory_type, payload)
Validate memory payload against YAML schema and return cleaned payload.
Source code in src/memg_core/core/yaml_translator.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
YamlTranslatorError
Bases: MemorySystemError
Error in YAML schema translation or validation.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Error message. |
|
operation |
Operation that caused the error. |
|
context |
Additional context information. |
|
original_error |
Original exception that was wrapped. |
Source code in src/memg_core/core/yaml_translator.py
23 24 25 26 27 28 29 30 31 | |
get_entity_model(entity_name)
Get Pydantic model for entity from global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Name of the entity. |
required |
Returns:
| Type | Description |
|---|---|
type[BaseModel]
|
type[BaseModel]: Pydantic model class. |
Source code in src/memg_core/core/types.py
434 435 436 437 438 439 440 441 442 443 | |
initialize_types_from_yaml(yaml_path)
Initialize global type registry from YAML - call once at startup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
str
|
Path to YAML schema file. |
required |
Source code in src/memg_core/core/types.py
470 471 472 473 474 475 476 | |
Utilities
HRID Management
Human-readable ID utilities:
HRID generator and parser for MEMG Core.
Format: {TYPE_UPPER}_{AAA000} - TYPE: uppercase alphanumeric type name (no spaces) - AAA: base26 letters A–Z (wraps after ZZZ) - 000–999: numeric suffix
_COUNTERS = {}
module-attribute
_HRID_RE = re.compile('^(?P<type>[A-Z0-9_]+)_(?P<alpha>[A-Z]{3})(?P<num>\\d{3})$')
module-attribute
DatabaseError
Bases: MemorySystemError
Database operation failures (Qdrant, Kuzu).
Source code in src/memg_core/core/exceptions.py
42 43 | |
_alpha_to_idx(alpha)
Convert alpha string to index: AAA -> 0, AAB -> 1, ..., ZZZ -> 17575.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
str
|
Three-letter alpha string (AAA-ZZZ). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Numeric index. |
Source code in src/memg_core/utils/hrid.py
22 23 24 25 26 27 28 29 30 31 32 33 34 | |
_idx_to_alpha(idx)
Convert index to alpha string: 0 -> AAA, 1 -> AAB, ..., 17575 -> ZZZ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
Numeric index (0-17575). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Three-letter alpha string. |
Source code in src/memg_core/utils/hrid.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
_initialize_counter_from_tracker(type_name, user_id, hrid_tracker)
Initialize counter by querying HridTracker for highest existing HRID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_name
|
str
|
The memory type to check (e.g., 'note', 'task') |
required |
user_id
|
str
|
User ID for scoped HRID lookup |
required |
hrid_tracker
|
HridTracker instance to query |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
tuple[int, int]: (alpha_idx, num) representing the next available counter position |
Source code in src/memg_core/utils/hrid.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
generate_hrid(type_name, user_id, hrid_tracker=None)
Generate the next HRID for the given type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_name
|
str
|
The memory type (e.g., 'note', 'task'). |
required |
user_id
|
str
|
User ID for scoped HRID generation. |
required |
hrid_tracker
|
Optional HridTracker instance for querying existing HRIDs. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The next HRID in format TYPE_AAA000. |
Notes
- Uses HridTracker to query HridMapping table for existing HRIDs.
- Falls back to in-memory counter if no tracker provided.
- Ensures no duplicates by checking complete HRID history.
Source code in src/memg_core/utils/hrid.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
parse_hrid(hrid)
Parse HRID into (type, alpha, num).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
HRID string to parse. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str, int]
|
tuple[str, str, int]: (type, alpha, num) components. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If HRID format is invalid. |
Source code in src/memg_core/utils/hrid.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
HRID Tracker: UUID ↔ HRID translation and lifecycle management.
Handles all HRID mapping operations using the existing KuzuInterface. Provides transparent translation between user-facing HRIDs and internal UUIDs.
DatabaseError
Bases: MemorySystemError
Database operation failures (Qdrant, Kuzu).
Source code in src/memg_core/core/exceptions.py
42 43 | |
HridTracker
Manages HRID ↔ UUID mappings using KuzuInterface.
Attributes:
| Name | Type | Description |
|---|---|---|
kuzu |
Pre-configured Kuzu interface for database operations. |
Source code in src/memg_core/utils/hrid_tracker.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
__init__(kuzu_interface)
Initialize with existing KuzuInterface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kuzu_interface
|
KuzuInterface
|
Pre-configured Kuzu interface for database operations. |
required |
Source code in src/memg_core/utils/hrid_tracker.py
23 24 25 26 27 28 29 | |
create_mapping(hrid, uuid, memory_type, user_id)
Create new HRID ↔ UUID mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable ID. |
required |
uuid
|
str
|
Internal UUID. |
required |
memory_type
|
str
|
Entity type (e.g., 'task', 'note'). |
required |
user_id
|
str
|
User ID for scoped mapping. |
required |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If mapping creation fails. |
Source code in src/memg_core/utils/hrid_tracker.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
exists(hrid)
Check if HRID exists (active, not deleted).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable ID to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if HRID exists and is active. |
Source code in src/memg_core/utils/hrid_tracker.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
get_highest_hrid(memory_type, user_id)
Get highest HRID for a memory type (for generation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_type
|
str
|
Entity type to check (case insensitive). |
required |
user_id
|
str
|
User ID for scoped HRID lookup. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, int, int] | None
|
tuple[str, int, int] | None: (hrid, alpha_idx, num) or None if no HRIDs exist. |
Source code in src/memg_core/utils/hrid_tracker.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
get_hrid(uuid, user_id)
Translate UUID to HRID with user verification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
str
|
Internal UUID. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Human-readable ID string. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If UUID not found, deleted, or doesn't belong to user. |
Source code in src/memg_core/utils/hrid_tracker.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_uuid(hrid, user_id)
Translate HRID to UUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable ID (e.g., 'TASK_AAA001'). |
required |
user_id
|
str
|
User ID for scoped lookup. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
UUID string for internal operations. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If HRID not found or is deleted. |
Source code in src/memg_core/utils/hrid_tracker.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
mark_deleted(hrid)
Mark HRID mapping as deleted (soft delete)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
Human-readable ID to mark as deleted |
required |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If marking as deleted fails |
Source code in src/memg_core/utils/hrid_tracker.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
KuzuInterface
Pure CRUD wrapper around Kuzu database - NO DDL operations.
Attributes:
| Name | Type | Description |
|---|---|---|
conn |
Pre-initialized Kuzu connection. |
Source code in src/memg_core/core/interfaces/kuzu.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
__init__(connection)
Initialize with pre-created connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection
|
Connection
|
Pre-initialized Kuzu connection from DatabaseClients. |
required |
Source code in src/memg_core/core/interfaces/kuzu.py
19 20 21 22 23 24 25 | |
add_node(table, properties)
Add a node to the graph - pure CRUD operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Node table name. |
required |
properties
|
dict[str, Any]
|
Node properties. |
required |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If node creation fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
add_relationship(from_table, to_table, rel_type, from_id, to_id, user_id, props=None)
Add relationship between nodes using single relationship table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_table
|
str
|
Source node table name. |
required |
to_table
|
str
|
Target node table name. |
required |
rel_type
|
str
|
Relationship predicate (validated against YAML schema). |
required |
from_id
|
str
|
Source node ID. |
required |
to_id
|
str
|
Target node ID. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
props
|
dict[str, Any] | None
|
Optional relationship properties (DEPRECATED - not used). |
None
|
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If relationship creation fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
delete_node(table, node_uuid, user_id)
Delete a single node by UUID
Source code in src/memg_core/core/interfaces/kuzu.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
delete_relationship(from_table, to_table, rel_type, from_id, to_id, user_id)
Delete relationship between nodes using single relationship table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_table
|
str
|
Source node table name. |
required |
to_table
|
str
|
Target node table name. |
required |
rel_type
|
str
|
Relationship predicate (validated against YAML schema). |
required |
from_id
|
str
|
Source node ID. |
required |
to_id
|
str
|
Target node ID. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded, False if relationship not found. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If relationship deletion fails due to system error. |
Source code in src/memg_core/core/interfaces/kuzu.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
get_nodes(user_id, node_type=None, filters=None, limit=50, offset=0)
Get multiple nodes with filtering and pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User ID for ownership verification. |
required |
node_type
|
str | None
|
Optional node type filter (e.g., "task", "note"). |
None
|
filters
|
dict[str, Any] | None
|
Optional field filters (e.g., {"status": "open"}). |
None
|
limit
|
int
|
Maximum number of nodes to return. |
50
|
offset
|
int
|
Number of nodes to skip for pagination. |
0
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of node data from Kuzu. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If node retrieval fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
neighbors(node_label, node_uuid, user_id, rel_types, direction='any', limit=10, neighbor_label=None)
Fetch neighbors of a node using single relationship table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_label
|
str
|
Node type/table name (e.g., "Memory", "bug") - NOT a UUID. |
required |
node_uuid
|
str
|
UUID of the specific node to find neighbors for. |
required |
user_id
|
str
|
User ID for isolation - only return neighbors belonging to this user. |
required |
rel_types
|
list[str]
|
List of relationship predicates to filter by (required, validated against YAML). |
required |
direction
|
str
|
"in", "out", or "any" for relationship direction. |
'any'
|
limit
|
int
|
Maximum number of neighbors to return. |
10
|
neighbor_label
|
str | None
|
Type of neighbor nodes to return. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of neighbor nodes with relationship info. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If node_label is a UUID or node_uuid is not a UUID. |
DatabaseError
|
If neighbor query fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
query(cypher, params=None)
Execute Cypher query and return results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cypher
|
str
|
Cypher query string. |
required |
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: Query results. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If query execution fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
update_node(table, node_uuid, properties, user_id)
Update a node in the graph - pure CRUD operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Node table name. |
required |
node_uuid
|
str
|
UUID of the node to update. |
required |
properties
|
dict[str, Any]
|
Node properties to update. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if update succeeded, False if node not found. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If node update fails due to system error. |
Source code in src/memg_core/core/interfaces/kuzu.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
_alpha_to_idx(alpha)
Convert alpha string to index: AAA -> 0, AAB -> 1, ..., ZZZ -> 17575.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
str
|
Three-letter alpha string (AAA-ZZZ). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Numeric index. |
Source code in src/memg_core/utils/hrid.py
22 23 24 25 26 27 28 29 30 31 32 33 34 | |
parse_hrid(hrid)
Parse HRID into (type, alpha, num).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hrid
|
str
|
HRID string to parse. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str, int]
|
tuple[str, str, int]: (type, alpha, num) components. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If HRID format is invalid. |
Source code in src/memg_core/utils/hrid.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
Database Clients
Database client utilities:
Database client management - thin layer for explicit database setup.
User controls database paths. No fallbacks. No automation.
DatabaseClients
DDL-only database setup - creates schemas and returns raw clients.
NO INTERFACES - pure schema creation only. Consumer must create interfaces separately using returned raw clients.
Attributes:
| Name | Type | Description |
|---|---|---|
qdrant_client |
QdrantClient | None
|
Pre-initialized QdrantClient. |
kuzu_connection |
Connection | None
|
Pre-initialized Kuzu connection. |
db_name |
str | None
|
Database name. |
qdrant_path |
Path to Qdrant database. |
|
kuzu_path |
Path to Kuzu database. |
|
yaml_translator |
YAML translator instance. |
Source code in src/memg_core/utils/db_clients.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
__init__(yaml_path=None, embedder=None)
Create DDL-only database client wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
str | None
|
Path to YAML schema file. User must provide - no defaults. |
None
|
embedder
|
EmbedderProtocol | None
|
Optional custom embedder implementation. If not provided, uses the default FastEmbed-based embedder. |
None
|
Source code in src/memg_core/utils/db_clients.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
close()
Close all database connections and cleanup resources.
Should be called when database clients are no longer needed.
Source code in src/memg_core/utils/db_clients.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
get_embedder()
Get embedder instance.
Returns:
| Name | Type | Description |
|---|---|---|
EmbedderProtocol |
EmbedderProtocol
|
Instance for generating vectors. Either the custom embedder provided during initialization or the default FastEmbed-based embedder. |
Source code in src/memg_core/utils/db_clients.py
187 188 189 190 191 192 193 194 195 196 | |
get_kuzu_interface()
Get Kuzu interface using the initialized connection.
Returns:
| Name | Type | Description |
|---|---|---|
KuzuInterface |
KuzuInterface
|
Configured with the DDL-created connection (no yaml_translator needed). |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If connection not initialized (call init_dbs first). |
Source code in src/memg_core/utils/db_clients.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
get_qdrant_interface()
Get Qdrant interface using the initialized client.
Returns:
| Name | Type | Description |
|---|---|---|
QdrantInterface |
QdrantInterface
|
Configured with the DDL-created client and collection. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If client not initialized (call init_dbs first). |
Source code in src/memg_core/utils/db_clients.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
get_yaml_translator()
Get the YAML translator used for schema operations.
Returns:
| Name | Type | Description |
|---|---|---|
YamlTranslator |
YamlTranslator
|
Instance used during DDL operations. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If YAML translator not initialized. |
Source code in src/memg_core/utils/db_clients.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
init_dbs(db_path, db_name)
Initialize databases with structured paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db_path
|
str
|
Base database directory. |
required |
db_name
|
str
|
Database name (used for collection and file names). |
required |
Source code in src/memg_core/utils/db_clients.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
DatabaseError
Bases: MemorySystemError
Database operation failures (Qdrant, Kuzu).
Source code in src/memg_core/core/exceptions.py
42 43 | |
Embedder
Local embedder using FastEmbed - no API keys required.
Attributes:
| Name | Type | Description |
|---|---|---|
model_name |
Name of the embedding model being used. |
|
model |
FastEmbed TextEmbedding instance. |
Source code in src/memg_core/core/interfaces/embedder.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
__init__(model_name=None)
Initialize the FastEmbed embedder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str | None
|
Model to use. Defaults to config or snowflake-arctic-embed-xs. |
None
|
Source code in src/memg_core/core/interfaces/embedder.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
get_embedding(text)
Get embedding for a single text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to embed. |
required |
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: Embedding vector. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If FastEmbed returns empty embedding. |
Source code in src/memg_core/core/interfaces/embedder.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
get_embeddings(texts)
Get embeddings for multiple texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
list[str]
|
List of texts to embed. |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
list[list[float]]: List of embedding vectors. |
Source code in src/memg_core/core/interfaces/embedder.py
53 54 55 56 57 58 59 60 61 62 63 | |
EmbedderProtocol
Bases: Protocol
Protocol defining the embedder interface (structural typing - duck typing with type hints).
This is NOT an abstract base class - you don't need to inherit from it. Any object with get_embedding() and get_embeddings() methods will work. The Protocol is purely for type checkers (mypy, pyright) and IDE support.
This allows consumers to provide their own embedding implementations (OpenAI, Cohere, custom models, etc.) without modifying memg-core code.
Example
class MyEmbedder: # No inheritance needed! ... def get_embedding(self, text: str) -> list[float]: ... return [0.1, 0.2, 0.3] # Your implementation ... def get_embeddings(self, texts: list[str]) -> list[list[float]]: ... return [[0.1, 0.2, 0.3] for _ in texts]
from memg_core.api import MemgClient client = MemgClient(yaml_path="...", db_path="...", embedder=MyEmbedder())
Source code in src/memg_core/core/interfaces/embedder_protocol.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
get_embedding(text)
Generate embedding vector for a single text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Input text to embed. |
required |
Returns:
| Type | Description |
|---|---|
list[float]
|
Embedding vector as list of floats. |
Source code in src/memg_core/core/interfaces/embedder_protocol.py
33 34 35 36 37 38 39 40 41 42 | |
get_embeddings(texts)
Generate embedding vectors for multiple texts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
list[str]
|
List of input texts to embed. |
required |
Returns:
| Type | Description |
|---|---|
list[list[float]]
|
List of embedding vectors. |
Source code in src/memg_core/core/interfaces/embedder_protocol.py
44 45 46 47 48 49 50 51 52 53 | |
GraphRegister
Generates DDL statements for graph databases using TypeRegistry.
Database-agnostic design - generates DDL that can be adapted for: - Kuzu (current) - Neo4j (future) - ArangoDB (future) - Any graph database with node/relationship tables
Source code in src/memg_core/utils/graph_register.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
__init__(type_registry=None, yaml_translator=None)
Initialize GraphRegister with TypeRegistry and YamlTranslator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_registry
|
TypeRegistry | None
|
TypeRegistry instance. If None, uses global singleton. |
None
|
yaml_translator
|
YamlTranslator | None
|
YamlTranslator for accessing full YAML schema. Optional. |
None
|
Source code in src/memg_core/utils/graph_register.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
generate_all_ddl()
Generate all DDL statements for complete schema setup.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of all DDL statements needed for schema creation |
Source code in src/memg_core/utils/graph_register.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
generate_all_entity_tables_ddl()
Generate DDL for all entity tables from TypeRegistry.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of DDL strings, one per entity table |
Source code in src/memg_core/utils/graph_register.py
110 111 112 113 114 115 116 117 118 119 120 121 122 | |
generate_entity_table_ddl(entity_name)
Generate DDL for a single entity table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Name of entity type (e.g., 'task', 'bug') |
required |
Returns:
| Type | Description |
|---|---|
str
|
DDL string for creating the entity table |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If entity not found in TypeRegistry |
Source code in src/memg_core/utils/graph_register.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
generate_hrid_mapping_table_ddl()
Generate DDL for HRID mapping table (system table).
Returns:
| Type | Description |
|---|---|
str
|
DDL string for HRID mapping table |
Source code in src/memg_core/utils/graph_register.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
generate_memory_base_table_ddl()
Generate DDL for base Memory table used for relationships.
All entities are also stored in this table to enable unified relationship model. Contains only system fields needed for relationships and filtering.
Returns:
| Type | Description |
|---|---|
str
|
DDL string for Memory table |
Source code in src/memg_core/utils/graph_register.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
generate_relationship_tables_ddl()
Generate DDL for predicate-based relationship tables.
Creates one relationship table per predicate type (RELATES_TO, ANNOTATES, etc.). Each table connects Memory nodes, eliminating entity combination explosion.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of DDL strings, one per predicate type |
Source code in src/memg_core/utils/graph_register.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
KuzuInterface
Pure CRUD wrapper around Kuzu database - NO DDL operations.
Attributes:
| Name | Type | Description |
|---|---|---|
conn |
Pre-initialized Kuzu connection. |
Source code in src/memg_core/core/interfaces/kuzu.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
__init__(connection)
Initialize with pre-created connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection
|
Connection
|
Pre-initialized Kuzu connection from DatabaseClients. |
required |
Source code in src/memg_core/core/interfaces/kuzu.py
19 20 21 22 23 24 25 | |
add_node(table, properties)
Add a node to the graph - pure CRUD operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Node table name. |
required |
properties
|
dict[str, Any]
|
Node properties. |
required |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If node creation fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
add_relationship(from_table, to_table, rel_type, from_id, to_id, user_id, props=None)
Add relationship between nodes using single relationship table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_table
|
str
|
Source node table name. |
required |
to_table
|
str
|
Target node table name. |
required |
rel_type
|
str
|
Relationship predicate (validated against YAML schema). |
required |
from_id
|
str
|
Source node ID. |
required |
to_id
|
str
|
Target node ID. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
props
|
dict[str, Any] | None
|
Optional relationship properties (DEPRECATED - not used). |
None
|
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If relationship creation fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
delete_node(table, node_uuid, user_id)
Delete a single node by UUID
Source code in src/memg_core/core/interfaces/kuzu.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
delete_relationship(from_table, to_table, rel_type, from_id, to_id, user_id)
Delete relationship between nodes using single relationship table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_table
|
str
|
Source node table name. |
required |
to_table
|
str
|
Target node table name. |
required |
rel_type
|
str
|
Relationship predicate (validated against YAML schema). |
required |
from_id
|
str
|
Source node ID. |
required |
to_id
|
str
|
Target node ID. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded, False if relationship not found. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If relationship deletion fails due to system error. |
Source code in src/memg_core/core/interfaces/kuzu.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
get_nodes(user_id, node_type=None, filters=None, limit=50, offset=0)
Get multiple nodes with filtering and pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
User ID for ownership verification. |
required |
node_type
|
str | None
|
Optional node type filter (e.g., "task", "note"). |
None
|
filters
|
dict[str, Any] | None
|
Optional field filters (e.g., {"status": "open"}). |
None
|
limit
|
int
|
Maximum number of nodes to return. |
50
|
offset
|
int
|
Number of nodes to skip for pagination. |
0
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of node data from Kuzu. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If node retrieval fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
neighbors(node_label, node_uuid, user_id, rel_types, direction='any', limit=10, neighbor_label=None)
Fetch neighbors of a node using single relationship table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_label
|
str
|
Node type/table name (e.g., "Memory", "bug") - NOT a UUID. |
required |
node_uuid
|
str
|
UUID of the specific node to find neighbors for. |
required |
user_id
|
str
|
User ID for isolation - only return neighbors belonging to this user. |
required |
rel_types
|
list[str]
|
List of relationship predicates to filter by (required, validated against YAML). |
required |
direction
|
str
|
"in", "out", or "any" for relationship direction. |
'any'
|
limit
|
int
|
Maximum number of neighbors to return. |
10
|
neighbor_label
|
str | None
|
Type of neighbor nodes to return. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of neighbor nodes with relationship info. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If node_label is a UUID or node_uuid is not a UUID. |
DatabaseError
|
If neighbor query fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
query(cypher, params=None)
Execute Cypher query and return results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cypher
|
str
|
Cypher query string. |
required |
params
|
dict[str, Any] | None
|
Query parameters. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: Query results. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If query execution fails. |
Source code in src/memg_core/core/interfaces/kuzu.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
update_node(table, node_uuid, properties, user_id)
Update a node in the graph - pure CRUD operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
Node table name. |
required |
node_uuid
|
str
|
UUID of the node to update. |
required |
properties
|
dict[str, Any]
|
Node properties to update. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if update succeeded, False if node not found. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If node update fails due to system error. |
Source code in src/memg_core/core/interfaces/kuzu.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
QdrantInterface
Pure CRUD wrapper around QdrantClient - NO DDL operations.
Attributes:
| Name | Type | Description |
|---|---|---|
client |
Pre-initialized QdrantClient. |
|
collection_name |
Name of the Qdrant collection. |
Source code in src/memg_core/core/interfaces/qdrant.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
__init__(client, collection_name)
Initialize with pre-created client and collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
QdrantClient
|
Pre-initialized QdrantClient from DatabaseClients. |
required |
collection_name
|
str
|
Name of pre-created collection. |
required |
Source code in src/memg_core/core/interfaces/qdrant.py
28 29 30 31 32 33 34 35 36 | |
add_point(vector, payload, point_id=None, collection=None)
Add a single point to collection - pure CRUD operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
list[float]
|
Embedding vector. |
required |
payload
|
dict[str, Any]
|
Point payload data. |
required |
point_id
|
str | None
|
Optional point ID (auto-generated if None). |
None
|
collection
|
str | None
|
Optional collection name override. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: (success, point_id) where success indicates if operation succeeded. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If point addition fails. |
Source code in src/memg_core/core/interfaces/qdrant.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
delete_points(point_ids, user_id, collection=None)
Delete points by IDs with user ownership verification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point_ids
|
list[str]
|
List of point IDs to delete. |
required |
user_id
|
str
|
User ID for ownership verification. |
required |
collection
|
str | None
|
Optional collection name override. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if deletion succeeded. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If points not found or don't belong to user, or deletion fails. |
Source code in src/memg_core/core/interfaces/qdrant.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
get_collection_info(collection=None)
Get collection information - pure read operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
str | None
|
Optional collection name override. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Collection information including existence, vector count, point count, and config. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If collection info retrieval fails. |
Source code in src/memg_core/core/interfaces/qdrant.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
get_point(point_id, collection=None)
Get a single point by ID - pure CRUD operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point_id
|
str
|
ID of the point to retrieve. |
required |
collection
|
str | None
|
Optional collection name override. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: Point data including id, vector, and payload, or None if not found. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If retrieval fails. |
Source code in src/memg_core/core/interfaces/qdrant.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
search_points(vector, limit=5, collection=None, filters=None, score_threshold=None)
Search for similar points with mandatory user isolation - pure CRUD operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
list[float]
|
Query embedding vector. |
required |
limit
|
int
|
Maximum number of results. |
5
|
collection
|
str | None
|
Optional collection name override. |
None
|
filters
|
dict[str, Any] | None
|
Search filters (must include user_id for security). |
None
|
score_threshold
|
float | None
|
Minimum similarity score threshold (0.0-1.0). |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of search results with id, score, and payload. |
Raises:
| Type | Description |
|---|---|
DatabaseError
|
If search fails or user_id is missing from filters. |
Source code in src/memg_core/core/interfaces/qdrant.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
YamlTranslator
Translates YAML schema definitions to Pydantic models for strict validation.
Attributes:
| Name | Type | Description |
|---|---|---|
yaml_path |
Path to YAML schema file. |
|
_schema |
dict[str, Any] | None
|
Cached schema dictionary. |
Source code in src/memg_core/core/yaml_translator.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | |
schema
property
Get the loaded YAML schema, loading it if necessary.
__init__(yaml_path=None)
Initialize YamlTranslator with YAML schema path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
yaml_path
|
str | None
|
Path to YAML schema file. If None, uses MEMG_YAML_SCHEMA env var. |
None
|
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If YAML path not provided or TypeRegistry initialization fails. |
Source code in src/memg_core/core/yaml_translator.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
build_anchor_text(memory)
Build anchor text for embedding from YAML-defined anchor field.
NO hardcoded field names - reads anchor field from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
Memory object containing payload data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Anchor text for embedding. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If anchor field is missing or invalid. |
Source code in src/memg_core/core/yaml_translator.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
create_memory_from_yaml(memory_type, payload, user_id)
Create a Memory object from YAML-validated payload.
Source code in src/memg_core/core/yaml_translator.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
debug_relation_map()
Return a nested relation map for debugging/printing.
Structure: { source: { target: [ {name, predicate, directed, description} ... ] } }
Source code in src/memg_core/core/yaml_translator.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
get_anchor_field(entity_name)
Get the anchor field name for the given entity type from YAML schema.
Now reads from vector.anchored_to instead of separate anchor field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Name of the entity type. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Anchor field name. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If anchor field not found. |
Source code in src/memg_core/core/yaml_translator.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
get_default_datetime_format()
Get the default datetime format from YAML schema.
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Datetime format string from schema defaults, or None if not set. |
Source code in src/memg_core/core/yaml_translator.py
360 361 362 363 364 365 366 367 368 | |
get_display_field_name(entity_name)
Get the field name to use for display from YAML schema override section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Field name to use for display, or anchor field if no override. |
Source code in src/memg_core/core/yaml_translator.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
get_display_text(memory)
Get display text for a memory, using YAML-defined display field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
Memory object containing payload data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Display text for the memory. |
Raises:
| Type | Description |
|---|---|
YamlTranslatorError
|
If display field is missing or invalid. |
Source code in src/memg_core/core/yaml_translator.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
get_entity_model(entity_name)
Get Pydantic model from TypeRegistry - NO REDUNDANCY.
Source code in src/memg_core/core/yaml_translator.py
681 682 683 | |
get_entity_types()
Get list of available entity types from YAML schema.
Source code in src/memg_core/core/yaml_translator.py
123 124 125 | |
get_exclude_display_fields(entity_name)
Get the list of fields that should never be displayed from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of field names to always exclude from display. |
Source code in src/memg_core/core/yaml_translator.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
get_force_display_fields(entity_name)
Get the list of fields that should always be displayed from YAML schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_name
|
str
|
Entity type name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of field names to always include in display. |
Source code in src/memg_core/core/yaml_translator.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
get_relations_for_source(entity_name)
Get normalized relation specs for a source entity in target-first schema.
Returns list of dicts with keys
- source (str)
- target (str)
- name (str | None)
- description (str | None)
- predicate (str)
- directed (bool)
Source code in src/memg_core/core/yaml_translator.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
get_see_also_config(entity_name)
Get the see_also configuration for the given entity type from YAML schema.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Dict with keys: enabled, threshold, limit, target_types |
dict[str, Any] | None
|
None if see_also is not configured for this entity |
Source code in src/memg_core/core/yaml_translator.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
validate_memory_against_yaml(memory_type, payload)
Validate memory payload against YAML schema and return cleaned payload.
Source code in src/memg_core/core/yaml_translator.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
get_config()
Get system configuration, preferring environment variables.
Returns:
| Name | Type | Description |
|---|---|---|
MemorySystemConfig |
MemorySystemConfig
|
System configuration instance. |
Source code in src/memg_core/core/config.py
174 175 176 177 178 179 180 | |