generated from amazon-archives/__template_Apache-2.0
-
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
Open
ayanray089
wants to merge
8
commits into
strands-agents:main
Choose a base branch
from
ayanray089:feature/mongodb-atlas-memory-tool
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 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9a7611a
feat: Add MongoDB Atlas memory tool with comprehensive testing
3b958e1
feat: Add MongoDB Atlas Memory tool with comprehensive documentation
175c935
Remove test_mongodb_atlas.py from repository
ba95d4b
Add MongoDB Atlas memory tool implementation
eb17be8
Address PR review comments for MongoDB Atlas Memory Tool
1381918
Merge origin/main into feature/mongodb-atlas-memory-tool
a974240
Address PR review feedback: Remove unnecessary query parameters from …
e09fa81
Update MongoDB memory response size limits and fix unit tests
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 |
|---|---|---|
|
|
@@ -859,6 +859,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]/?retryWrites=true&w=majority", | ||
|
||
| 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]/?retryWrites=true&w=majority", | ||
| database_name="memory_db", | ||
| collection_name="memories", | ||
| namespace="user_123" | ||
| ) | ||
|
|
||
| # Use configuration dictionary for cleaner code | ||
| config = { | ||
| "cluster_uri": "mongodb+srv://user:[email protected]/?retryWrites=true&w=majority", | ||
| "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). | ||
|
|
@@ -1075,6 +1145,16 @@ The Mem0 Memory Tool supports three different backend configurations: | |
| | STRANDS_RSS_UPDATE_INTERVAL | Default amount of time between updating rss feeds in minutes | 60 | | ||
| | STRANDS_RSS_STORAGE_PATH | Default storage path where rss feeds are stored locally | strands_rss_feeds (this may vary based on your system) | | ||
|
|
||
| #### 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 | | ||
|
|
||
| #### Video Tools | ||
|
|
||
| | Environment Variable | Description | Default | | ||
|
|
||
Oops, something went wrong.
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.
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.
I believe cluster_uri can be defined upfront (using class based init) so the agents have no access to possible sensitive information like password of cluster