QA Chain with Vertex AI using Langchain and Chroma

730 Views Asked by At

I'm trying to build a QA Chain using Langchain. If I try to define a vectorstore using Chroma and a list of documents through the code below:

from langchain.embeddings.vertexai import VertexAIEmbeddings
from langchain.vectorstores import Chroma 
vectorstore = Chroma.from_documents(documents=[Document(content="test")], 
                                    embedding=VertexAIEmbeddings())

I get the following error related to an update:

Please note the recent change to the EmbeddingFunction interface: https://docs.trychroma.com/migration#migration-to-0416---november-7-2023

Basically they altered the EmbeddingFunction class to receive any type of file (multimodal embedding) not only text. Is any work around to this error yet?

1

There are 1 best solutions below

1
On

I'm also having troubles using Chroma this way. Do you have a specific reason to use the VertexAIEmbeddings?

For me, it works fine now using the OpenAIEmbeddings:

from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Chroma 
from langchain.document_loaders import TextLoader

loader = TextLoader("./test.txt")
docs = loader.load()

vectorstore = Chroma.from_documents(documents=docs,embedding=OpenAIEmbeddings())