galet-memory 0.1.0__tar.gz
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.
- galet_memory-0.1.0/LICENSE +21 -0
- galet_memory-0.1.0/PKG-INFO +186 -0
- galet_memory-0.1.0/README.md +161 -0
- galet_memory-0.1.0/pyproject.toml +40 -0
- galet_memory-0.1.0/setup.cfg +4 -0
- galet_memory-0.1.0/src/galet_memory/__init__.py +94 -0
- galet_memory-0.1.0/src/galet_memory/curation.py +216 -0
- galet_memory-0.1.0/src/galet_memory/episodic/__init__.py +36 -0
- galet_memory-0.1.0/src/galet_memory/episodic/embedding_digest_recall.py +74 -0
- galet_memory-0.1.0/src/galet_memory/episodic/interface.py +82 -0
- galet_memory-0.1.0/src/galet_memory/episodic/management.py +150 -0
- galet_memory-0.1.0/src/galet_memory/episodic/sqlite.py +635 -0
- galet_memory-0.1.0/src/galet_memory/examples/__init__.py +1 -0
- galet_memory-0.1.0/src/galet_memory/examples/embedding_cli.py +138 -0
- galet_memory-0.1.0/src/galet_memory/examples/episodic_cli.py +172 -0
- galet_memory-0.1.0/src/galet_memory/examples/run_examples.py +147 -0
- galet_memory-0.1.0/src/galet_memory/galet_adapter.py +17 -0
- galet_memory-0.1.0/src/galet_memory/migrations/__init__.py +1 -0
- galet_memory-0.1.0/src/galet_memory/migrations/migrate_embeddings_to_vec0.py +177 -0
- galet_memory-0.1.0/src/galet_memory/migrations/migrate_vec0_canonical.py +221 -0
- galet_memory-0.1.0/src/galet_memory/migrations/migrate_vec_embeddings_v2.py +118 -0
- galet_memory-0.1.0/src/galet_memory/ports/__init__.py +41 -0
- galet_memory-0.1.0/src/galet_memory/ports/contexts.py +39 -0
- galet_memory-0.1.0/src/galet_memory/ports/embedding_cache.py +124 -0
- galet_memory-0.1.0/src/galet_memory/ports/embeddings.py +58 -0
- galet_memory-0.1.0/src/galet_memory/ports/sqlite_vec.py +308 -0
- galet_memory-0.1.0/src/galet_memory/ports/text.py +25 -0
- galet_memory-0.1.0/src/galet_memory/procedural/__init__.py +15 -0
- galet_memory-0.1.0/src/galet_memory/procedural/context_memory.py +74 -0
- galet_memory-0.1.0/src/galet_memory/procedural/interface.py +48 -0
- galet_memory-0.1.0/src/galet_memory/semantic/__init__.py +15 -0
- galet_memory-0.1.0/src/galet_memory/semantic/interface.py +45 -0
- galet_memory-0.1.0/src/galet_memory/semantic/vector_memory.py +107 -0
- galet_memory-0.1.0/src/galet_memory.egg-info/PKG-INFO +186 -0
- galet_memory-0.1.0/src/galet_memory.egg-info/SOURCES.txt +50 -0
- galet_memory-0.1.0/src/galet_memory.egg-info/dependency_links.txt +1 -0
- galet_memory-0.1.0/src/galet_memory.egg-info/entry_points.txt +3 -0
- galet_memory-0.1.0/src/galet_memory.egg-info/requires.txt +7 -0
- galet_memory-0.1.0/src/galet_memory.egg-info/top_level.txt +1 -0
- galet_memory-0.1.0/tests/test_contracts.py +44 -0
- galet_memory-0.1.0/tests/test_curation.py +301 -0
- galet_memory-0.1.0/tests/test_embedding_cache.py +131 -0
- galet_memory-0.1.0/tests/test_embedding_cli.py +69 -0
- galet_memory-0.1.0/tests/test_episodic_cli.py +115 -0
- galet_memory-0.1.0/tests/test_memory_implementations.py +139 -0
- galet_memory-0.1.0/tests/test_migrate_embeddings_to_vec0.py +80 -0
- galet_memory-0.1.0/tests/test_migrate_vec0_canonical.py +126 -0
- galet_memory-0.1.0/tests/test_migrate_vec_embeddings_v2.py +63 -0
- galet_memory-0.1.0/tests/test_package.py +5 -0
- galet_memory-0.1.0/tests/test_sqlite_episodic_memory.py +201 -0
- galet_memory-0.1.0/tests/test_sqlite_vec_index.py +140 -0
- galet_memory-0.1.0/tests/test_sqlite_vec_integration.py +63 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 junwin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: galet-memory
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Provider-neutral memory abstractions and implementations for agent applications
|
|
5
|
+
Author-email: junwin <jdunwin@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/junwin/galet-memory
|
|
8
|
+
Project-URL: Repository, https://github.com/junwin/galet-memory
|
|
9
|
+
Keywords: memory,embeddings,episodic,vector
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: galet>=0.1.1
|
|
20
|
+
Provides-Extra: vec
|
|
21
|
+
Requires-Dist: sqlite-vec>=0.1.9; extra == "vec"
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# galet-memory
|
|
27
|
+
|
|
28
|
+
Provider-neutral memory abstractions and reusable implementations for agent applications.
|
|
29
|
+
|
|
30
|
+
This package is being extracted from Lucy's `src/coala_memory` package. It will own
|
|
31
|
+
memory models, interfaces, retrieval and ranking logic, and reusable persistence
|
|
32
|
+
implementations.
|
|
33
|
+
|
|
34
|
+
## Dependency rule
|
|
35
|
+
|
|
36
|
+
> Applications may depend on `galet-memory`; `galet-memory` must never depend
|
|
37
|
+
> on an application.
|
|
38
|
+
|
|
39
|
+
In particular, this repository must not import from Lucy's `src` package.
|
|
40
|
+
Lucy-specific configuration, dependency injection, storage adapters, agent lookup,
|
|
41
|
+
request context, and tool handlers remain in Lucy.
|
|
42
|
+
|
|
43
|
+
## Planned extraction order
|
|
44
|
+
|
|
45
|
+
1. Neutral episodic, semantic, procedural, and working-memory interfaces and models.
|
|
46
|
+
2. Retrieval, ranking, and digest logic.
|
|
47
|
+
3. Reusable SQLite and vector-backed implementations behind package-owned ports.
|
|
48
|
+
4. Lucy compatibility re-exports and adapters.
|
|
49
|
+
5. Exact-commit integration in Lucy followed by parity and full-suite testing.
|
|
50
|
+
|
|
51
|
+
The extraction must preserve database formats, retrieval results, prompts, and tool
|
|
52
|
+
permissions.
|
|
53
|
+
|
|
54
|
+
## Storage ports
|
|
55
|
+
|
|
56
|
+
Reusable memory implementations depend on narrow, structurally typed ports:
|
|
57
|
+
|
|
58
|
+
- `EmbeddingProvider` turns text into vectors. `GaletEmbeddingProvider`
|
|
59
|
+
adapts Galet's `EmbeddingApi`.
|
|
60
|
+
- `EmbeddingIndex` performs namespace-scoped similarity queries without
|
|
61
|
+
exposing an application's storage records.
|
|
62
|
+
- `TextLoader` loads bounded text from paths already authorized by the host.
|
|
63
|
+
- `ContextRepository` returns neutral context and skill snapshots.
|
|
64
|
+
|
|
65
|
+
Host applications adapt their storage and configuration to these ports. The
|
|
66
|
+
package includes `VectorSemanticMemory`, `EmbeddingDigestRecall`,
|
|
67
|
+
`ContextProceduralMemory`, and a basic `FileTextLoader`.
|
|
68
|
+
|
|
69
|
+
## Request-scoped embedding reuse
|
|
70
|
+
|
|
71
|
+
Semantic document recall and episodic digest recall commonly embed the same
|
|
72
|
+
query. Wrap their shared provider once and open a cache scope around the
|
|
73
|
+
application request:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from galet_memory import CachingEmbeddingProvider
|
|
77
|
+
|
|
78
|
+
embeddings = CachingEmbeddingProvider(base_embeddings)
|
|
79
|
+
semantic_memory = VectorSemanticMemory(embeddings=embeddings, ...)
|
|
80
|
+
digest_recall = EmbeddingDigestRecall(embeddings=embeddings, ...)
|
|
81
|
+
|
|
82
|
+
with embeddings.request_scope() as cache:
|
|
83
|
+
digest_recall(episodic_request)
|
|
84
|
+
semantic_memory.recall(semantic_request)
|
|
85
|
+
|
|
86
|
+
print(cache.info())
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The cache key contains the exact embedding model and the exact ordered input
|
|
90
|
+
texts. A model change therefore cannot reuse vectors from the previous model.
|
|
91
|
+
Calls outside a request scope pass through uncached, concurrent contexts are
|
|
92
|
+
isolated, and failed provider calls are never stored.
|
|
93
|
+
|
|
94
|
+
`SqliteVecEmbeddingIndex` reads the existing 1536-dimension sqlite-vec
|
|
95
|
+
schema. It defaults to `vec_embeddings_v2` and joins results to
|
|
96
|
+
`embedding_metadata`; the original `vec_embeddings` table can be selected
|
|
97
|
+
explicitly for legacy reads. Internal tables generated by vec0 are never
|
|
98
|
+
accessed directly.
|
|
99
|
+
|
|
100
|
+
`SqliteEpisodicMemory` implements both the prompt-time `EpisodicMemory` and
|
|
101
|
+
session-management `EpisodicMemoryManager` contracts. It opens the existing
|
|
102
|
+
Lucy-compatible `kv`/`logs` schema directly, while exposing only neutral
|
|
103
|
+
galet-memory models. Existing keys under `sessions/` and `correlations/` are
|
|
104
|
+
preserved, so adopting the package does not require a database migration.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from galet_memory import SqliteEpisodicMemory
|
|
108
|
+
|
|
109
|
+
episodic = SqliteEpisodicMemory("/path/to/chat2.sqlite")
|
|
110
|
+
session = episodic.get_session("existing-session-id")
|
|
111
|
+
```
|
|
112
|
+
## Episodic memory road test
|
|
113
|
+
|
|
114
|
+
Create a disposable database and session:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite create \
|
|
118
|
+
--account demo --agent lucy --session-id road-test \
|
|
119
|
+
--friendly-name "Road test"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Append and inspect an event:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite add \
|
|
126
|
+
road-test "Hello episodic memory"
|
|
127
|
+
|
|
128
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite show road-test
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Append supplied digest text as a logical archive boundary, then compare the
|
|
132
|
+
visible and complete histories:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite archive \
|
|
136
|
+
road-test "The earlier conversation was summarized." --account demo
|
|
137
|
+
|
|
138
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite show road-test
|
|
139
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite show road-test --scope all
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The sample accepts digest text directly and does not call an LLM. Run it
|
|
143
|
+
against a disposable database or a copy while experimenting.
|
|
144
|
+
|
|
145
|
+
## Embedding memory road test
|
|
146
|
+
|
|
147
|
+
Install the package, set `OPENAI_API_KEY` (or use Galet's
|
|
148
|
+
`GALET_CREDENTIAL_PATH`), and point the CLI at a copy or test embedding
|
|
149
|
+
database.
|
|
150
|
+
|
|
151
|
+
Add a sample:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
galet-memory-embeddings \
|
|
155
|
+
--db /home/junwin/lucy_storage/data/embeddings-v2.sqlite \
|
|
156
|
+
--account junwin \
|
|
157
|
+
--namespace demo \
|
|
158
|
+
add "The allotment has runner beans and three apple trees."
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Query it:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
galet-memory-embeddings \
|
|
165
|
+
--db /home/junwin/lucy_storage/data/embeddings-v2.sqlite \
|
|
166
|
+
--account junwin \
|
|
167
|
+
--namespace demo \
|
|
168
|
+
query "What fruit trees are in the allotment?"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Query it with path to credentials:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
galet-memory-embeddings \
|
|
175
|
+
--credential-path /home/zzzzzz/credential \
|
|
176
|
+
--db /home/junwin/lucy_storage/data/embeddings-v2.sqlite \
|
|
177
|
+
--account junwin \
|
|
178
|
+
--namespace demo \
|
|
179
|
+
query "What fruit trees are in the allotment?"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Use `--extension` when vec0 is not installed at
|
|
183
|
+
`/usr/local/lib/sqlite-vec/vec0.so`. The current schema requires
|
|
184
|
+
1536-dimension vectors, so the default model is
|
|
185
|
+
`text-embedding-3-small`. Run against a copy of a production database when
|
|
186
|
+
experimenting.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# galet-memory
|
|
2
|
+
|
|
3
|
+
Provider-neutral memory abstractions and reusable implementations for agent applications.
|
|
4
|
+
|
|
5
|
+
This package is being extracted from Lucy's `src/coala_memory` package. It will own
|
|
6
|
+
memory models, interfaces, retrieval and ranking logic, and reusable persistence
|
|
7
|
+
implementations.
|
|
8
|
+
|
|
9
|
+
## Dependency rule
|
|
10
|
+
|
|
11
|
+
> Applications may depend on `galet-memory`; `galet-memory` must never depend
|
|
12
|
+
> on an application.
|
|
13
|
+
|
|
14
|
+
In particular, this repository must not import from Lucy's `src` package.
|
|
15
|
+
Lucy-specific configuration, dependency injection, storage adapters, agent lookup,
|
|
16
|
+
request context, and tool handlers remain in Lucy.
|
|
17
|
+
|
|
18
|
+
## Planned extraction order
|
|
19
|
+
|
|
20
|
+
1. Neutral episodic, semantic, procedural, and working-memory interfaces and models.
|
|
21
|
+
2. Retrieval, ranking, and digest logic.
|
|
22
|
+
3. Reusable SQLite and vector-backed implementations behind package-owned ports.
|
|
23
|
+
4. Lucy compatibility re-exports and adapters.
|
|
24
|
+
5. Exact-commit integration in Lucy followed by parity and full-suite testing.
|
|
25
|
+
|
|
26
|
+
The extraction must preserve database formats, retrieval results, prompts, and tool
|
|
27
|
+
permissions.
|
|
28
|
+
|
|
29
|
+
## Storage ports
|
|
30
|
+
|
|
31
|
+
Reusable memory implementations depend on narrow, structurally typed ports:
|
|
32
|
+
|
|
33
|
+
- `EmbeddingProvider` turns text into vectors. `GaletEmbeddingProvider`
|
|
34
|
+
adapts Galet's `EmbeddingApi`.
|
|
35
|
+
- `EmbeddingIndex` performs namespace-scoped similarity queries without
|
|
36
|
+
exposing an application's storage records.
|
|
37
|
+
- `TextLoader` loads bounded text from paths already authorized by the host.
|
|
38
|
+
- `ContextRepository` returns neutral context and skill snapshots.
|
|
39
|
+
|
|
40
|
+
Host applications adapt their storage and configuration to these ports. The
|
|
41
|
+
package includes `VectorSemanticMemory`, `EmbeddingDigestRecall`,
|
|
42
|
+
`ContextProceduralMemory`, and a basic `FileTextLoader`.
|
|
43
|
+
|
|
44
|
+
## Request-scoped embedding reuse
|
|
45
|
+
|
|
46
|
+
Semantic document recall and episodic digest recall commonly embed the same
|
|
47
|
+
query. Wrap their shared provider once and open a cache scope around the
|
|
48
|
+
application request:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from galet_memory import CachingEmbeddingProvider
|
|
52
|
+
|
|
53
|
+
embeddings = CachingEmbeddingProvider(base_embeddings)
|
|
54
|
+
semantic_memory = VectorSemanticMemory(embeddings=embeddings, ...)
|
|
55
|
+
digest_recall = EmbeddingDigestRecall(embeddings=embeddings, ...)
|
|
56
|
+
|
|
57
|
+
with embeddings.request_scope() as cache:
|
|
58
|
+
digest_recall(episodic_request)
|
|
59
|
+
semantic_memory.recall(semantic_request)
|
|
60
|
+
|
|
61
|
+
print(cache.info())
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The cache key contains the exact embedding model and the exact ordered input
|
|
65
|
+
texts. A model change therefore cannot reuse vectors from the previous model.
|
|
66
|
+
Calls outside a request scope pass through uncached, concurrent contexts are
|
|
67
|
+
isolated, and failed provider calls are never stored.
|
|
68
|
+
|
|
69
|
+
`SqliteVecEmbeddingIndex` reads the existing 1536-dimension sqlite-vec
|
|
70
|
+
schema. It defaults to `vec_embeddings_v2` and joins results to
|
|
71
|
+
`embedding_metadata`; the original `vec_embeddings` table can be selected
|
|
72
|
+
explicitly for legacy reads. Internal tables generated by vec0 are never
|
|
73
|
+
accessed directly.
|
|
74
|
+
|
|
75
|
+
`SqliteEpisodicMemory` implements both the prompt-time `EpisodicMemory` and
|
|
76
|
+
session-management `EpisodicMemoryManager` contracts. It opens the existing
|
|
77
|
+
Lucy-compatible `kv`/`logs` schema directly, while exposing only neutral
|
|
78
|
+
galet-memory models. Existing keys under `sessions/` and `correlations/` are
|
|
79
|
+
preserved, so adopting the package does not require a database migration.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from galet_memory import SqliteEpisodicMemory
|
|
83
|
+
|
|
84
|
+
episodic = SqliteEpisodicMemory("/path/to/chat2.sqlite")
|
|
85
|
+
session = episodic.get_session("existing-session-id")
|
|
86
|
+
```
|
|
87
|
+
## Episodic memory road test
|
|
88
|
+
|
|
89
|
+
Create a disposable database and session:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite create \
|
|
93
|
+
--account demo --agent lucy --session-id road-test \
|
|
94
|
+
--friendly-name "Road test"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Append and inspect an event:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite add \
|
|
101
|
+
road-test "Hello episodic memory"
|
|
102
|
+
|
|
103
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite show road-test
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Append supplied digest text as a logical archive boundary, then compare the
|
|
107
|
+
visible and complete histories:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite archive \
|
|
111
|
+
road-test "The earlier conversation was summarized." --account demo
|
|
112
|
+
|
|
113
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite show road-test
|
|
114
|
+
galet-memory-episodic --db /tmp/galet-chat.sqlite show road-test --scope all
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The sample accepts digest text directly and does not call an LLM. Run it
|
|
118
|
+
against a disposable database or a copy while experimenting.
|
|
119
|
+
|
|
120
|
+
## Embedding memory road test
|
|
121
|
+
|
|
122
|
+
Install the package, set `OPENAI_API_KEY` (or use Galet's
|
|
123
|
+
`GALET_CREDENTIAL_PATH`), and point the CLI at a copy or test embedding
|
|
124
|
+
database.
|
|
125
|
+
|
|
126
|
+
Add a sample:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
galet-memory-embeddings \
|
|
130
|
+
--db /home/junwin/lucy_storage/data/embeddings-v2.sqlite \
|
|
131
|
+
--account junwin \
|
|
132
|
+
--namespace demo \
|
|
133
|
+
add "The allotment has runner beans and three apple trees."
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Query it:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
galet-memory-embeddings \
|
|
140
|
+
--db /home/junwin/lucy_storage/data/embeddings-v2.sqlite \
|
|
141
|
+
--account junwin \
|
|
142
|
+
--namespace demo \
|
|
143
|
+
query "What fruit trees are in the allotment?"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Query it with path to credentials:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
galet-memory-embeddings \
|
|
150
|
+
--credential-path /home/zzzzzz/credential \
|
|
151
|
+
--db /home/junwin/lucy_storage/data/embeddings-v2.sqlite \
|
|
152
|
+
--account junwin \
|
|
153
|
+
--namespace demo \
|
|
154
|
+
query "What fruit trees are in the allotment?"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Use `--extension` when vec0 is not installed at
|
|
158
|
+
`/usr/local/lib/sqlite-vec/vec0.so`. The current schema requires
|
|
159
|
+
1536-dimension vectors, so the default model is
|
|
160
|
+
`text-embedding-3-small`. Run against a copy of a production database when
|
|
161
|
+
experimenting.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "galet-memory"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Provider-neutral memory abstractions and implementations for agent applications"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [{ name = "junwin", email = "jdunwin@gmail.com" }]
|
|
13
|
+
keywords = ["memory", "embeddings", "episodic", "vector"]
|
|
14
|
+
dependencies = ["galet>=0.1.1"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Topic :: Software Development :: Libraries",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
vec = ["sqlite-vec>=0.1.9"]
|
|
26
|
+
test = ["pytest>=8"]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
galet-memory-embeddings = "galet_memory.examples.embedding_cli:main"
|
|
30
|
+
galet-memory-episodic = "galet_memory.examples.episodic_cli:main"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/junwin/galet-memory"
|
|
34
|
+
Repository = "https://github.com/junwin/galet-memory"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.packages.find]
|
|
37
|
+
where = ["src"]
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Provider-neutral memory abstractions and implementations."""
|
|
2
|
+
|
|
3
|
+
from .episodic import (
|
|
4
|
+
EmbeddingDigestRecall,
|
|
5
|
+
EventScope,
|
|
6
|
+
EpisodicCurationRequest,
|
|
7
|
+
EpisodicCurationResult,
|
|
8
|
+
EpisodicConcurrencyError,
|
|
9
|
+
EpisodicDigest,
|
|
10
|
+
EpisodicEvent,
|
|
11
|
+
EpisodicMemory,
|
|
12
|
+
EpisodicMemoryManager,
|
|
13
|
+
EpisodicMemoryRequest,
|
|
14
|
+
EpisodicMemoryResult,
|
|
15
|
+
EpisodicSession,
|
|
16
|
+
EpisodicSessionQuery,
|
|
17
|
+
EpisodicCompatibilityError,
|
|
18
|
+
SqliteEpisodicMemory,
|
|
19
|
+
)
|
|
20
|
+
from .curation import (
|
|
21
|
+
CurationConflictError,
|
|
22
|
+
CurationError,
|
|
23
|
+
CurationResult,
|
|
24
|
+
CurationService,
|
|
25
|
+
CurationSessionNotFoundError,
|
|
26
|
+
CurationStorageError,
|
|
27
|
+
DigestGenerationError,
|
|
28
|
+
DigestGenerationRequest,
|
|
29
|
+
DigestGenerator,
|
|
30
|
+
)
|
|
31
|
+
from .procedural import (
|
|
32
|
+
ContextProceduralMemory,
|
|
33
|
+
ProceduralMemory,
|
|
34
|
+
ProceduralMemoryRequest,
|
|
35
|
+
ProceduralMemoryResult,
|
|
36
|
+
ProceduralSkill,
|
|
37
|
+
)
|
|
38
|
+
from .semantic import (
|
|
39
|
+
SemanticDocument,
|
|
40
|
+
SemanticMemory,
|
|
41
|
+
SemanticMemoryRequest,
|
|
42
|
+
SemanticMemoryResult,
|
|
43
|
+
VectorSemanticMemory,
|
|
44
|
+
)
|
|
45
|
+
from .ports import (
|
|
46
|
+
CachingEmbeddingProvider,
|
|
47
|
+
EmbeddingCache,
|
|
48
|
+
EmbeddingCacheInfo,
|
|
49
|
+
EmbeddingCacheKey,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
__version__ = "0.1.0.dev0"
|
|
53
|
+
|
|
54
|
+
__all__ = [
|
|
55
|
+
"CachingEmbeddingProvider",
|
|
56
|
+
"ContextProceduralMemory",
|
|
57
|
+
"CurationConflictError",
|
|
58
|
+
"CurationError",
|
|
59
|
+
"CurationResult",
|
|
60
|
+
"CurationService",
|
|
61
|
+
"CurationSessionNotFoundError",
|
|
62
|
+
"CurationStorageError",
|
|
63
|
+
"DigestGenerationError",
|
|
64
|
+
"DigestGenerationRequest",
|
|
65
|
+
"DigestGenerator",
|
|
66
|
+
"EmbeddingDigestRecall",
|
|
67
|
+
"EmbeddingCache",
|
|
68
|
+
"EmbeddingCacheInfo",
|
|
69
|
+
"EmbeddingCacheKey",
|
|
70
|
+
"EventScope",
|
|
71
|
+
"EpisodicCurationRequest",
|
|
72
|
+
"EpisodicCurationResult",
|
|
73
|
+
"EpisodicConcurrencyError",
|
|
74
|
+
"EpisodicDigest",
|
|
75
|
+
"EpisodicEvent",
|
|
76
|
+
"EpisodicMemory",
|
|
77
|
+
"EpisodicMemoryManager",
|
|
78
|
+
"EpisodicMemoryRequest",
|
|
79
|
+
"EpisodicMemoryResult",
|
|
80
|
+
"EpisodicSession",
|
|
81
|
+
"EpisodicSessionQuery",
|
|
82
|
+
"EpisodicCompatibilityError",
|
|
83
|
+
"SqliteEpisodicMemory",
|
|
84
|
+
"ProceduralMemory",
|
|
85
|
+
"ProceduralMemoryRequest",
|
|
86
|
+
"ProceduralMemoryResult",
|
|
87
|
+
"ProceduralSkill",
|
|
88
|
+
"SemanticDocument",
|
|
89
|
+
"SemanticMemory",
|
|
90
|
+
"SemanticMemoryRequest",
|
|
91
|
+
"SemanticMemoryResult",
|
|
92
|
+
"VectorSemanticMemory",
|
|
93
|
+
"__version__",
|
|
94
|
+
]
|