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: LangChain |
| #3 | --- |
| #4 | |
| #5 | Mem0 supports LangChain as a provider for vector store integration. LangChain provides a unified interface to various vector databases, making it easy to integrate different vector store providers through a consistent API. |
| #6 | |
| #7 | <Note> |
| #8 | When using LangChain as your vector store provider, you must set the collection name to "mem0". This is a required configuration for proper integration with Mem0. |
| #9 | </Note> |
| #10 | |
| #11 | ## Usage |
| #12 | |
| #13 | <CodeGroup> |
| #14 | ```python Python |
| #15 | import os |
| #16 | from mem0 import Memory |
| #17 | from langchain_community.vectorstores import Chroma |
| #18 | from langchain_openai import OpenAIEmbeddings |
| #19 | |
| #20 | # Initialize a LangChain vector store |
| #21 | embeddings = OpenAIEmbeddings() |
| #22 | vector_store = Chroma( |
| #23 | persist_directory="./chroma_db", |
| #24 | embedding_function=embeddings, |
| #25 | collection_name="mem0" # Required collection name |
| #26 | ) |
| #27 | |
| #28 | # Pass the initialized vector store to the config |
| #29 | config = { |
| #30 | "vector_store": { |
| #31 | "provider": "langchain", |
| #32 | "config": { |
| #33 | "client": vector_store |
| #34 | } |
| #35 | } |
| #36 | } |
| #37 | |
| #38 | m = Memory.from_config(config) |
| #39 | messages = [ |
| #40 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #41 | {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."}, |
| #42 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #43 | {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."} |
| #44 | ] |
| #45 | m.add(messages, user_id="alice", metadata={"category": "movies"}) |
| #46 | ``` |
| #47 | |
| #48 | ```typescript TypeScript |
| #49 | import { Memory } from "mem0ai"; |
| #50 | import { OpenAIEmbeddings } from "@langchain/openai"; |
| #51 | import { MemoryVectorStore as LangchainMemoryStore } from "langchain/vectorstores/memory"; |
| #52 | |
| #53 | const embeddings = new OpenAIEmbeddings(); |
| #54 | const vectorStore = new LangchainVectorStore(embeddings); |
| #55 | |
| #56 | const config = { |
| #57 | "vector_store": { |
| #58 | "provider": "langchain", |
| #59 | "config": { "client": vectorStore } |
| #60 | } |
| #61 | } |
| #62 | |
| #63 | const memory = new Memory(config); |
| #64 | |
| #65 | const messages = [ |
| #66 | { role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" }, |
| #67 | { role: "assistant", content: "How about thriller movies? They can be quite engaging." }, |
| #68 | { role: "user", content: "I'm not a big fan of thriller movies but I love sci-fi movies." }, |
| #69 | { role: "assistant", content: "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future." } |
| #70 | ] |
| #71 | |
| #72 | await memory.add(messages, { userId: "alice", metadata: { category: "movies" } }); |
| #73 | ``` |
| #74 | </CodeGroup> |
| #75 | |
| #76 | ## Supported LangChain Vector Stores |
| #77 | |
| #78 | LangChain supports a wide range of vector store providers, including: |
| #79 | |
| #80 | - Chroma |
| #81 | - FAISS |
| #82 | - Pinecone |
| #83 | - Weaviate |
| #84 | - Milvus |
| #85 | - Qdrant |
| #86 | - And many more |
| #87 | |
| #88 | You can use any of these vector store instances directly in your configuration. For a complete and up-to-date list of available providers, refer to the [LangChain Vector Stores documentation](https://python.langchain.com/docs/integrations/vectorstores). |
| #89 | |
| #90 | ## Limitations |
| #91 | |
| #92 | When using LangChain as a vector store provider, there are some limitations to be aware of: |
| #93 | |
| #94 | 1. **Bulk Operations**: The `get_all` and `delete_all` operations are not supported when using LangChain as the vector store provider. This is because LangChain's vector store interface doesn't provide standardized methods for these bulk operations across all providers. |
| #95 | |
| #96 | 2. **Provider-Specific Features**: Some advanced features may not be available depending on the specific vector store implementation you're using through LangChain. |
| #97 | |
| #98 | ## Provider-Specific Configuration |
| #99 | |
| #100 | When using LangChain as a vector store provider, you'll need to: |
| #101 | |
| #102 | 1. Set the appropriate environment variables for your chosen vector store provider |
| #103 | 2. Import and initialize the specific vector store class you want to use |
| #104 | 3. Pass the initialized vector store instance to the config |
| #105 | |
| #106 | <Note> |
| #107 | Make sure to install the necessary LangChain packages and any provider-specific dependencies. |
| #108 | </Note> |
| #109 | |
| #110 | ## Config |
| #111 | |
| #112 | All available parameters for the `langchain` vector store config are present in [Master List of All Params in Config](../config). |
| #113 |