Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chroma db Code changed thats why unable to access the vectorstore from ChromaDB for embeddings #19848

Closed
5 tasks done
utkarshg1 opened this issue Apr 1, 2024 · 12 comments · Fixed by #19866
Closed
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: chroma Primarily related to ChromaDB integrations Ɑ: vector store Related to vector store module

Comments

@utkarshg1
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

# Python code
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import Chroma
vectorstore = Chroma.from_documents(documents=splits,
                                    embedding=OpenAIEmbeddings(model="text-embedding-3-large"), 
                                    persist_directory = "./chroma_db")

Error Message and Stack Trace (if applicable)

File /workspace/.pyenv_mirror/user/current/lib/python3.12/site-packages/chromadb/api/types.py:211, in validate_embedding_function(embedding_function)
208 protocol_signature = signature(EmbeddingFunction.call).parameters.keys()
210 if not function_signature == protocol_signature:
--> 211 raise ValueError(
212 f"Expected EmbeddingFunction.call to have the following signature: {protocol_signature}, got {function_signature}\n"
213 "Please see https://docs.trychroma.com/embeddings for details of the EmbeddingFunction interface.\n"
214 "Please note the recent change to the EmbeddingFunction interface: https://docs.trychroma.com/migration#migration-to-0416---november-7-2023 \n"
215 )

ValueError: Expected EmbeddingFunction.call to have the following signature: odict_keys(['self', 'input']), got odict_keys(['args', 'kwargs'])
Please see https://docs.trychroma.com/embeddings for details of the EmbeddingFunction interface.
Please note the recent change to the EmbeddingFunction interface: https://docs.trychroma.com/migration#migration-to-0416---november-7-2023

Description

I'm Trying to get Embeddings but looks like ChromaDB has changed functionality from their end.
Hence Langchain code also needs to be changed

https://docs.trychroma.com/embeddings/openai

System Info

langchain==0.1.14
langchain-community==0.0.30
langchain-core==0.1.37
langchain-openai==0.1.1
langchain-text-splitters==0.0.1
langchainhub==0.1.15
chromadb==0.4.24

@dosubot dosubot bot added Ɑ: vector store Related to vector store module 🔌: chroma Primarily related to ChromaDB integrations 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Apr 1, 2024
@wanjianwei
Copy link

i also met this error, and is looking for a solution

@srnsrn120
Copy link

Same issue i am also facing .

@Thabet-Chaaouri
Copy link

Same issue here

@srnsrn120
Copy link

Same issue i am also facing .

If Any Work Around is there please help

@liugddx
Copy link
Contributor

liugddx commented Apr 1, 2024

Let me see

@avoutsas67
Copy link

Same issue with me - it seems the version 0.4.16 of ChromaDB introduced a breaking change.

@liugddx
Copy link
Contributor

liugddx commented Apr 1, 2024

I tried the code and it works for me, what's the problem?

@avoutsas67
Copy link

avoutsas67 commented Apr 1, 2024

@liugddx see the top message in the thread by @utkarshg1. Describes the issue quite clearly.
Most likely you need to do a test on a clean venv where you have the versions mentioned above.

@liugddx
Copy link
Contributor

liugddx commented Apr 1, 2024

If you want a quick fix I have a solution

openai_ef = embedding_functions.OpenAIEmbeddingFunction(model_name="text-embedding-3-large",api_key=os.environ["OPENAI_API_KEY"])
vectorstore = Chroma.from_documents(documents=all_splits,
                                    embedding=openai_ef,
                                    persist_directory = "./chroma_db")

And change line 279 of chroma.py to the following method

            embeddings = self._embedding_function(texts)

@utkarshg1
Copy link
Author

Same issue i am also facing .

If Any Work Around is there please help

An easiest workaround for this is using the FAISS cpu as Vectorstore
Make sure you install faiss-cpu package as well

pip install faiss-cpu

Python code below:

# Index
from langchain_openai import OpenAIEmbeddings
from langchain_community.vectorstores import FAISS
vectorstore = FAISS.from_documents(documents=splits,
                                   embedding=OpenAIEmbeddings())

# Retriever
vectorstore.as_retriever()

@srnsrn120
Copy link

_embedding_function

No , Now i am using Multi vector retriever, i am not able to use Faiss or QdrantClient, only Chroma i am able to use
So thats why i wanted Chroma work around .

baskaryan added a commit that referenced this issue Apr 1, 2024
…e… (#19866)

…mbedding_function` (#19277)"

This reverts commit 7042934.

Fixes #19848
Sukitly added a commit to Sukitly/langchain that referenced this issue Apr 1, 2024
feat: update

fix: fix spell

docs: remove unnecessary args from the pip install (langchain-ai#19823)

**Description:** An additional `U` argument was added for the
instructions to install the pip packages for the MediaWiki Dump Document
loader which was leading to error in installing the package. Removing
the argument fixed the command to install.

**Issue:** langchain-ai#19820
**Dependencies:** No dependency change requierd
**Twitter handle:** [@vardhaman722](https://twitter.com/vardhaman722)

Update cross_encoder_reranker.ipynb (langchain-ai#19846)

HuggingFace -> Hugging Face

core: generate mermaid syntax and render visual graph (langchain-ai#19599)

- **Description:** Add functionality to generate Mermaid syntax and
render flowcharts from graph data. This includes support for custom node
colors and edge curve styles, as well as the ability to export the
generated graphs to PNG images using either the Mermaid.INK API or
Pyppeteer for local rendering.
- **Dependencies:** Optional dependencies are `pyppeteer` if rendering
wants to be done using Pypeteer and Javascript code.

---------

Co-authored-by: Angel Igareta <angel.igareta@klarna.com>
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>

feat: fix

feat: update

fix: fix lint

fix: fix lint

fix: fix lint

ai21[patch]: release 0.1.3 (langchain-ai#19867)

👥 Update LangChain people data (langchain-ai#19858)

👥 Update LangChain people data

Co-authored-by: github-actions <github-actions@github.com>

community[patch]: Revert " Fix the bug that Chroma does not specify `e… (langchain-ai#19866)

…mbedding_function` (langchain-ai#19277)"

This reverts commit 7042934.

Fixes langchain-ai#19848

fix: fix lint
@baskaryan
Copy link
Collaborator

Should be fixed in langchain-community==0.0.31, please let me know if you're still seeing an issue

marlenezw pushed a commit to marlenezw/langchain that referenced this issue Apr 2, 2024
hinthornw pushed a commit that referenced this issue Apr 26, 2024
…e… (#19866)

…mbedding_function` (#19277)"

This reverts commit 7042934.

Fixes #19848
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: chroma Primarily related to ChromaDB integrations Ɑ: vector store Related to vector store module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants