langgraph-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.
- langgraph_goodmem-0.1.0/.github/workflows/release.yml +50 -0
- langgraph_goodmem-0.1.0/.gitignore +36 -0
- langgraph_goodmem-0.1.0/LICENSE +21 -0
- langgraph_goodmem-0.1.0/Makefile +43 -0
- langgraph_goodmem-0.1.0/PKG-INFO +119 -0
- langgraph_goodmem-0.1.0/README.md +92 -0
- langgraph_goodmem-0.1.0/examples/live_smoke_test.py +325 -0
- langgraph_goodmem-0.1.0/examples/react_agent_with_memory.py +127 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/__init__.py +31 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/_client.py +665 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/py.typed +0 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/__init__.py +27 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/create_memory.py +133 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/create_space.py +128 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/delete_memory.py +82 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/delete_space.py +58 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/get_memory.py +104 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/get_space.py +60 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/list_embedders.py +87 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/list_memories.py +112 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/list_spaces.py +87 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/retrieve_memories.py +183 -0
- langgraph_goodmem-0.1.0/langgraph_goodmem/tools/update_space.py +100 -0
- langgraph_goodmem-0.1.0/pyproject.toml +107 -0
- langgraph_goodmem-0.1.0/tests/__init__.py +0 -0
- langgraph_goodmem-0.1.0/tests/integration_tests/__init__.py +0 -0
- langgraph_goodmem-0.1.0/tests/integration_tests/test_goodmem_integration.py +187 -0
- langgraph_goodmem-0.1.0/tests/unit_tests/__init__.py +0 -0
- langgraph_goodmem-0.1.0/tests/unit_tests/test_client.py +273 -0
- langgraph_goodmem-0.1.0/tests/unit_tests/test_imports.py +23 -0
- langgraph_goodmem-0.1.0/tests/unit_tests/test_tools.py +187 -0
- langgraph_goodmem-0.1.0/uv.lock +1292 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
name: Build distribution
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v3
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.10"
|
|
23
|
+
|
|
24
|
+
- name: Build sdist + wheel
|
|
25
|
+
run: uv build
|
|
26
|
+
|
|
27
|
+
- name: Upload artifacts
|
|
28
|
+
uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: dist
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
publish:
|
|
34
|
+
name: Publish to PyPI
|
|
35
|
+
needs: build
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
environment:
|
|
38
|
+
name: pypi
|
|
39
|
+
url: https://pypi.org/p/langgraph-goodmem
|
|
40
|
+
permissions:
|
|
41
|
+
id-token: write
|
|
42
|
+
steps:
|
|
43
|
+
- name: Download artifacts
|
|
44
|
+
uses: actions/download-artifact@v4
|
|
45
|
+
with:
|
|
46
|
+
name: dist
|
|
47
|
+
path: dist/
|
|
48
|
+
|
|
49
|
+
- name: Publish to PyPI via Trusted Publishing
|
|
50
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Build artifacts
|
|
2
|
+
dist/
|
|
3
|
+
build/
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
|
|
7
|
+
# Python bytecode
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*$py.class
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# Tooling caches
|
|
18
|
+
.mypy_cache/
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
.tox/
|
|
22
|
+
.coverage
|
|
23
|
+
.coverage.*
|
|
24
|
+
htmlcov/
|
|
25
|
+
coverage.xml
|
|
26
|
+
|
|
27
|
+
# Editor / OS
|
|
28
|
+
.idea/
|
|
29
|
+
.vscode/
|
|
30
|
+
.DS_Store
|
|
31
|
+
*.swp
|
|
32
|
+
*~
|
|
33
|
+
|
|
34
|
+
# Environment files
|
|
35
|
+
.env
|
|
36
|
+
.env.local
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PAIR Systems Inc.
|
|
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,43 @@
|
|
|
1
|
+
.PHONY: all format lint type test test_watch
|
|
2
|
+
|
|
3
|
+
# Default target
|
|
4
|
+
all: lint format test
|
|
5
|
+
|
|
6
|
+
######################
|
|
7
|
+
# TESTING AND COVERAGE
|
|
8
|
+
######################
|
|
9
|
+
|
|
10
|
+
TEST ?= .
|
|
11
|
+
|
|
12
|
+
test:
|
|
13
|
+
uv run pytest $(TEST)
|
|
14
|
+
|
|
15
|
+
test_watch:
|
|
16
|
+
uv run ptw $(TEST)
|
|
17
|
+
|
|
18
|
+
######################
|
|
19
|
+
# LINTING AND FORMATTING
|
|
20
|
+
######################
|
|
21
|
+
|
|
22
|
+
# Define a variable for Python and notebook files.
|
|
23
|
+
PYTHON_FILES=.
|
|
24
|
+
MYPY_CACHE=.mypy_cache
|
|
25
|
+
lint format: PYTHON_FILES=.
|
|
26
|
+
lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --relative --diff-filter=d main . | grep -E '\.py$$|\.ipynb$$')
|
|
27
|
+
lint_package: PYTHON_FILES=langgraph_goodmem
|
|
28
|
+
lint_tests: PYTHON_FILES=tests
|
|
29
|
+
lint_tests: MYPY_CACHE=.mypy_cache_test
|
|
30
|
+
|
|
31
|
+
lint lint_diff lint_package lint_tests:
|
|
32
|
+
uv run ruff check .
|
|
33
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run ruff format $(PYTHON_FILES) --diff
|
|
34
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run ruff check --select I $(PYTHON_FILES)
|
|
35
|
+
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE)
|
|
36
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
|
|
37
|
+
|
|
38
|
+
type:
|
|
39
|
+
mkdir -p $(MYPY_CACHE) && uv run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
|
|
40
|
+
|
|
41
|
+
format format_diff:
|
|
42
|
+
uv run ruff format $(PYTHON_FILES)
|
|
43
|
+
uv run ruff check --select I --fix $(PYTHON_FILES)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langgraph-goodmem
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LangGraph integration for GoodMem: long-term agent memory with semantic storage and retrieval.
|
|
5
|
+
Project-URL: Homepage, https://github.com/PAIR-Systems-Inc/goodmem-langgraph
|
|
6
|
+
Project-URL: Repository, https://github.com/PAIR-Systems-Inc/goodmem-langgraph
|
|
7
|
+
Project-URL: Documentation, https://goodmem.ai/docs
|
|
8
|
+
Project-URL: Issues, https://github.com/PAIR-Systems-Inc/goodmem-langgraph/issues
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,goodmem,langgraph,llm,memory,semantic-search,vector-search
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: <4.0.0,>=3.10.0
|
|
23
|
+
Requires-Dist: httpx<1.0.0,>=0.27.0
|
|
24
|
+
Requires-Dist: langchain-core<2.0.0,>=1.0.0
|
|
25
|
+
Requires-Dist: pydantic<3.0.0,>=2.7.4
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# langgraph-goodmem
|
|
29
|
+
|
|
30
|
+
[](https://pypi.org/project/langgraph-goodmem/)
|
|
31
|
+
[](LICENSE)
|
|
32
|
+
|
|
33
|
+
LangGraph integration for [GoodMem](https://goodmem.ai) — long-term agent memory with semantic storage and retrieval.
|
|
34
|
+
|
|
35
|
+
GoodMem is a memory layer for AI agents that handles embedding, vector search, reranking, and LLM-powered answering server-side. This package exposes GoodMem operations as LangGraph tools that can be used with any LangGraph agent or graph.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install langgraph-goodmem
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Requires Python 3.10+.
|
|
44
|
+
|
|
45
|
+
## Tools
|
|
46
|
+
|
|
47
|
+
| Tool | Description |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `GoodMemListEmbedders` | List available embedder models |
|
|
50
|
+
| `GoodMemListSpaces` | List all spaces in your account |
|
|
51
|
+
| `GoodMemGetSpace` | Fetch a specific space by ID |
|
|
52
|
+
| `GoodMemCreateSpace` | Create a new space or reuse an existing one |
|
|
53
|
+
| `GoodMemUpdateSpace` | Update a space's name or metadata |
|
|
54
|
+
| `GoodMemDeleteSpace` | Delete a space and all of its memories |
|
|
55
|
+
| `GoodMemCreateMemory` | Store text or files as memories |
|
|
56
|
+
| `GoodMemListMemories` | List memories in a space |
|
|
57
|
+
| `GoodMemGetMemory` | Fetch a specific memory by ID |
|
|
58
|
+
| `GoodMemRetrieveMemories` | Semantic similarity search across spaces |
|
|
59
|
+
| `GoodMemDeleteMemory` | Permanently delete a memory |
|
|
60
|
+
|
|
61
|
+
## Quick start
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from langgraph_goodmem import (
|
|
65
|
+
GoodMemCreateSpace,
|
|
66
|
+
GoodMemCreateMemory,
|
|
67
|
+
GoodMemRetrieveMemories,
|
|
68
|
+
)
|
|
69
|
+
from langgraph.prebuilt import create_react_agent
|
|
70
|
+
|
|
71
|
+
goodmem_kwargs = {
|
|
72
|
+
"goodmem_base_url": "http://localhost:8080",
|
|
73
|
+
"goodmem_api_key": "your-api-key",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
tools = [
|
|
77
|
+
GoodMemCreateSpace(**goodmem_kwargs),
|
|
78
|
+
GoodMemCreateMemory(**goodmem_kwargs),
|
|
79
|
+
GoodMemRetrieveMemories(**goodmem_kwargs),
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
agent = create_react_agent(model="gpt-4o", tools=tools)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Usage in a custom LangGraph graph
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from langgraph.graph import StateGraph, START, END
|
|
89
|
+
from langgraph.prebuilt import ToolNode
|
|
90
|
+
from langgraph_goodmem import (
|
|
91
|
+
GoodMemCreateSpace,
|
|
92
|
+
GoodMemCreateMemory,
|
|
93
|
+
GoodMemRetrieveMemories,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
tools = [
|
|
97
|
+
GoodMemCreateSpace(**goodmem_kwargs),
|
|
98
|
+
GoodMemCreateMemory(**goodmem_kwargs),
|
|
99
|
+
GoodMemRetrieveMemories(**goodmem_kwargs),
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
tool_node = ToolNode(tools)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Environment variables
|
|
106
|
+
|
|
107
|
+
| Variable | Description |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `GOODMEM_BASE_URL` | Base URL of the GoodMem API server |
|
|
110
|
+
| `GOODMEM_API_KEY` | API key for authentication |
|
|
111
|
+
| `GOODMEM_VERIFY_SSL` | Set to `false` to skip TLS verification for self-signed certs (default: `true`) |
|
|
112
|
+
|
|
113
|
+
## Example
|
|
114
|
+
|
|
115
|
+
A full ReAct agent example is in [examples/react_agent_with_memory.py](examples/react_agent_with_memory.py).
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# langgraph-goodmem
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/langgraph-goodmem/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
LangGraph integration for [GoodMem](https://goodmem.ai) — long-term agent memory with semantic storage and retrieval.
|
|
7
|
+
|
|
8
|
+
GoodMem is a memory layer for AI agents that handles embedding, vector search, reranking, and LLM-powered answering server-side. This package exposes GoodMem operations as LangGraph tools that can be used with any LangGraph agent or graph.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install langgraph-goodmem
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Requires Python 3.10+.
|
|
17
|
+
|
|
18
|
+
## Tools
|
|
19
|
+
|
|
20
|
+
| Tool | Description |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `GoodMemListEmbedders` | List available embedder models |
|
|
23
|
+
| `GoodMemListSpaces` | List all spaces in your account |
|
|
24
|
+
| `GoodMemGetSpace` | Fetch a specific space by ID |
|
|
25
|
+
| `GoodMemCreateSpace` | Create a new space or reuse an existing one |
|
|
26
|
+
| `GoodMemUpdateSpace` | Update a space's name or metadata |
|
|
27
|
+
| `GoodMemDeleteSpace` | Delete a space and all of its memories |
|
|
28
|
+
| `GoodMemCreateMemory` | Store text or files as memories |
|
|
29
|
+
| `GoodMemListMemories` | List memories in a space |
|
|
30
|
+
| `GoodMemGetMemory` | Fetch a specific memory by ID |
|
|
31
|
+
| `GoodMemRetrieveMemories` | Semantic similarity search across spaces |
|
|
32
|
+
| `GoodMemDeleteMemory` | Permanently delete a memory |
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from langgraph_goodmem import (
|
|
38
|
+
GoodMemCreateSpace,
|
|
39
|
+
GoodMemCreateMemory,
|
|
40
|
+
GoodMemRetrieveMemories,
|
|
41
|
+
)
|
|
42
|
+
from langgraph.prebuilt import create_react_agent
|
|
43
|
+
|
|
44
|
+
goodmem_kwargs = {
|
|
45
|
+
"goodmem_base_url": "http://localhost:8080",
|
|
46
|
+
"goodmem_api_key": "your-api-key",
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
tools = [
|
|
50
|
+
GoodMemCreateSpace(**goodmem_kwargs),
|
|
51
|
+
GoodMemCreateMemory(**goodmem_kwargs),
|
|
52
|
+
GoodMemRetrieveMemories(**goodmem_kwargs),
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
agent = create_react_agent(model="gpt-4o", tools=tools)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Usage in a custom LangGraph graph
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from langgraph.graph import StateGraph, START, END
|
|
62
|
+
from langgraph.prebuilt import ToolNode
|
|
63
|
+
from langgraph_goodmem import (
|
|
64
|
+
GoodMemCreateSpace,
|
|
65
|
+
GoodMemCreateMemory,
|
|
66
|
+
GoodMemRetrieveMemories,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
tools = [
|
|
70
|
+
GoodMemCreateSpace(**goodmem_kwargs),
|
|
71
|
+
GoodMemCreateMemory(**goodmem_kwargs),
|
|
72
|
+
GoodMemRetrieveMemories(**goodmem_kwargs),
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
tool_node = ToolNode(tools)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Environment variables
|
|
79
|
+
|
|
80
|
+
| Variable | Description |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `GOODMEM_BASE_URL` | Base URL of the GoodMem API server |
|
|
83
|
+
| `GOODMEM_API_KEY` | API key for authentication |
|
|
84
|
+
| `GOODMEM_VERIFY_SSL` | Set to `false` to skip TLS verification for self-signed certs (default: `true`) |
|
|
85
|
+
|
|
86
|
+
## Example
|
|
87
|
+
|
|
88
|
+
A full ReAct agent example is in [examples/react_agent_with_memory.py](examples/react_agent_with_memory.py).
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"""Live end-to-end smoke test for every langgraph-goodmem tool.
|
|
2
|
+
|
|
3
|
+
Runs against a real GoodMem server. Exercises all 11 tools and every
|
|
4
|
+
post-processor knob on `goodmem_retrieve_memories` (reranker, LLM,
|
|
5
|
+
relevance threshold, LLM temperature, chronological resort, max results).
|
|
6
|
+
|
|
7
|
+
Required environment variables:
|
|
8
|
+
GOODMEM_BASE_URL e.g. https://localhost:8080
|
|
9
|
+
GOODMEM_API_KEY your GoodMem API key
|
|
10
|
+
|
|
11
|
+
Optional environment variables (sensible defaults shown):
|
|
12
|
+
GOODMEM_VERIFY_SSL "true" | "false" (default: "false")
|
|
13
|
+
GOODMEM_EMBEDDER_ID default: 019cfd1c-c033-7517-b7de-f73941a0464b
|
|
14
|
+
GOODMEM_RERANKER_ID default: 019cfda4-7e2f-743c-9edb-e469a97b95c6
|
|
15
|
+
GOODMEM_LLM_ID default: 019cfd9f-0963-76f9-b069-4cde19a64ba8
|
|
16
|
+
|
|
17
|
+
Run from the repo root after `pip install -e .`:
|
|
18
|
+
python examples/live_smoke_test.py
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import json
|
|
24
|
+
import os
|
|
25
|
+
import sys
|
|
26
|
+
import time
|
|
27
|
+
import uuid
|
|
28
|
+
from typing import Any
|
|
29
|
+
|
|
30
|
+
from langgraph_goodmem import (
|
|
31
|
+
GoodMemCreateMemory,
|
|
32
|
+
GoodMemCreateSpace,
|
|
33
|
+
GoodMemDeleteMemory,
|
|
34
|
+
GoodMemDeleteSpace,
|
|
35
|
+
GoodMemGetMemory,
|
|
36
|
+
GoodMemGetSpace,
|
|
37
|
+
GoodMemListEmbedders,
|
|
38
|
+
GoodMemListMemories,
|
|
39
|
+
GoodMemListSpaces,
|
|
40
|
+
GoodMemRetrieveMemories,
|
|
41
|
+
GoodMemUpdateSpace,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# --- Configuration -------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
BASE_URL = os.environ.get("GOODMEM_BASE_URL")
|
|
47
|
+
API_KEY = os.environ.get("GOODMEM_API_KEY")
|
|
48
|
+
VERIFY_SSL = os.environ.get("GOODMEM_VERIFY_SSL", "false").lower() == "true"
|
|
49
|
+
|
|
50
|
+
EMBEDDER_ID = os.environ.get(
|
|
51
|
+
"GOODMEM_EMBEDDER_ID", "019cfd1c-c033-7517-b7de-f73941a0464b"
|
|
52
|
+
)
|
|
53
|
+
RERANKER_ID = os.environ.get(
|
|
54
|
+
"GOODMEM_RERANKER_ID", "019cfda4-7e2f-743c-9edb-e469a97b95c6"
|
|
55
|
+
)
|
|
56
|
+
LLM_ID = os.environ.get("GOODMEM_LLM_ID", "019cfd9f-0963-76f9-b069-4cde19a64ba8")
|
|
57
|
+
|
|
58
|
+
if not BASE_URL or not API_KEY:
|
|
59
|
+
sys.exit(
|
|
60
|
+
"ERROR: set GOODMEM_BASE_URL and GOODMEM_API_KEY before running this script."
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
KW: dict[str, Any] = {
|
|
64
|
+
"goodmem_base_url": BASE_URL,
|
|
65
|
+
"goodmem_api_key": API_KEY,
|
|
66
|
+
"goodmem_verify_ssl": VERIFY_SSL,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# --- Helpers -------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
PASS = "\033[32m✓\033[0m"
|
|
72
|
+
FAIL = "\033[31m✗\033[0m"
|
|
73
|
+
INFO = "\033[36m›\033[0m"
|
|
74
|
+
results: list[tuple[str, bool, str]] = []
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def step(label: str) -> None:
|
|
78
|
+
print(f"\n{INFO} {label}")
|
|
79
|
+
print("─" * (len(label) + 2))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def call(tool_name: str, tool: Any, payload: dict[str, Any]) -> dict[str, Any]:
|
|
83
|
+
"""Invoke a tool, parse the JSON, mark pass/fail, and return the result."""
|
|
84
|
+
raw = tool.invoke(payload)
|
|
85
|
+
try:
|
|
86
|
+
result = json.loads(raw)
|
|
87
|
+
except json.JSONDecodeError:
|
|
88
|
+
print(f" {FAIL} {tool_name}: non-JSON response")
|
|
89
|
+
print(f" {raw[:400]}")
|
|
90
|
+
results.append((tool_name, False, "non-JSON response"))
|
|
91
|
+
return {}
|
|
92
|
+
ok = bool(result.get("success"))
|
|
93
|
+
icon = PASS if ok else FAIL
|
|
94
|
+
summary = result.get("error") or result.get("message") or ""
|
|
95
|
+
print(f" {icon} {tool_name}{' — ' + summary if summary else ''}")
|
|
96
|
+
results.append((tool_name, ok, summary))
|
|
97
|
+
return result
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def preview(label: str, value: Any, limit: int = 200) -> None:
|
|
101
|
+
text = (
|
|
102
|
+
json.dumps(value, indent=2) if isinstance(value, (dict, list)) else str(value)
|
|
103
|
+
)
|
|
104
|
+
if len(text) > limit:
|
|
105
|
+
text = text[:limit] + " …"
|
|
106
|
+
print(f" {label}: {text}")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# --- Run ----------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
print(f"GoodMem live smoke test → {BASE_URL}")
|
|
112
|
+
print(f" embedder_id = {EMBEDDER_ID}")
|
|
113
|
+
print(f" reranker_id = {RERANKER_ID}")
|
|
114
|
+
print(f" llm_id = {LLM_ID}")
|
|
115
|
+
|
|
116
|
+
# 1. list_embedders ------------------------------------------------------
|
|
117
|
+
step("1. goodmem_list_embedders")
|
|
118
|
+
r = call("list_embedders", GoodMemListEmbedders(**KW), {})
|
|
119
|
+
embedders = r.get("embedders", [])
|
|
120
|
+
preview("count", len(embedders))
|
|
121
|
+
ids = {e.get("embedderId") for e in embedders}
|
|
122
|
+
if EMBEDDER_ID not in ids:
|
|
123
|
+
print(
|
|
124
|
+
f" {FAIL} configured EMBEDDER_ID {EMBEDDER_ID} not found in server's "
|
|
125
|
+
f"embedder list — subsequent steps may fail."
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
# 2. list_spaces (snapshot) ---------------------------------------------
|
|
129
|
+
step("2. goodmem_list_spaces (before)")
|
|
130
|
+
r = call("list_spaces", GoodMemListSpaces(**KW), {})
|
|
131
|
+
preview("count", len(r.get("spaces", [])))
|
|
132
|
+
|
|
133
|
+
# 3. create_space --------------------------------------------------------
|
|
134
|
+
space_name = f"langgraph-smoke-{int(time.time())}-{uuid.uuid4().hex[:6]}"
|
|
135
|
+
step(f"3. goodmem_create_space (name={space_name})")
|
|
136
|
+
r = call(
|
|
137
|
+
"create_space",
|
|
138
|
+
GoodMemCreateSpace(**KW),
|
|
139
|
+
{"name": space_name, "embedder_id": EMBEDDER_ID},
|
|
140
|
+
)
|
|
141
|
+
space_id = r.get("spaceId")
|
|
142
|
+
if not space_id:
|
|
143
|
+
sys.exit(f"\n{FAIL} create_space returned no spaceId, aborting.")
|
|
144
|
+
preview("spaceId", space_id)
|
|
145
|
+
|
|
146
|
+
# 4. get_space -----------------------------------------------------------
|
|
147
|
+
step("4. goodmem_get_space")
|
|
148
|
+
r = call("get_space", GoodMemGetSpace(**KW), {"space_id": space_id})
|
|
149
|
+
preview("space.name", r.get("space", {}).get("name"))
|
|
150
|
+
|
|
151
|
+
# 5. update_space (rename) ----------------------------------------------
|
|
152
|
+
new_name = space_name + "-renamed"
|
|
153
|
+
step(f"5. goodmem_update_space (rename → {new_name})")
|
|
154
|
+
r = call(
|
|
155
|
+
"update_space",
|
|
156
|
+
GoodMemUpdateSpace(**KW),
|
|
157
|
+
{"space_id": space_id, "name": new_name},
|
|
158
|
+
)
|
|
159
|
+
preview("space.name", r.get("space", {}).get("name"))
|
|
160
|
+
|
|
161
|
+
# 6. create_memory (×3, varied content) ---------------------------------
|
|
162
|
+
step("6. goodmem_create_memory (×3 varied texts)")
|
|
163
|
+
texts = [
|
|
164
|
+
"LangGraph is a framework for building stateful, multi-actor agents with LLMs.",
|
|
165
|
+
"GoodMem provides server-side embedding, vector search, and reranking.",
|
|
166
|
+
"Pasta carbonara is a Roman dish made with eggs, guanciale, and pecorino.",
|
|
167
|
+
]
|
|
168
|
+
memory_ids: list[str] = []
|
|
169
|
+
for i, text in enumerate(texts, 1):
|
|
170
|
+
r = call(
|
|
171
|
+
f"create_memory[{i}]",
|
|
172
|
+
GoodMemCreateMemory(**KW),
|
|
173
|
+
{"space_id": space_id, "text_content": text},
|
|
174
|
+
)
|
|
175
|
+
if r.get("memoryId"):
|
|
176
|
+
memory_ids.append(r["memoryId"])
|
|
177
|
+
preview("created memory_ids", memory_ids)
|
|
178
|
+
|
|
179
|
+
if not memory_ids:
|
|
180
|
+
sys.exit(f"\n{FAIL} no memories created, aborting.")
|
|
181
|
+
|
|
182
|
+
# 7. list_memories -------------------------------------------------------
|
|
183
|
+
step("7. goodmem_list_memories")
|
|
184
|
+
r = call("list_memories", GoodMemListMemories(**KW), {"space_id": space_id})
|
|
185
|
+
preview("count", len(r.get("memories", [])))
|
|
186
|
+
|
|
187
|
+
# 8. get_memory ----------------------------------------------------------
|
|
188
|
+
step(f"8. goodmem_get_memory (memory_id={memory_ids[0]})")
|
|
189
|
+
r = call("get_memory", GoodMemGetMemory(**KW), {"memory_id": memory_ids[0]})
|
|
190
|
+
preview("memory.spaceId", r.get("memory", {}).get("spaceId"))
|
|
191
|
+
|
|
192
|
+
# 9. retrieve_memories — variants ---------------------------------------
|
|
193
|
+
print("\n--- goodmem_retrieve_memories variants ---")
|
|
194
|
+
print(
|
|
195
|
+
" (waits up to 60s for indexing on first call; the queried memories "
|
|
196
|
+
"were just created)"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
retrieve = GoodMemRetrieveMemories(**KW)
|
|
200
|
+
query = "Which framework is used for stateful multi-actor agents?"
|
|
201
|
+
|
|
202
|
+
# 9a. plain
|
|
203
|
+
step("9a. retrieve_memories (plain, no postprocessor)")
|
|
204
|
+
r = call(
|
|
205
|
+
"retrieve_plain",
|
|
206
|
+
retrieve,
|
|
207
|
+
{
|
|
208
|
+
"query": query,
|
|
209
|
+
"space_ids": space_id,
|
|
210
|
+
"max_results": 5,
|
|
211
|
+
"wait_for_indexing": True,
|
|
212
|
+
},
|
|
213
|
+
)
|
|
214
|
+
preview("totalResults", r.get("totalResults"))
|
|
215
|
+
if r.get("results"):
|
|
216
|
+
preview("top relevanceScore", r["results"][0].get("relevanceScore"))
|
|
217
|
+
|
|
218
|
+
# 9b. reranker only
|
|
219
|
+
step("9b. retrieve_memories (+ reranker_id)")
|
|
220
|
+
r = call(
|
|
221
|
+
"retrieve_reranker",
|
|
222
|
+
retrieve,
|
|
223
|
+
{
|
|
224
|
+
"query": query,
|
|
225
|
+
"space_ids": space_id,
|
|
226
|
+
"max_results": 5,
|
|
227
|
+
"wait_for_indexing": False,
|
|
228
|
+
"reranker_id": RERANKER_ID,
|
|
229
|
+
},
|
|
230
|
+
)
|
|
231
|
+
preview("totalResults", r.get("totalResults"))
|
|
232
|
+
|
|
233
|
+
# 9c. LLM only (expect abstractReply)
|
|
234
|
+
step("9c. retrieve_memories (+ llm_id → abstractReply)")
|
|
235
|
+
r = call(
|
|
236
|
+
"retrieve_llm",
|
|
237
|
+
retrieve,
|
|
238
|
+
{
|
|
239
|
+
"query": query,
|
|
240
|
+
"space_ids": space_id,
|
|
241
|
+
"max_results": 5,
|
|
242
|
+
"wait_for_indexing": False,
|
|
243
|
+
"llm_id": LLM_ID,
|
|
244
|
+
"llm_temperature": 0.2,
|
|
245
|
+
},
|
|
246
|
+
)
|
|
247
|
+
preview("totalResults", r.get("totalResults"))
|
|
248
|
+
preview("abstractReply", r.get("abstractReply"), limit=400)
|
|
249
|
+
|
|
250
|
+
# 9d. reranker + LLM + relevance threshold
|
|
251
|
+
step(
|
|
252
|
+
"9d. retrieve_memories (+ reranker_id + llm_id + relevance_threshold=0.1 "
|
|
253
|
+
"+ llm_temperature=0.5)"
|
|
254
|
+
)
|
|
255
|
+
r = call(
|
|
256
|
+
"retrieve_full",
|
|
257
|
+
retrieve,
|
|
258
|
+
{
|
|
259
|
+
"query": query,
|
|
260
|
+
"space_ids": space_id,
|
|
261
|
+
"max_results": 5,
|
|
262
|
+
"wait_for_indexing": False,
|
|
263
|
+
"reranker_id": RERANKER_ID,
|
|
264
|
+
"llm_id": LLM_ID,
|
|
265
|
+
"relevance_threshold": 0.1,
|
|
266
|
+
"llm_temperature": 0.5,
|
|
267
|
+
},
|
|
268
|
+
)
|
|
269
|
+
preview("totalResults", r.get("totalResults"))
|
|
270
|
+
preview("abstractReply", r.get("abstractReply"), limit=400)
|
|
271
|
+
|
|
272
|
+
# 9e. chronological resort
|
|
273
|
+
step("9e. retrieve_memories (+ chronological_resort=True)")
|
|
274
|
+
r = call(
|
|
275
|
+
"retrieve_chrono",
|
|
276
|
+
retrieve,
|
|
277
|
+
{
|
|
278
|
+
"query": query,
|
|
279
|
+
"space_ids": space_id,
|
|
280
|
+
"max_results": 5,
|
|
281
|
+
"wait_for_indexing": False,
|
|
282
|
+
"reranker_id": RERANKER_ID,
|
|
283
|
+
"chronological_resort": True,
|
|
284
|
+
},
|
|
285
|
+
)
|
|
286
|
+
preview("totalResults", r.get("totalResults"))
|
|
287
|
+
|
|
288
|
+
# 9f. max_results=1
|
|
289
|
+
step("9f. retrieve_memories (max_results=1)")
|
|
290
|
+
r = call(
|
|
291
|
+
"retrieve_max1",
|
|
292
|
+
retrieve,
|
|
293
|
+
{
|
|
294
|
+
"query": query,
|
|
295
|
+
"space_ids": space_id,
|
|
296
|
+
"max_results": 1,
|
|
297
|
+
"wait_for_indexing": False,
|
|
298
|
+
},
|
|
299
|
+
)
|
|
300
|
+
preview("totalResults", r.get("totalResults"))
|
|
301
|
+
|
|
302
|
+
# 10. delete_memory (one) ------------------------------------------------
|
|
303
|
+
step(f"10. goodmem_delete_memory (memory_id={memory_ids[-1]})")
|
|
304
|
+
call("delete_memory", GoodMemDeleteMemory(**KW), {"memory_id": memory_ids[-1]})
|
|
305
|
+
|
|
306
|
+
# 11. delete_space (cleanup) --------------------------------------------
|
|
307
|
+
step(f"11. goodmem_delete_space (space_id={space_id})")
|
|
308
|
+
call("delete_space", GoodMemDeleteSpace(**KW), {"space_id": space_id})
|
|
309
|
+
|
|
310
|
+
# --- Summary ------------------------------------------------------------
|
|
311
|
+
|
|
312
|
+
print("\n" + "═" * 60)
|
|
313
|
+
print(" SUMMARY")
|
|
314
|
+
print("═" * 60)
|
|
315
|
+
passed = sum(1 for _, ok, _ in results if ok)
|
|
316
|
+
total = len(results)
|
|
317
|
+
for name, ok, msg in results:
|
|
318
|
+
icon = PASS if ok else FAIL
|
|
319
|
+
line = f" {icon} {name}"
|
|
320
|
+
if not ok and msg:
|
|
321
|
+
line += f" — {msg}"
|
|
322
|
+
print(line)
|
|
323
|
+
print("─" * 60)
|
|
324
|
+
print(f" {passed}/{total} passed")
|
|
325
|
+
sys.exit(0 if passed == total else 1)
|