-
Notifications
You must be signed in to change notification settings - Fork 155
docs: add Synap managed memory integration #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
visy-ani
wants to merge
8
commits into
deepset-ai:main
Choose a base branch
from
visy-ani:add-synap-memory-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2465551
docs: add Synap managed memory integration
visy-ani 9a253bc
Potential fix for pull request finding
visy-ani 30f51c1
docs(synap): add open source backlink to integration package
visy-ani 1c66d18
fix(synap): use env var for API key, remove unused imports, add write…
visy-ani 5e52675
fix(synap): simplify Full Pipeline Example to runnable retrieval-only…
visy-ani a24e2ef
docs(synap): address review — fix repo path, add License section + TO…
visy-ani bf515e8
Potential fix for pull request finding
kacperlukawski 118c619
docs(synap): restructure around SynapMemoryStore to match Mem0 pattern
visy-ani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| --- | ||
| layout: integration | ||
| name: Synap | ||
| description: Add persistent, cross-session user memory to your Haystack agents and pipelines with Synap | ||
| authors: | ||
| - name: Maximem | ||
| socials: | ||
| github: maximem-ai | ||
| linkedin: https://www.linkedin.com/company/maximem/ | ||
| pypi: https://pypi.org/project/maximem-synap-haystack/ | ||
| repo: https://github.com/maximem-ai/maximem_synap_sdk/tree/main/packages/integrations/synap-haystack | ||
| type: Memory Store | ||
| report_issue: https://github.com/maximem-ai/maximem_synap/issues | ||
| version: Haystack 2.0 | ||
| toc: true | ||
| --- | ||
|
|
||
| ### Table of Contents | ||
|
|
||
| - [Overview](#overview) | ||
| - [Installation](#installation) | ||
| - [Usage](#usage) | ||
| - [Available Classes](#available-classes) | ||
| - [Standalone Memory Operations](#standalone-memory-operations) | ||
| - [Use in a Pipeline](#use-in-a-pipeline) | ||
| - [More Resources](#more-resources) | ||
| - [License](#license) | ||
|
|
||
| ## Overview | ||
|
|
||
| [Synap](https://maximem.ai) is a managed long-term memory layer for AI agents. It runs a full extraction pipeline on every conversation turn — automatically identifying facts, preferences, episodes, emotions, and temporal events — and retrieves only what is semantically relevant to the current query. | ||
|
|
||
| The `maximem-synap-haystack` package provides a Haystack-native memory store that follows the same shape as `mem0-haystack`: | ||
|
|
||
| - **`SynapMemoryStore`**: A persistent memory store backed by the Synap API. Owns all SDK interaction (`add_memories` / `search_memories` / `search_memories_as_single_message`). | ||
| - **`SynapMemoryRetriever`** and **`SynapMemoryWriter`**: Pipeline `@component` classes for retrieving memories as `ChatMessage` objects and writing conversation turns to the store. | ||
| - **`SynapRetriever`**: An additional `@component` that returns memories as `Document` objects for classic RAG-style pipelines. | ||
|
|
||
| Memory is scoped to the `user_id` and `customer_id` you provide, ensuring strict isolation in multi-tenant applications. | ||
|
|
||
| More information: | ||
|
|
||
| - [Synap website](https://maximem.ai) | ||
| - [Synap documentation](https://docs.maximem.ai) | ||
| - [Synap GitHub repository](https://github.com/maximem-ai/maximem_synap_sdk) | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install maximem-synap-haystack | ||
| ``` | ||
|
|
||
| Set your Synap API key: | ||
|
|
||
| ```bash | ||
| export SYNAP_API_KEY="your-synap-api-key" | ||
| ``` | ||
|
|
||
| You can obtain an API key at [synap.maximem.ai](https://synap.maximem.ai). | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Available Classes | ||
|
|
||
| - **`SynapMemoryStore`**: The memory store — a plain object (not a `@component`) that owns all Synap SDK interaction. Use it directly for standalone read/write, or pass it to the components below. | ||
| - **`SynapMemoryRetriever`**: Retrieves memories from Synap as system `ChatMessage` objects. Mem0-shaped chat read path. | ||
| - **`SynapMemoryWriter`**: Writes user / assistant `ChatMessage` objects to Synap. Returns per-message status so callers can branch on partial failures. | ||
| - **`SynapRetriever`**: Alternate retriever that returns Haystack `Document` objects (RAG-style read path). | ||
|
|
||
| ### Standalone Memory Operations | ||
|
|
||
| You can use `SynapMemoryStore` directly to add and search memories: | ||
|
|
||
| ```python | ||
| import os | ||
|
|
||
| from haystack.dataclasses import ChatMessage | ||
| from maximem_synap import MaximemSynapSDK | ||
| from synap_haystack import SynapMemoryStore | ||
|
|
||
| sdk = MaximemSynapSDK(api_key=os.environ["SYNAP_API_KEY"]) | ||
| store = SynapMemoryStore(sdk, user_id="alice", customer_id="acme_corp") | ||
|
|
||
| # Write — extracted server-side into long-term memory | ||
| store.add_memories( | ||
| messages=[ChatMessage.from_user("I prefer window seats and aisle on red-eyes.")], | ||
| conversation_id="conv_abc", | ||
| ) | ||
|
|
||
| # Read — semantic, query-driven | ||
| memories = store.search_memories(query="seat preference") | ||
| for msg in memories: | ||
| print(msg.text) | ||
|
|
||
| # Single-message variant — useful for prompt injection | ||
| context = store.search_memories_as_single_message(query="seat preference") | ||
| ``` | ||
|
|
||
| ### Use in a Pipeline | ||
|
|
||
| `SynapMemoryRetriever` and `SynapMemoryWriter` are thin `@component` wrappers around the store. Construct the store once and share it across both: | ||
|
|
||
| ```python | ||
| import os | ||
|
|
||
| from haystack import Pipeline | ||
| from haystack.components.builders import ChatPromptBuilder | ||
| from haystack.components.generators.chat import OpenAIChatGenerator | ||
| from maximem_synap import MaximemSynapSDK | ||
| from synap_haystack import SynapMemoryRetriever, SynapMemoryStore, SynapMemoryWriter | ||
|
|
||
| sdk = MaximemSynapSDK(api_key=os.environ["SYNAP_API_KEY"]) | ||
| store = SynapMemoryStore(sdk, user_id="alice", customer_id="acme_corp") | ||
|
|
||
| pipeline = Pipeline() | ||
| pipeline.add_component("memory_retriever", SynapMemoryRetriever(store=store)) | ||
| pipeline.add_component("prompt_builder", ChatPromptBuilder()) | ||
| pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o")) | ||
| pipeline.add_component("memory_writer", SynapMemoryWriter(store=store)) | ||
|
|
||
| pipeline.connect("memory_retriever.messages", "prompt_builder.template") | ||
| pipeline.connect("prompt_builder.prompt", "llm.messages") | ||
| ``` | ||
|
|
||
| For classic RAG pipelines that want `Document` objects rather than `ChatMessage` objects, use `SynapRetriever` instead of `SynapMemoryRetriever` — same store, different output shape. | ||
|
|
||
| ## More Resources | ||
|
|
||
| - [Synap Documentation](https://docs.maximem.ai) | ||
| - [Haystack Integration Guide](https://docs.maximem.ai/integrations/haystack) | ||
| - [Dashboard](https://synap.maximem.ai) | ||
| - [PyPI: maximem-synap-haystack](https://pypi.org/project/maximem-synap-haystack/) | ||
| - [Open source integration package](https://github.com/maximem-ai/maximem_synap_sdk/tree/main/packages/integrations/synap-haystack) | ||
|
|
||
| ## License | ||
|
|
||
| `maximem-synap-haystack` is released under the [Apache License 2.0](https://github.com/maximem-ai/maximem_synap_sdk/blob/main/LICENSE). | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.