-
Notifications
You must be signed in to change notification settings - Fork 189
Feature/mongodb atlas memory tool #281
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
9a7611a
3b958e1
175c935
ba95d4b
eb17be8
1381918
a974240
e09fa81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -886,6 +886,76 @@ result = agent.tool.elasticsearch_memory( | |||
| ) | ||||
| ``` | ||||
|
|
||||
| ### MongoDB Atlas Memory | ||||
|
|
||||
| **Note**: This tool requires AWS account credentials to generate embeddings using Amazon Bedrock Titan models. | ||||
|
|
||||
| ```python | ||||
| from strands import Agent | ||||
| from strands_tools.mongodb_memory import mongodb_memory | ||||
|
|
||||
| # Create agent with direct tool usage | ||||
| agent = Agent(tools=[mongodb_memory]) | ||||
|
|
||||
| # Store a memory with semantic embeddings | ||||
| result = agent.tool.mongodb_memory( | ||||
| action="record", | ||||
| content="User prefers vegetarian pizza with extra cheese", | ||||
| metadata={"category": "food_preferences", "type": "dietary"}, | ||||
| cluster_uri="mongodb+srv://user:[email protected]", | ||||
| database_name="memory_db", | ||||
| collection_name="memories", | ||||
| namespace="user_123" | ||||
| ) | ||||
|
|
||||
| # Search memories using semantic similarity (vector search) | ||||
| result = agent.tool.mongodb_memory( | ||||
| action="retrieve", | ||||
| query="food preferences and dietary restrictions", | ||||
| max_results=5, | ||||
| cluster_uri="mongodb+srv://user:[email protected]", | ||||
| database_name="memory_db", | ||||
| collection_name="memories", | ||||
| namespace="user_123" | ||||
| ) | ||||
|
|
||||
| # Use configuration dictionary for cleaner code | ||||
| config = { | ||||
| "cluster_uri": "mongodb+srv://user:[email protected]", | ||||
| "database_name": "memory_db", | ||||
| "collection_name": "memories", | ||||
| "namespace": "user_123" | ||||
| } | ||||
|
|
||||
| # List all memories with pagination | ||||
| result = agent.tool.mongodb_memory( | ||||
| action="list", | ||||
| max_results=10, | ||||
| **config | ||||
| ) | ||||
|
|
||||
| # Get specific memory by ID | ||||
| result = agent.tool.mongodb_memory( | ||||
| action="get", | ||||
| memory_id="mem_1234567890_abcd1234", | ||||
| **config | ||||
| ) | ||||
|
|
||||
| # Delete a memory | ||||
| result = agent.tool.mongodb_memory( | ||||
| action="delete", | ||||
| memory_id="mem_1234567890_abcd1234", | ||||
| **config | ||||
| ) | ||||
|
|
||||
| # Use environment variables for configuration | ||||
| result = agent.tool.mongodb_memory( | ||||
| action="record", | ||||
| content="User prefers vegetarian pizza" | ||||
| # cluster_uri, database_name, etc. will be read from environment variables | ||||
| ) | ||||
| ``` | ||||
|
|
||||
| ## 🌍 Environment Variables Configuration | ||||
|
|
||||
| Agents Tools provides extensive customization through environment variables. This allows you to configure tool behavior without modifying code, making it ideal for different environments (development, testing, production). | ||||
|
|
@@ -1105,9 +1175,38 @@ The Mem0 Memory Tool supports three different backend configurations: | |||
|
|
||||
| #### Retrieve Tool | ||||
|
|
||||
| | Environment Variable | Description | Default | | ||||
| |----------------------|-------------|---------| | ||||
| #### Retrieve Tool | ||||
|
|
||||
| | Environment Variable | Description | Default | | ||||
| |----------------------|-------------|---------| | ||||
| | RETRIEVE_ENABLE_METADATA_DEFAULT | Default setting for enabling metadata in retrieve tool responses | false | | ||||
| >>>>>>> origin/main | ||||
| | RETRIEVE_ENABLE_METADATA_DEFAULT | Default setting for enabling metadata in retrieve tool responses | false | | ||||
|
|
||||
| #### MongoDB Atlas Memory Tool | ||||
|
|
||||
| | Environment Variable | Description | Default | | ||||
| |----------------------|-------------|---------| | ||||
| | MONGODB_ATLAS_CLUSTER_URI | MongoDB Atlas connection URI | None | | ||||
| | MONGODB_DATABASE_NAME | Default database name for MongoDB operations | memory_db | | ||||
| | MONGODB_COLLECTION_NAME | Default collection name for MongoDB operations | memories | | ||||
| | MONGODB_NAMESPACE | Default namespace for memory isolation | default | | ||||
| | MONGODB_EMBEDDING_MODEL | Bedrock model for generating embeddings | amazon.titan-embed-text-v2:0 | | ||||
|
|
||||
| #### Retrieve Tool | ||||
|
|
||||
| | Environment Variable | Description | Default | | ||||
| |----------------------|-------------|---------| | ||||
| | RETRIEVE_ENABLE_METADATA_DEFAULT | Default setting for enabling metadata in retrieve tool responses | false | | ||||
| ======= | ||||
| #### Retrieve Tool | ||||
|
|
||||
| | Environment Variable | Description | Default | | ||||
| |----------------------|-------------|---------| | ||||
| | RETRIEVE_ENABLE_METADATA_DEFAULT | Default setting for enabling metadata in retrieve tool responses | false | | ||||
| >>>>>>> origin/main | ||||
|
||||
| >>>>>>> origin/main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this too ^^