deepeval-goodmem 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.
- deepeval_goodmem-0.1.0/LICENSE +201 -0
- deepeval_goodmem-0.1.0/PKG-INFO +164 -0
- deepeval_goodmem-0.1.0/README.md +134 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/__init__.py +31 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/_base.py +89 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/_client.py +684 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/create_memory.py +50 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/create_space.py +53 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/delete_memory.py +31 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/delete_space.py +30 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/get_memory.py +41 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/get_space.py +32 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/list_embedders.py +35 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/list_memories.py +58 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/list_spaces.py +35 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/py.typed +0 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/retrieve_memories.py +91 -0
- deepeval_goodmem-0.1.0/deepeval_goodmem/update_space.py +55 -0
- deepeval_goodmem-0.1.0/pyproject.toml +48 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 GoodMem
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepeval-goodmem
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: DeepEval AI framework plugin for GoodMem, a retrieval-augmented generation (RAG) memory service.
|
|
5
|
+
Author: PAIR Systems
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: httpx>=0.24.0,<1
|
|
19
|
+
Requires-Dist: pytest>=7.0 ; extra == "dev"
|
|
20
|
+
Requires-Dist: pytest-timeout ; extra == "dev"
|
|
21
|
+
Requires-Dist: build ; extra == "dev"
|
|
22
|
+
Requires-Dist: twine ; extra == "dev"
|
|
23
|
+
Requires-Dist: openai>=1.12.0 ; extra == "examples"
|
|
24
|
+
Project-URL: homepage, https://github.com/PAIR-Systems-Inc/goodmem_deepeval
|
|
25
|
+
Project-URL: issues, https://github.com/PAIR-Systems-Inc/goodmem_deepeval/issues
|
|
26
|
+
Project-URL: source, https://github.com/PAIR-Systems-Inc/goodmem_deepeval
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Provides-Extra: examples
|
|
29
|
+
|
|
30
|
+
# deepeval-goodmem
|
|
31
|
+
|
|
32
|
+
[GoodMem](https://goodmem.ai) integration for
|
|
33
|
+
[DeepEval](https://deepeval.com).
|
|
34
|
+
|
|
35
|
+
GoodMem gives AI agents retrieval-augmented generation (RAG) memory. Store
|
|
36
|
+
documents in a space and GoodMem chunks, embeds, and indexes them so your
|
|
37
|
+
agent can pull back the most relevant passages on any question.
|
|
38
|
+
|
|
39
|
+
This package exposes the GoodMem API as a set of DeepEval-flavoured operation
|
|
40
|
+
classes. Each operation has a `run(...)` method that returns a JSON string,
|
|
41
|
+
making them callable from any evaluation script, test harness, or scoring
|
|
42
|
+
pipeline.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install deepeval-goodmem
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For local development:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install -e ".[dev]"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quickstart
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import json
|
|
60
|
+
import os
|
|
61
|
+
|
|
62
|
+
os.environ["GOODMEM_BASE_URL"] = "https://localhost:8080"
|
|
63
|
+
os.environ["GOODMEM_API_KEY"] = "gm_xxxxxxxxxxxxxxxxxxxxxxxx"
|
|
64
|
+
os.environ["GOODMEM_VERIFY_SSL"] = "false" # self-signed local server
|
|
65
|
+
|
|
66
|
+
from deepeval_goodmem import (
|
|
67
|
+
GoodMemCreateMemory,
|
|
68
|
+
GoodMemCreateSpace,
|
|
69
|
+
GoodMemListEmbedders,
|
|
70
|
+
GoodMemRetrieveMemories,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
embedders = json.loads(GoodMemListEmbedders().run())
|
|
74
|
+
embedder_id = embedders["embedders"][0]["embedderId"]
|
|
75
|
+
|
|
76
|
+
space = json.loads(
|
|
77
|
+
GoodMemCreateSpace().run(name="quickstart", embedder_id=embedder_id)
|
|
78
|
+
)
|
|
79
|
+
space_id = space["spaceId"]
|
|
80
|
+
|
|
81
|
+
GoodMemCreateMemory().run(
|
|
82
|
+
space_id=space_id,
|
|
83
|
+
text_content="The capital of France is Paris.",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
results = json.loads(
|
|
87
|
+
GoodMemRetrieveMemories().run(
|
|
88
|
+
query="What is the capital of France?",
|
|
89
|
+
space_ids=space_id,
|
|
90
|
+
max_results=3,
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
print(results)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Every operation's `run(...)` returns a JSON string. On success the parsed
|
|
97
|
+
object includes `"success": true` and operation-specific fields. On failure
|
|
98
|
+
it includes `"success": false` and an `"error"` field.
|
|
99
|
+
|
|
100
|
+
The local GoodMem dev server ships with TLS even on localhost. Set
|
|
101
|
+
`GOODMEM_VERIFY_SSL=false` to accept the self-signed certificate during
|
|
102
|
+
development; production deployments behind a trusted certificate should
|
|
103
|
+
leave it at the default of `true`.
|
|
104
|
+
|
|
105
|
+
## Available operations
|
|
106
|
+
|
|
107
|
+
| Operation | Description |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `GoodMemListEmbedders` | List embedder models available on the server |
|
|
110
|
+
| `GoodMemListSpaces` | List all spaces accessible to the API key |
|
|
111
|
+
| `GoodMemGetSpace` | Fetch a space by ID |
|
|
112
|
+
| `GoodMemCreateSpace` | Create a space (idempotent by name) |
|
|
113
|
+
| `GoodMemUpdateSpace` | Update a space's name, labels, or public-read flag |
|
|
114
|
+
| `GoodMemDeleteSpace` | Delete a space and all of its memories |
|
|
115
|
+
| `GoodMemCreateMemory` | Store text or a file as a memory |
|
|
116
|
+
| `GoodMemListMemories` | List memories in a space, with pagination and filters |
|
|
117
|
+
| `GoodMemRetrieveMemories` | Semantic retrieval across one or more spaces |
|
|
118
|
+
| `GoodMemGetMemory` | Fetch a memory by ID, with optional content |
|
|
119
|
+
| `GoodMemDeleteMemory` | Delete a memory |
|
|
120
|
+
|
|
121
|
+
### Retrieval options
|
|
122
|
+
|
|
123
|
+
`GoodMemRetrieveMemories` accepts the following parameters in addition to
|
|
124
|
+
`query`, `space_ids`, and `max_results`:
|
|
125
|
+
|
|
126
|
+
| Parameter | Type | Description |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| `metadata_filter` | str | SQL-style JSONPath filter applied server-side to every space key. Example: `CAST(val('$.category') AS TEXT) = 'feat'` |
|
|
129
|
+
| `wait_for_indexing` | bool | Poll for results when none come back on the first call (default `True`) |
|
|
130
|
+
| `max_wait_seconds` | float | Polling budget (default `60.0`) |
|
|
131
|
+
| `poll_interval` | float | Seconds between polls (default `5.0`) |
|
|
132
|
+
| `reranker_id` | str | Reranker model to refine result ordering |
|
|
133
|
+
| `llm_id` | str | LLM that generates a contextual abstract reply |
|
|
134
|
+
| `relevance_threshold` | float | Minimum score (0-1) for inclusion |
|
|
135
|
+
| `llm_temperature` | float | Creativity (0-2) for the LLM post-processor |
|
|
136
|
+
| `chronological_resort` | bool | Reorder results by creation time |
|
|
137
|
+
|
|
138
|
+
## Environment variables
|
|
139
|
+
|
|
140
|
+
| Variable | Description |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `GOODMEM_BASE_URL` | Base URL of the GoodMem API server |
|
|
143
|
+
| `GOODMEM_API_KEY` | API key sent as `X-API-Key` |
|
|
144
|
+
| `GOODMEM_VERIFY_SSL` | Set to `false` to skip TLS verification (default `true`) |
|
|
145
|
+
|
|
146
|
+
When the env vars are set, every operation constructor can be called with
|
|
147
|
+
no arguments.
|
|
148
|
+
|
|
149
|
+
## End-to-end example
|
|
150
|
+
|
|
151
|
+
[`examples/example_usage.py`](examples/example_usage.py) walks through three
|
|
152
|
+
scenarios: persistent project context, a scribe and analyst pipeline, and
|
|
153
|
+
metadata-driven retrieval. The answering step uses OpenAI; install with
|
|
154
|
+
`pip install deepeval-goodmem[examples]` and set `OPENAI_API_KEY` before
|
|
155
|
+
running.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
python examples/example_usage.py
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
Apache License 2.0. See [LICENSE](LICENSE).
|
|
164
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# deepeval-goodmem
|
|
2
|
+
|
|
3
|
+
[GoodMem](https://goodmem.ai) integration for
|
|
4
|
+
[DeepEval](https://deepeval.com).
|
|
5
|
+
|
|
6
|
+
GoodMem gives AI agents retrieval-augmented generation (RAG) memory. Store
|
|
7
|
+
documents in a space and GoodMem chunks, embeds, and indexes them so your
|
|
8
|
+
agent can pull back the most relevant passages on any question.
|
|
9
|
+
|
|
10
|
+
This package exposes the GoodMem API as a set of DeepEval-flavoured operation
|
|
11
|
+
classes. Each operation has a `run(...)` method that returns a JSON string,
|
|
12
|
+
making them callable from any evaluation script, test harness, or scoring
|
|
13
|
+
pipeline.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install deepeval-goodmem
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For local development:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e ".[dev]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quickstart
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import json
|
|
31
|
+
import os
|
|
32
|
+
|
|
33
|
+
os.environ["GOODMEM_BASE_URL"] = "https://localhost:8080"
|
|
34
|
+
os.environ["GOODMEM_API_KEY"] = "gm_xxxxxxxxxxxxxxxxxxxxxxxx"
|
|
35
|
+
os.environ["GOODMEM_VERIFY_SSL"] = "false" # self-signed local server
|
|
36
|
+
|
|
37
|
+
from deepeval_goodmem import (
|
|
38
|
+
GoodMemCreateMemory,
|
|
39
|
+
GoodMemCreateSpace,
|
|
40
|
+
GoodMemListEmbedders,
|
|
41
|
+
GoodMemRetrieveMemories,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
embedders = json.loads(GoodMemListEmbedders().run())
|
|
45
|
+
embedder_id = embedders["embedders"][0]["embedderId"]
|
|
46
|
+
|
|
47
|
+
space = json.loads(
|
|
48
|
+
GoodMemCreateSpace().run(name="quickstart", embedder_id=embedder_id)
|
|
49
|
+
)
|
|
50
|
+
space_id = space["spaceId"]
|
|
51
|
+
|
|
52
|
+
GoodMemCreateMemory().run(
|
|
53
|
+
space_id=space_id,
|
|
54
|
+
text_content="The capital of France is Paris.",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
results = json.loads(
|
|
58
|
+
GoodMemRetrieveMemories().run(
|
|
59
|
+
query="What is the capital of France?",
|
|
60
|
+
space_ids=space_id,
|
|
61
|
+
max_results=3,
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
print(results)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Every operation's `run(...)` returns a JSON string. On success the parsed
|
|
68
|
+
object includes `"success": true` and operation-specific fields. On failure
|
|
69
|
+
it includes `"success": false` and an `"error"` field.
|
|
70
|
+
|
|
71
|
+
The local GoodMem dev server ships with TLS even on localhost. Set
|
|
72
|
+
`GOODMEM_VERIFY_SSL=false` to accept the self-signed certificate during
|
|
73
|
+
development; production deployments behind a trusted certificate should
|
|
74
|
+
leave it at the default of `true`.
|
|
75
|
+
|
|
76
|
+
## Available operations
|
|
77
|
+
|
|
78
|
+
| Operation | Description |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `GoodMemListEmbedders` | List embedder models available on the server |
|
|
81
|
+
| `GoodMemListSpaces` | List all spaces accessible to the API key |
|
|
82
|
+
| `GoodMemGetSpace` | Fetch a space by ID |
|
|
83
|
+
| `GoodMemCreateSpace` | Create a space (idempotent by name) |
|
|
84
|
+
| `GoodMemUpdateSpace` | Update a space's name, labels, or public-read flag |
|
|
85
|
+
| `GoodMemDeleteSpace` | Delete a space and all of its memories |
|
|
86
|
+
| `GoodMemCreateMemory` | Store text or a file as a memory |
|
|
87
|
+
| `GoodMemListMemories` | List memories in a space, with pagination and filters |
|
|
88
|
+
| `GoodMemRetrieveMemories` | Semantic retrieval across one or more spaces |
|
|
89
|
+
| `GoodMemGetMemory` | Fetch a memory by ID, with optional content |
|
|
90
|
+
| `GoodMemDeleteMemory` | Delete a memory |
|
|
91
|
+
|
|
92
|
+
### Retrieval options
|
|
93
|
+
|
|
94
|
+
`GoodMemRetrieveMemories` accepts the following parameters in addition to
|
|
95
|
+
`query`, `space_ids`, and `max_results`:
|
|
96
|
+
|
|
97
|
+
| Parameter | Type | Description |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| `metadata_filter` | str | SQL-style JSONPath filter applied server-side to every space key. Example: `CAST(val('$.category') AS TEXT) = 'feat'` |
|
|
100
|
+
| `wait_for_indexing` | bool | Poll for results when none come back on the first call (default `True`) |
|
|
101
|
+
| `max_wait_seconds` | float | Polling budget (default `60.0`) |
|
|
102
|
+
| `poll_interval` | float | Seconds between polls (default `5.0`) |
|
|
103
|
+
| `reranker_id` | str | Reranker model to refine result ordering |
|
|
104
|
+
| `llm_id` | str | LLM that generates a contextual abstract reply |
|
|
105
|
+
| `relevance_threshold` | float | Minimum score (0-1) for inclusion |
|
|
106
|
+
| `llm_temperature` | float | Creativity (0-2) for the LLM post-processor |
|
|
107
|
+
| `chronological_resort` | bool | Reorder results by creation time |
|
|
108
|
+
|
|
109
|
+
## Environment variables
|
|
110
|
+
|
|
111
|
+
| Variable | Description |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `GOODMEM_BASE_URL` | Base URL of the GoodMem API server |
|
|
114
|
+
| `GOODMEM_API_KEY` | API key sent as `X-API-Key` |
|
|
115
|
+
| `GOODMEM_VERIFY_SSL` | Set to `false` to skip TLS verification (default `true`) |
|
|
116
|
+
|
|
117
|
+
When the env vars are set, every operation constructor can be called with
|
|
118
|
+
no arguments.
|
|
119
|
+
|
|
120
|
+
## End-to-end example
|
|
121
|
+
|
|
122
|
+
[`examples/example_usage.py`](examples/example_usage.py) walks through three
|
|
123
|
+
scenarios: persistent project context, a scribe and analyst pipeline, and
|
|
124
|
+
metadata-driven retrieval. The answering step uses OpenAI; install with
|
|
125
|
+
`pip install deepeval-goodmem[examples]` and set `OPENAI_API_KEY` before
|
|
126
|
+
running.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python examples/example_usage.py
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
Apache License 2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""DeepEval plugin for GoodMem, the retrieval-augmented generation (RAG) memory backend for AI agents."""
|
|
2
|
+
|
|
3
|
+
from deepeval_goodmem._base import GoodMemOperation
|
|
4
|
+
from deepeval_goodmem._client import GoodMemClient
|
|
5
|
+
from deepeval_goodmem.create_memory import GoodMemCreateMemory
|
|
6
|
+
from deepeval_goodmem.create_space import GoodMemCreateSpace
|
|
7
|
+
from deepeval_goodmem.delete_memory import GoodMemDeleteMemory
|
|
8
|
+
from deepeval_goodmem.delete_space import GoodMemDeleteSpace
|
|
9
|
+
from deepeval_goodmem.get_memory import GoodMemGetMemory
|
|
10
|
+
from deepeval_goodmem.get_space import GoodMemGetSpace
|
|
11
|
+
from deepeval_goodmem.list_embedders import GoodMemListEmbedders
|
|
12
|
+
from deepeval_goodmem.list_memories import GoodMemListMemories
|
|
13
|
+
from deepeval_goodmem.list_spaces import GoodMemListSpaces
|
|
14
|
+
from deepeval_goodmem.retrieve_memories import GoodMemRetrieveMemories
|
|
15
|
+
from deepeval_goodmem.update_space import GoodMemUpdateSpace
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"GoodMemClient",
|
|
19
|
+
"GoodMemCreateMemory",
|
|
20
|
+
"GoodMemCreateSpace",
|
|
21
|
+
"GoodMemDeleteMemory",
|
|
22
|
+
"GoodMemDeleteSpace",
|
|
23
|
+
"GoodMemGetMemory",
|
|
24
|
+
"GoodMemGetSpace",
|
|
25
|
+
"GoodMemListEmbedders",
|
|
26
|
+
"GoodMemListMemories",
|
|
27
|
+
"GoodMemListSpaces",
|
|
28
|
+
"GoodMemOperation",
|
|
29
|
+
"GoodMemRetrieveMemories",
|
|
30
|
+
"GoodMemUpdateSpace",
|
|
31
|
+
]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Base class for GoodMem operations."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from deepeval_goodmem._client import GoodMemClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _env_bool(value: str | None, default: bool = True) -> bool:
|
|
11
|
+
"""Parse a boolean from an environment variable string."""
|
|
12
|
+
if value is None:
|
|
13
|
+
return default
|
|
14
|
+
return value.strip().lower() in {"1", "true", "yes", "y", "on"}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class GoodMemOperation:
|
|
18
|
+
"""Base class for GoodMem operation wrappers.
|
|
19
|
+
|
|
20
|
+
Each subclass exposes a single GoodMem API action and serializes its
|
|
21
|
+
result as a JSON string.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
goodmem_base_url: The GoodMem API base URL. Falls back to the
|
|
25
|
+
`GOODMEM_BASE_URL` environment variable.
|
|
26
|
+
goodmem_api_key: The GoodMem API key. Falls back to the
|
|
27
|
+
`GOODMEM_API_KEY` environment variable.
|
|
28
|
+
goodmem_verify_ssl: Whether to verify SSL certificates. Falls back
|
|
29
|
+
to the `GOODMEM_VERIFY_SSL` environment variable (default: True).
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
name: str = "goodmem_operation"
|
|
33
|
+
description: str = ""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
*,
|
|
38
|
+
goodmem_base_url: str | None = None,
|
|
39
|
+
goodmem_api_key: str | None = None,
|
|
40
|
+
goodmem_verify_ssl: bool | None = None,
|
|
41
|
+
) -> None:
|
|
42
|
+
base_url = goodmem_base_url or os.environ.get("GOODMEM_BASE_URL")
|
|
43
|
+
api_key = goodmem_api_key or os.environ.get("GOODMEM_API_KEY")
|
|
44
|
+
|
|
45
|
+
if not base_url:
|
|
46
|
+
msg = (
|
|
47
|
+
"GoodMem base URL is required. Pass `goodmem_base_url` or set "
|
|
48
|
+
"the GOODMEM_BASE_URL environment variable."
|
|
49
|
+
)
|
|
50
|
+
raise ValueError(msg)
|
|
51
|
+
if not api_key:
|
|
52
|
+
msg = (
|
|
53
|
+
"GoodMem API key is required. Pass `goodmem_api_key` or set "
|
|
54
|
+
"the GOODMEM_API_KEY environment variable."
|
|
55
|
+
)
|
|
56
|
+
raise ValueError(msg)
|
|
57
|
+
|
|
58
|
+
if goodmem_verify_ssl is None:
|
|
59
|
+
verify_ssl = _env_bool(os.environ.get("GOODMEM_VERIFY_SSL"), default=True)
|
|
60
|
+
else:
|
|
61
|
+
verify_ssl = goodmem_verify_ssl
|
|
62
|
+
|
|
63
|
+
self.goodmem_base_url = base_url
|
|
64
|
+
self.goodmem_api_key = api_key
|
|
65
|
+
self.goodmem_verify_ssl = verify_ssl
|
|
66
|
+
|
|
67
|
+
def _client(self) -> GoodMemClient:
|
|
68
|
+
"""Return a fresh `GoodMemClient` for this operation."""
|
|
69
|
+
return GoodMemClient(
|
|
70
|
+
base_url=self.goodmem_base_url,
|
|
71
|
+
api_key=self.goodmem_api_key,
|
|
72
|
+
verify_ssl=self.goodmem_verify_ssl,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def run(self, **kwargs: Any) -> str:
|
|
76
|
+
"""Run the operation and return the result as a JSON string.
|
|
77
|
+
|
|
78
|
+
On failure, the JSON payload contains `success: false` and an
|
|
79
|
+
`error` field with the exception message.
|
|
80
|
+
"""
|
|
81
|
+
try:
|
|
82
|
+
result = self._run(**kwargs)
|
|
83
|
+
except Exception as e:
|
|
84
|
+
result = {"success": False, "error": str(e)}
|
|
85
|
+
return json.dumps(result)
|
|
86
|
+
|
|
87
|
+
def _run(self, **kwargs: Any) -> dict[str, Any]:
|
|
88
|
+
"""Perform the API call. Subclasses must implement this."""
|
|
89
|
+
raise NotImplementedError
|