repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: AWS Bedrock |
| #3 | --- |
| #4 | |
| #5 | This integration demonstrates how to use **Mem0** with **AWS Bedrock** and **Amazon OpenSearch Service (AOSS)** to enable persistent, semantic memory in intelligent agents. |
| #6 | |
| #7 | ## Overview |
| #8 | |
| #9 | In this guide, you'll: |
| #10 | |
| #11 | 1. Configure AWS credentials to enable Bedrock and OpenSearch access |
| #12 | 2. Set up the Mem0 SDK to use Bedrock for embeddings and LLM |
| #13 | 3. Store and retrieve memories using OpenSearch as a vector store |
| #14 | 4. Build memory-aware applications with scalable cloud infrastructure |
| #15 | |
| #16 | ## Prerequisites |
| #17 | |
| #18 | - AWS account with access to: |
| #19 | - Bedrock foundation models (e.g., Titan, Claude) |
| #20 | - OpenSearch Service with a configured domain |
| #21 | - Python 3.8+ |
| #22 | - Valid AWS credentials (via environment or IAM role) |
| #23 | |
| #24 | ## Setup and Installation |
| #25 | |
| #26 | Install required packages: |
| #27 | |
| #28 | ```bash |
| #29 | pip install mem0ai boto3 opensearch-py |
| #30 | ``` |
| #31 | |
| #32 | Set environment variables. |
| #33 | |
| #34 | Configure your AWS credentials using environment variables, IAM roles, or the AWS CLI. |
| #35 | |
| #36 | ```python |
| #37 | import os |
| #38 | |
| #39 | os.environ['AWS_REGION'] = 'us-west-2' |
| #40 | os.environ['AWS_ACCESS_KEY_ID'] = 'AKIA...' |
| #41 | os.environ['AWS_SECRET_ACCESS_KEY'] = 'AS...' |
| #42 | ``` |
| #43 | |
| #44 | ## Initialize Mem0 Integration |
| #45 | |
| #46 | Import necessary modules and configure Mem0: |
| #47 | |
| #48 | ```python |
| #49 | import boto3 |
| #50 | from opensearchpy import OpenSearch, RequestsHttpConnection, AWSV4SignerAuth |
| #51 | from mem0.memory.main import Memory |
| #52 | |
| #53 | region = 'us-west-2' |
| #54 | service = 'aoss' |
| #55 | credentials = boto3.Session().get_credentials() |
| #56 | auth = AWSV4SignerAuth(credentials, region, service) |
| #57 | |
| #58 | config = { |
| #59 | "embedder": { |
| #60 | "provider": "aws_bedrock", |
| #61 | "config": { |
| #62 | "model": "amazon.titan-embed-text-v2:0" |
| #63 | } |
| #64 | }, |
| #65 | "llm": { |
| #66 | "provider": "aws_bedrock", |
| #67 | "config": { |
| #68 | "model": "anthropic.claude-3-5-haiku-20241022-v1:0", |
| #69 | "temperature": 0.1, |
| #70 | "max_tokens": 2000 |
| #71 | } |
| #72 | }, |
| #73 | "vector_store": { |
| #74 | "provider": "opensearch", |
| #75 | "config": { |
| #76 | "collection_name": "mem0", |
| #77 | "host": "your-opensearch-domain.us-west-2.es.amazonaws.com", |
| #78 | "port": 443, |
| #79 | "http_auth": auth, |
| #80 | "embedding_model_dims": 1024, |
| #81 | "connection_class": RequestsHttpConnection, |
| #82 | "pool_maxsize": 20, |
| #83 | "use_ssl": True, |
| #84 | "verify_certs": True |
| #85 | } |
| #86 | } |
| #87 | } |
| #88 | |
| #89 | # Initialize memory system |
| #90 | m = Memory.from_config(config) |
| #91 | ``` |
| #92 | |
| #93 | ## Memory Operations |
| #94 | |
| #95 | Use Mem0 with your Bedrock-powered LLM and OpenSearch storage backend: |
| #96 | |
| #97 | ```python |
| #98 | # Store conversational context |
| #99 | messages = [ |
| #100 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #101 | {"role": "assistant", "content": "How about a thriller?"}, |
| #102 | {"role": "user", "content": "I prefer sci-fi."}, |
| #103 | {"role": "assistant", "content": "Noted! I'll suggest sci-fi movies next time."} |
| #104 | ] |
| #105 | |
| #106 | m.add(messages, user_id="alice", metadata={"category": "movie_recommendations"}) |
| #107 | |
| #108 | # Search for memory |
| #109 | relevant = m.search("What kind of movies does Alice like?", user_id="alice") |
| #110 | |
| #111 | # Retrieve all user memories |
| #112 | all_memories = m.get_all(user_id="alice") |
| #113 | ``` |
| #114 | |
| #115 | ## Key Features |
| #116 | |
| #117 | 1. **Serverless Memory Embeddings**: Use Titan or other Bedrock models for fast, cloud-native embeddings |
| #118 | 2. **Scalable Vector Search**: Store and retrieve vectorized memories via OpenSearch |
| #119 | 3. **Seamless AWS Auth**: Uses AWS IAM or environment variables to securely authenticate |
| #120 | 4. **User-specific Memory Spaces**: Memories are isolated per user ID |
| #121 | 5. **Persistent Memory Context**: Maintain and recall history across sessions |
| #122 | |
| #123 | <CardGroup cols={2}> |
| #124 | <Card title="AWS Bedrock Cookbook" icon="aws" href="/cookbooks/integrations/aws-bedrock"> |
| #125 | Complete guide to using Bedrock with Mem0 |
| #126 | </Card> |
| #127 | <Card title="Neptune Analytics Cookbook" icon="database" href="/cookbooks/integrations/neptune-analytics"> |
| #128 | Build graph memory with AWS Neptune |
| #129 | </Card> |
| #130 | </CardGroup> |
| #131 | |
| #132 |