How do vectorstores work on Convex with Langchain?
I am making a chatbot of sorts with retrieval QA on langchain using Convex's vectorstore. I'm storing documents embedded in Convex, but wondering how I can access multiple vectorstores by name? Currently in schema.ts, I have a basic schema example for a simple vector db.
I'm wondering how I can make more vector dbs than just one named "documents", ie, for multiple users where each user might have their own vectdb with their name. Currently accessing the vector db in langchain through
new ConvexVectorStore(new OpenAIEmbeddings({ openAIApiKey: secretKey }), { ctx });
, and I don't see anywhere to pass in string names of the vector db to use or if I wanted to create a new vector db with a specific name. Curious how I might be able to achieve this?7 Replies
Each vector index is on a table. If you want to separate vector stores by user, you can add a
filterField
and then filter by that user.Here's an article on using Vector search with Langchain and Convex: https://stack.convex.dev/ai-chat-using-langchain-and-convex
Build AI Chat with LangChain and Convex
In this second post in our series, we’ll build an AI-powered chat interface using LangChain and its new Convex integration.
There's some other ones in the series if you want to build a fully custom RAG application
With langchain though, I'm not sure how to filter it because usage is as follows:
Additionally how can I create filter fields for multiple users? It seems convex is limited to 16 fields as well, so I'm not sure I can create a vector store for each user
the field would be the userid, so every user could be filtered with one field. @Michal Srb may be more familiar with filtering in LangChain
Hey @Helmet:
- If you do have different tables, you can configure ConvexVectorStore to read from a different table
- Don't use LangChain if you want to filter by another field (see https://stack.convex.dev/ai-chat-with-convex-vector-search instead)
- To filter for multiple users, you can run multiple vector search reads, one for each user.
Build AI Chat with Convex Vector Search
Convex is a full-stack development platform and cloud database, including built-in vector search. In this third post in our [series](https://stack.con...
And see here for how to use
q.or
to search for many users with one search: https://docs.convex.dev/vector-search#filter-expressionsVector Search | Convex Developer Hub
Run vector search queries on embeddings