From bc5fafa20e0e6eb6619e5f025863d6595a8cdf10 Mon Sep 17 00:00:00 2001 From: Akmal Ali Jasmin Date: Sun, 9 Feb 2025 01:11:02 +0530 Subject: [PATCH] [DOC] Fix #29685: HuggingFaceEndpoint missing task argument in documentation (#29686) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR updates the LangChain documentation to address an issue where the `HuggingFaceEndpoint` example **does not specify the required `task` argument**. Without this argument, users on `huggingface_hub == 0.28.1` encounter the following error: ``` ValueError: Task unknown has no recommended model. Please specify a model explicitly. ``` --- ## **Issue** Fixes #29685 --- ## **Changes Made** ✅ **Updated `HuggingFaceEndpoint` documentation** to explicitly define `task="text-generation"`: ```python llm = HuggingFaceEndpoint( repo_id=GEN_MODEL_ID, huggingfacehub_api_token=HF_TOKEN, task="text-generation" # Explicitly specify task ) ``` ✅ **Added a deprecation warning note** and recommended using `InferenceClient`: ```python from huggingface_hub import InferenceClient from langchain.llms.huggingface_hub import HuggingFaceHub client = InferenceClient(model=GEN_MODEL_ID, token=HF_TOKEN) llm = HuggingFaceHub( repo_id=GEN_MODEL_ID, huggingfacehub_api_token=HF_TOKEN, client=client, ) ``` --- ## **Dependencies** - No new dependencies introduced. - Change only affects **documentation**. --- ## **Testing** - ✅ Verified that adding `task="text-generation"` resolves the issue. - ✅ Tested the alternative approach with `InferenceClient` in Google Colab. --- ## **Twitter Handle (Optional)** If this PR gets announced, a shout-out to **@AkmalJasmin** would be great! 🚀 --- ## **Reviewers** 📌 **@langchain-maintainers** Please review this PR. Let me know if further changes are needed. 🚀 This fix improves **developer onboarding** and ensures the **LangChain documentation remains up to date**! 🚀 --- docs/docs/integrations/document_loaders/docling.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/integrations/document_loaders/docling.ipynb b/docs/docs/integrations/document_loaders/docling.ipynb index dea667aaffa..16ef567c55f 100644 --- a/docs/docs/integrations/document_loaders/docling.ipynb +++ b/docs/docs/integrations/document_loaders/docling.ipynb @@ -443,6 +443,7 @@ "llm = HuggingFaceEndpoint(\n", " repo_id=GEN_MODEL_ID,\n", " huggingfacehub_api_token=HF_TOKEN,\n", + " task=\"text-generation\",\n", ")" ] },