Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
95bcbd1
Add config
andy-k-improving Sep 19, 2025
8f92265
Update llm
andy-k-improving Sep 22, 2025
89598fd
Add error msg
andy-k-improving Sep 22, 2025
575c1be
Update vector config handling
andy-k-improving Sep 22, 2025
3be04a6
Update Graph store
andy-k-improving Sep 22, 2025
16f7499
Remove debug
andy-k-improving Sep 22, 2025
125e308
Fix lint
andy-k-improving Sep 22, 2025
e86d868
Update test
andy-k-improving Sep 22, 2025
33a0459
Update tests
andy-k-improving Sep 22, 2025
c9637b5
Update lint
andy-k-improving Sep 23, 2025
fc59bfb
Update test
andy-k-improving Sep 23, 2025
926bef1
Remove default config
andy-k-improving Sep 25, 2025
6d85c15
Update config
andy-k-improving Sep 25, 2025
8827750
Update display of stored message
andy-k-improving Sep 29, 2025
47a5f94
Consolidate var
andy-k-improving Oct 8, 2025
42a64d2
Update test
andy-k-improving Oct 8, 2025
105c854
Test cases
andy-k-improving Sep 29, 2025
2191a61
Update test data
andy-k-improving Sep 29, 2025
48849ed
Update lint
andy-k-improving Oct 2, 2025
d8dafa5
Update faiss default strategy
andy-k-improving Oct 6, 2025
27a688c
Update display for store entries
andy-k-improving Oct 6, 2025
69be35a
Update logic
andy-k-improving Oct 7, 2025
7bce9f2
Update config hanlding
andy-k-improving Oct 7, 2025
1e8a4bc
Update test
andy-k-improving Oct 8, 2025
474ccd1
Update wording
andy-k-improving Oct 8, 2025
42f585f
Merge branch 'main' into ft-hf-neptune-db-support
andy-k-improving Oct 15, 2025
f7c7ea4
Update method naming
andy-k-improving Oct 15, 2025
30926e9
Update cosine hanlding
andy-k-improving Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/strands_tools/mem0_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,22 @@ def _initialize_client(self, config: Optional[Dict] = None) -> Any:
merged_config = self._append_faiss_config(config)

# Graph backend providers

# Graph backend providers
if os.environ.get("NEPTUNE_ANALYTICS_GRAPH_IDENTIFIER") and os.environ.get("NEPTUNE_DATABASE_ENDPOINT"):
raise RuntimeError("""Conflicting backend configurations:
Both NEPTUNE_ANALYTICS_GRAPH_IDENTIFIER and NEPTUNE_DATABASE_ENDPOINT environment variables are set.
Please specify only one graph backend.""")

if os.environ.get("NEPTUNE_ANALYTICS_GRAPH_IDENTIFIER"):
logger.debug("Using Neptune Analytics graph backend (Mem0Memory with Neptune Analytics)")
merged_config = self._append_neptune_analytics_graph_config(merged_config)

elif os.environ.get("NEPTUNE_DATABASE_ENDPOINT"):
logger.debug("Using Neptune Database graph backend (Mem0Memory with Neptune Database)")
merged_config = self._append_neptune_database_backend(merged_config)


return Mem0Memory.from_config(config_dict=merged_config)

def _append_neptune_analytics_vector_config(self, config: Optional[Dict] = None) -> Dict:
Expand All @@ -234,6 +246,26 @@ def _append_neptune_analytics_vector_config(self, config: Optional[Dict] = None)
}
return self._merge_config(config)

def _append_neptune_database_backend(self, config: Optional[Dict] = None) -> Dict:
"""Update incoming configuration dictionary to include the configuration of Neptune Database graph backend.

Args:
config: Optional configuration dictionary to override defaults.

Returns:
An configuration dict with graph backend.
"""
config = config or {}
config["graph_store"] = {
"provider": "neptunedb",
"config": {"endpoint": f"neptune-db://{os.environ.get('NEPTUNE_DATABASE_ENDPOINT')}"},
}
# To retrieve cosine similarity score instead for Faiss.
if "faiss" == config.get("vector_store", {}).get("provider"):
config["vector_store"]["config"]["distance_strategy"] = "cosine"

return config

def _append_opensearch_config(self, config: Optional[Dict] = None) -> Dict:
"""Update incoming configuration dictionary to include the configuration of OpenSearch vector backend.

Expand Down
10 changes: 10 additions & 0 deletions tests/test_mem0.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,16 @@ def test_mem0_service_client_init(mock_opensearch, mock_mem0_memory, mock_sessio
client = Mem0ServiceClient()
assert client.mem0 is not None

# Test with Neptune Database with OpenSearch
with patch.dict(
os.environ,
{"OPENSEARCH_HOST": "test.opensearch.amazonaws.com",
"NEPTUNE_DATABASE_ENDPOINT": "xxx.us-west-2.neptune.amazonaws.com"},
):
client = Mem0ServiceClient()
assert client.region == os.environ.get("AWS_REGION", "us-west-2")
assert client.mem0 is not None

# Test with custom config (OpenSearch)
custom_config = {
"embedder": {"provider": "custom", "config": {"model": "custom-model"}},
Expand Down