Connect To An Existing SpaceΒΆ
This is the best starting workflow for most LangChain users.
Choose this path when you already have a GoodMem space_id and you want to:
write texts or LangChain
Documentvalues into that spacerun semantic retrieval without managing embeddings locally
keep the LangChain integration as thin as possible
Important behavior to keep in mind while you read the example below:
each write call creates one or more GoodMem memories
each search result is a chunk-level LangChain
DocumentDocument.idin search results is the GoodMem chunk ID, not the memory IDmetadata filters operate on the stored memory metadata using the GoodMem filter language, for example
val('$.lang') = 'en'
Existing-space add/search workflow for GoodMemVectorStore.
This example is the runnable source of truth for the most common workflow: bind the vector store to an existing GoodMem space, add multiple documents, then run chunk-level semantic retrieval with and without scores.
Prerequisites:
install the package with
pip install -e .provide a valid GoodMem API key and base URL
create or identify a GoodMem space ahead of time
obtain that
space_idfrom the GoodMem SDK, CLI, or web console, or useGoodMemVectorStore.create(...)in a separate setup step
Run the example by editing the placeholder connection values and space_id,
then execute:
./.venv/bin/python examples/basic_semantic_search.py
Expected output:
created memory IDs from
add_documents(...)one chunk-level retrieval listing whose
Document.idvalues are chunk IDsone scored retrieval listing
The filter examples use the documented GoodMem filter language. In particular,
memory metadata fields are read with expressions such as
val('$.lang') = 'en'.
Search visibility is eventually consistent. Fresh writes may not appear in semantic retrieval immediately after the add call returns.