langchain: Bug after the openai updated in Embedding
System Info
AWS Sagemaker DataScience3.0 Image.
Who can help?
No response
Information
- The official example notebooks/scripts
- My own modified scripts
Related Components
- LLMs/Chat Models
- Embedding Models
- Prompts / Prompt Templates / Prompt Selectors
- Output Parsers
- Document Loaders
- Vector Stores / Retrievers
- Memory
- Agents / Agent Executors
- Tools / Toolkits
- Chains
- Callbacks/Tracing
- Async
Reproduction
here is my code, it worked before Nov 7th.
Chroma.from_documents(documents=document, embedding=embeddings,)
Then i get this error:
ValueError: Expected EmbeddingFunction.__call__ to have the following signature: odict_keys(['self', 'input']), got odict_keys(['self', '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
Expected behavior
Is anyone know how to fix this?
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 5
- Comments: 22 (3 by maintainers)
Commits related to this issue
- Fix chromadb also pin. See https://github.com/langchain-ai/langchain/issues/13051#issuecomment-1801478715 — committed to dennisdegreef/restai by dennisdegreef 8 months ago
š¤
The error youāre encountering is due to a recent change in the
EmbeddingFunctioninterface. TheEmbeddingFunction.__call__method now expects two arguments:selfandinput. However, it seems that in your code, theEmbeddingFunction.__call__method is being called withself,args, andkwargs.To resolve this issue, you need to update the way youāre calling the
EmbeddingFunction.__call__method. Instead of passingargsandkwargs, you should pass a singleinputargument.Hereās how you can do it:
In the
prepare_inputmethod, you should prepare theinputargument in a way that is compatible with the newEmbeddingFunction.__call__interface.Also, you might need to adjust the
predict_fn()function within the custominference.pyscript to handle batched requests. Change the return line fromreturn {"vectors": sentence_embeddings[0].tolist()}toreturn {"vectors": sentence_embeddings.tolist()}.Please refer to the following sources for more information:
I hope this helps! If you have any further questions or if something is unclear, please let me know.
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a š if this is helpful and š if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Problem seems to appear with chroma update to 0.4.16
Pinning to previous version seems to help.
Langchain still implements the old interface. See: https://docs.trychroma.com/migration#migration-to-0416---november-7-2023
I still met the problem, all the library are the latest version, here are my code:
and here is the error info:
Thank you š
My hero!