memoryagent-lib 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- memoryagent/config.py +24 -0
- memoryagent/examples/export_memory.py +7 -1
- memoryagent/examples/memory_api_server.py +6 -0
- memoryagent/system.py +1 -0
- {memoryagent_lib-0.1.1.dist-info → memoryagent_lib-0.1.2.dist-info}/METADATA +4 -1
- {memoryagent_lib-0.1.1.dist-info → memoryagent_lib-0.1.2.dist-info}/RECORD +8 -8
- {memoryagent_lib-0.1.1.dist-info → memoryagent_lib-0.1.2.dist-info}/WHEEL +0 -0
- {memoryagent_lib-0.1.1.dist-info → memoryagent_lib-0.1.2.dist-info}/top_level.txt +0 -0
memoryagent/config.py
CHANGED
|
@@ -20,6 +20,7 @@ class MemorySystemConfig(BaseModel):
|
|
|
20
20
|
working_ttl_seconds: int = 3600
|
|
21
21
|
retrieval_plan: RetrievalPlan = Field(default_factory=RetrievalPlan)
|
|
22
22
|
consolidation: ConsolidationConfig = Field(default_factory=ConsolidationConfig)
|
|
23
|
+
data_root: Optional[Path] = None
|
|
23
24
|
cold_store_path: Path = Field(default_factory=lambda: Path(".memoryagent_cold"))
|
|
24
25
|
metadata_db_path: Path = Field(default_factory=lambda: Path(".memoryagent_hot.sqlite"))
|
|
25
26
|
feature_db_path: Path = Field(default_factory=lambda: Path(".memoryagent_features.sqlite"))
|
|
@@ -33,3 +34,26 @@ class MemorySystemConfig(BaseModel):
|
|
|
33
34
|
if self.archive_index_path is not None:
|
|
34
35
|
return self.archive_index_path
|
|
35
36
|
return self.cold_store_path / "archive_index.json"
|
|
37
|
+
|
|
38
|
+
def resolve_paths(self) -> None:
|
|
39
|
+
root = self.data_root or _find_project_root()
|
|
40
|
+
if root is None:
|
|
41
|
+
return
|
|
42
|
+
root = Path(root)
|
|
43
|
+
self.data_root = root
|
|
44
|
+
self.cold_store_path = root / self.cold_store_path
|
|
45
|
+
self.metadata_db_path = root / self.metadata_db_path
|
|
46
|
+
self.feature_db_path = root / self.feature_db_path
|
|
47
|
+
self.vector_db_path = root / self.vector_db_path
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _find_project_root(start: Optional[Path] = None) -> Optional[Path]:
|
|
51
|
+
current = start or Path.cwd()
|
|
52
|
+
current = current.resolve()
|
|
53
|
+
for _ in range(6):
|
|
54
|
+
if (current / "pyproject.toml").exists() or (current / ".git").exists():
|
|
55
|
+
return current
|
|
56
|
+
if current.parent == current:
|
|
57
|
+
break
|
|
58
|
+
current = current.parent
|
|
59
|
+
return None
|
|
@@ -5,7 +5,13 @@ import sqlite3
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Any, Dict, List
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
try:
|
|
9
|
+
from memoryagent.config import _find_project_root
|
|
10
|
+
except Exception:
|
|
11
|
+
_find_project_root = None
|
|
12
|
+
|
|
13
|
+
ROOT = _find_project_root() if _find_project_root else None
|
|
14
|
+
ROOT = ROOT or Path.cwd()
|
|
9
15
|
COLD_ROOT = ROOT / ".memoryagent_cold"
|
|
10
16
|
HOT_DB = ROOT / ".memoryagent_hot.sqlite"
|
|
11
17
|
FEATURE_DB = ROOT / ".memoryagent_features.sqlite"
|
|
@@ -7,6 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
import os
|
|
8
8
|
from memoryagent.examples.export_memory import get_memory_payload
|
|
9
9
|
from uuid import uuid4
|
|
10
|
+
from pathlib import Path
|
|
10
11
|
|
|
11
12
|
from memoryagent import (
|
|
12
13
|
HeuristicMemoryPolicy,
|
|
@@ -64,6 +65,7 @@ def _get_memory_system():
|
|
|
64
65
|
vector_dim = int(os.environ.get("OPENAI_EMBED_DIM", "1536"))
|
|
65
66
|
|
|
66
67
|
config = MemorySystemConfig(
|
|
68
|
+
data_root=Path.cwd(),
|
|
67
69
|
use_sqlite_vec=True,
|
|
68
70
|
vector_dim=vector_dim,
|
|
69
71
|
sqlite_vec_extension_path=os.environ.get("SQLITE_VEC_PATH"),
|
|
@@ -73,6 +75,10 @@ def _get_memory_system():
|
|
|
73
75
|
config=config,
|
|
74
76
|
embedding_fn=_openai_embedder(client, embedding_model, config.vector_dim),
|
|
75
77
|
)
|
|
78
|
+
root = getattr(memory.config, "data_root", None)
|
|
79
|
+
print(
|
|
80
|
+
f"[memory_api] root={root} hot_db={memory.config.metadata_db_path} cold={memory.config.cold_store_path}"
|
|
81
|
+
)
|
|
76
82
|
return memory, client, model
|
|
77
83
|
|
|
78
84
|
|
memoryagent/system.py
CHANGED
|
@@ -35,6 +35,7 @@ class MemorySystem:
|
|
|
35
35
|
routing_policy: Optional[MemoryRoutingPolicy] = None,
|
|
36
36
|
) -> None:
|
|
37
37
|
self.config = config or MemorySystemConfig()
|
|
38
|
+
self.config.resolve_paths()
|
|
38
39
|
self.metadata_store = metadata_store or SQLiteMetadataStore(self.config.metadata_db_path)
|
|
39
40
|
if vector_index is not None:
|
|
40
41
|
self.vector_index = vector_index
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memoryagent-lib
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Add your description here
|
|
5
5
|
Author-email: Jiawei Zheng <jw.zhengai@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -173,6 +173,9 @@ The page calls:
|
|
|
173
173
|
- **Features**: `.memoryagent_features.sqlite`
|
|
174
174
|
- **Cold archive**: `.memoryagent_cold/records/<owner>/YYYY/MM/DD/daily_notes.json`
|
|
175
175
|
|
|
176
|
+
## Data Root (Installed Usage)
|
|
177
|
+
The system auto-detects a project root by walking up from the current working directory and looking for `pyproject.toml` or `.git`. If it can’t find one, it uses the current directory.
|
|
178
|
+
|
|
176
179
|
## Configuration
|
|
177
180
|
See `memoryagent/config.py` for defaults:
|
|
178
181
|
- `working_ttl_seconds`
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
memoryagent/__init__.py,sha256=WUv2YjbJzU4lpHIVPDLTrv3wglraPJh6Ky7P9f_r8OU,743
|
|
2
2
|
memoryagent/confidence.py,sha256=bEBrQFj7nTt7xIaFc21BqUaBQOy3DoIVpwTsBUysv54,2626
|
|
3
|
-
memoryagent/config.py,sha256=
|
|
3
|
+
memoryagent/config.py,sha256=KcwZM4aR2IYLaRioeqg_gwzX5lzyob_DcZRzdbreiAA,2175
|
|
4
4
|
memoryagent/consolidation.py,sha256=jG5AJr9PNxeqdPi3kD4bbj51YZkrxE4-ZSSTNCnN6Yc,123
|
|
5
5
|
memoryagent/indexers.py,sha256=I2Sv-jyWqs5K83BIXPvSDp9_Z18xClX8QedJyt3ZJzA,2030
|
|
6
6
|
memoryagent/models.py,sha256=mOt-rX8wlzT_n4JsvTDd6iKeJW-bdPp8VGFrb61OgdQ,4185
|
|
7
7
|
memoryagent/policy.py,sha256=doZbUIBAwQVr4BhPjcAtDs_GAM35Z04RYDnc3zf2AJo,6032
|
|
8
8
|
memoryagent/retrieval.py,sha256=PAvaHXAHxk6yXn5iZDR6t39UODwOciWNQimPredbtU4,6124
|
|
9
|
-
memoryagent/system.py,sha256=
|
|
9
|
+
memoryagent/system.py,sha256=3Fwo6RS0p4VC9O3yFsUyO0YShzVZf4memI4Ft70V2us,7794
|
|
10
10
|
memoryagent/utils.py,sha256=PZ5AaZwUZDNxj64g70UTXK9ynLtGLeSiHpp8GCmbTIs,883
|
|
11
11
|
memoryagent/workers.py,sha256=2TrwovaAx_NZhcPCwsl-FpLwWCmFC0HfPzHQkJsKO9U,6235
|
|
12
|
-
memoryagent/examples/export_memory.py,sha256=
|
|
13
|
-
memoryagent/examples/memory_api_server.py,sha256=
|
|
12
|
+
memoryagent/examples/export_memory.py,sha256=bdxkmw46EVrKF6R1Cb9Jf5jeQSzmFrOSiNs-qRs1gYA,3413
|
|
13
|
+
memoryagent/examples/memory_api_server.py,sha256=qgqbYwUvlsIaXBx76fjXUUpyqcA8ZtISoohbpdYgl6k,8120
|
|
14
14
|
memoryagent/examples/minimal.py,sha256=KjduPgOIOCy0B27LPxLlMwsEko19-piSlrZOPgv6pcc,1154
|
|
15
15
|
memoryagent/examples/openai_agent.py,sha256=u31uMM7SM-RYSotail49hs5CpRy01DTyrKOLADkNY8M,4577
|
|
16
16
|
memoryagent/storage/base.py,sha256=JYT0HcGIwUz-uydpy9huQ5ABK3G8XshDE6aM3PLpG2s,2453
|
|
17
17
|
memoryagent/storage/in_memory.py,sha256=-AfeYc9TO1EtD59vd2_JTZdJMmTlQYAYQK7fcpKhYAk,3373
|
|
18
18
|
memoryagent/storage/local_disk.py,sha256=EejHxueMmjL7PPPVVl6p8nNmrvJEdxyXQNORly9Nzow,15768
|
|
19
|
-
memoryagent_lib-0.1.
|
|
20
|
-
memoryagent_lib-0.1.
|
|
21
|
-
memoryagent_lib-0.1.
|
|
22
|
-
memoryagent_lib-0.1.
|
|
19
|
+
memoryagent_lib-0.1.2.dist-info/METADATA,sha256=jIjmjXxqQ-H97weQTe9-Sij2lfSX4INIvSZrcxbpzCw,5929
|
|
20
|
+
memoryagent_lib-0.1.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
21
|
+
memoryagent_lib-0.1.2.dist-info/top_level.txt,sha256=0svscYmHfWNY9RQMcUEEmE5I6ksCYfy4wR7P-CLrcIU,12
|
|
22
|
+
memoryagent_lib-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|