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: Amazon S3 Vectors |
| #3 | --- |
| #4 | |
| #5 | [Amazon S3 Vectors](https://aws.amazon.com/s3/features/vectors/) is a purpose-built, cost-optimized vector storage and query service for semantic search and AI applications. It provides S3-level elasticity and durability with sub-second query performance. |
| #6 | |
| #7 | ### Installation |
| #8 | |
| #9 | S3 Vectors support requires additional dependencies. Install them with: |
| #10 | |
| #11 | ```bash |
| #12 | pip install boto3 |
| #13 | ``` |
| #14 | |
| #15 | ### Usage |
| #16 | |
| #17 | To use Amazon S3 Vectors with Mem0, you need to have an AWS account and the necessary IAM permissions (`s3vectors:*`). Ensure your environment is configured with AWS credentials (e.g., via `~/.aws/credentials` or environment variables). |
| #18 | |
| #19 | ```python |
| #20 | import os |
| #21 | from mem0 import Memory |
| #22 | |
| #23 | # Ensure your AWS credentials are configured in your environment |
| #24 | # e.g., by setting AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION |
| #25 | |
| #26 | config = { |
| #27 | "vector_store": { |
| #28 | "provider": "s3_vectors", |
| #29 | "config": { |
| #30 | "vector_bucket_name": "my-mem0-vector-bucket", |
| #31 | "collection_name": "my-memories-index", |
| #32 | "embedding_model_dims": 1536, |
| #33 | "distance_metric": "cosine", |
| #34 | "region_name": "us-east-1" |
| #35 | } |
| #36 | } |
| #37 | } |
| #38 | |
| #39 | m = Memory.from_config(config) |
| #40 | messages = [ |
| #41 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #42 | {"role": "assistant", "content": "How about a thriller movie? They can be quite engaging."}, |
| #43 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #44 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #45 | ] |
| #46 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #47 | ``` |
| #48 | |
| #49 | ### Config |
| #50 | |
| #51 | Here are the parameters available for configuring Amazon S3 Vectors: |
| #52 | |
| #53 | | Parameter | Description | Default Value | |
| #54 | | ---------------------- | -------------------------------------------------------------------------------- | ------------------------------------- | |
| #55 | | `vector_bucket_name` | The name of the S3 Vector bucket to use. It will be created if it doesn't exist. | Required | |
| #56 | | `collection_name` | The name of the vector index within the bucket. | `mem0` | |
| #57 | | `embedding_model_dims` | Dimensions of the embedding model. Must match your embedder. | `1536` | |
| #58 | | `distance_metric` | Distance metric for similarity search. Options: `cosine`, `euclidean`. | `cosine` | |
| #59 | | `region_name` | The AWS region where the bucket and index reside. | `None` (uses default from AWS config) | |
| #60 | |
| #61 | ### IAM Permissions |
| #62 | |
| #63 | Your AWS identity (user or role) needs permissions to perform actions on S3 Vectors. A minimal policy would look like this: |
| #64 | |
| #65 | ```json |
| #66 | { |
| #67 | "Version": "2012-10-17", |
| #68 | "Statement": [ |
| #69 | { |
| #70 | "Effect": "Allow", |
| #71 | "Action": "s3vectors:*", |
| #72 | "Resource": "*" |
| #73 | } |
| #74 | ] |
| #75 | } |
| #76 | ``` |
| #77 | |
| #78 | For production, it is recommended to scope down the resource ARN to your specific buckets and indexes. |
| #79 |