langchain/libs/partners/huggingface
af su 7c7ee07d30
huggingface[fix]: HuggingFaceEndpointEmbeddings model parameter passing error when async embed (#27953)
This change refines the handling of _model_kwargs in POST requests.
Instead of nesting _model_kwargs as a dictionary under the parameters
key, it is now directly unpacked and merged into the request's JSON
payload. This ensures that the model parameters are passed correctly and
avoids unnecessary nesting.E. g.:

```python
import asyncio

from langchain_huggingface.embeddings import HuggingFaceEndpointEmbeddings

embedding_input = ["This input will get multiplied" * 10000]

embeddings = HuggingFaceEndpointEmbeddings(
    model="http://127.0.0.1:8081/embed",
    model_kwargs={"truncate": True},
)

# Truncated parameters in synchronized methods are handled correctly
embeddings.embed_documents(texts=embedding_input)
# The truncate parameter is not handled correctly in the asynchronous method,
# and 413 Request Entity Too Large is returned.
asyncio.run(embeddings.aembed_documents(texts=embedding_input))
```

Co-authored-by: af su <saf@zjuici.com>
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-11-20 19:08:56 +00:00
..
langchain_huggingface huggingface[fix]: HuggingFaceEndpointEmbeddings model parameter passing error when async embed (#27953) 2024-11-20 19:08:56 +00:00
scripts multiple: pydantic 2 compatibility, v0.3 (#26443) 2024-09-13 14:38:45 -07:00
tests standard-tests: rename langchain_standard_tests to langchain_tests, release 0.3.2 (#28203) 2024-11-18 19:10:39 -08:00
.gitignore huggingface: init package (#21097) 2024-05-13 20:53:15 +00:00
LICENSE huggingface: init package (#21097) 2024-05-13 20:53:15 +00:00
Makefile standard-tests[patch]: add Ser/Des test 2024-09-04 10:24:06 -07:00
poetry.lock multiple: langchain-standard-tests -> langchain-tests (#28139) 2024-11-15 11:32:04 -08:00
pyproject.toml multiple: langchain-standard-tests -> langchain-tests (#28139) 2024-11-15 11:32:04 -08:00
README.md huggingface: init package (#21097) 2024-05-13 20:53:15 +00:00

langchain-huggingface

This package contains the LangChain integrations for huggingface related classes.

Installation and Setup

  • Install the LangChain partner package
pip install langchain-huggingface