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 | [OpenSearch](https://opensearch.org/) is an enterprise-grade search and observability suite that brings order to unstructured data at scale. OpenSearch supports k-NN (k-Nearest Neighbors) and allows you to store and retrieve high-dimensional vector embeddings efficiently. |
| #2 | |
| #3 | ### Installation |
| #4 | |
| #5 | OpenSearch support requires additional dependencies. Install them with: |
| #6 | |
| #7 | ```bash |
| #8 | pip install opensearch-py |
| #9 | ``` |
| #10 | |
| #11 | ### Prerequisites |
| #12 | |
| #13 | Before using OpenSearch with Mem0, you need to set up a collection in AWS OpenSearch Service. |
| #14 | |
| #15 | #### AWS OpenSearch Service |
| #16 | You can create a collection through the AWS Console: |
| #17 | - Navigate to [OpenSearch Service Console](https://console.aws.amazon.com/aos/home) |
| #18 | - Click "Create collection" |
| #19 | - Select "Serverless collection" and then enable "Vector search" capabilities |
| #20 | - Once created, note the endpoint URL (host) for your configuration |
| #21 | |
| #22 | |
| #23 | ### Usage |
| #24 | |
| #25 | ```python |
| #26 | import os |
| #27 | from mem0 import Memory |
| #28 | import boto3 |
| #29 | from opensearchpy import OpenSearch, RequestsHttpConnection, AWSV4SignerAuth |
| #30 | |
| #31 | # For AWS OpenSearch Service with IAM authentication |
| #32 | region = 'us-west-2' |
| #33 | service = 'aoss' |
| #34 | credentials = boto3.Session().get_credentials() |
| #35 | auth = AWSV4SignerAuth(credentials, region, service) |
| #36 | |
| #37 | config = { |
| #38 | "vector_store": { |
| #39 | "provider": "opensearch", |
| #40 | "config": { |
| #41 | "collection_name": "mem0", |
| #42 | "host": "your-domain.us-west-2.aoss.amazonaws.com", |
| #43 | "port": 443, |
| #44 | "http_auth": auth, |
| #45 | "embedding_model_dims": 1024, |
| #46 | "connection_class": RequestsHttpConnection, |
| #47 | "pool_maxsize": 20, |
| #48 | "use_ssl": True, |
| #49 | "verify_certs": True |
| #50 | } |
| #51 | } |
| #52 | } |
| #53 | ``` |
| #54 | |
| #55 | ### Add Memories |
| #56 | |
| #57 | ```python |
| #58 | m = Memory.from_config(config) |
| #59 | messages = [ |
| #60 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #61 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #62 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #63 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #64 | ] |
| #65 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #66 | ``` |
| #67 | |
| #68 | ### Search Memories |
| #69 | |
| #70 | ```python |
| #71 | results = m.search("What kind of movies does Alice like?", user_id="alice") |
| #72 | ``` |
| #73 | |
| #74 | ### Features |
| #75 | |
| #76 | - Fast and Efficient Vector Search |
| #77 | - Can be deployed on-premises, in containers, or on cloud platforms like AWS OpenSearch Service |
| #78 | - Multiple authentication and security methods (Basic Authentication, API Keys, LDAP, SAML, and OpenID Connect) |
| #79 | - Automatic index creation with optimized mappings for vector search |
| #80 | - Memory optimization through disk-based vector search and quantization |
| #81 | - Real-time analytics and observability |
| #82 |