From dad8480ce36e4c2c066d6d8d17e10e486591570a Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 12 Oct 2023 19:22:41 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(HuggingFaceEndpoints.py?= =?UTF-8?q?):=20update=20import=20statement=20for=20HuggingFaceEndpoint=20?= =?UTF-8?q?class=20to=20match=20new=20file=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 chore(HuggingFaceEndpoints.py): remove unused import statement for langchain.llms.base module 🔧 chore(HuggingFaceEndpoints.py): remove unused "type" field from task parameter in build method signature 🔧 chore(HuggingFaceEndpoints.py): add default value for task parameter in build method signature 🔧 chore(HuggingFaceEndpoints.py): add default values for huggingfacehub_api_token and model_kwargs parameters in build method signature 🐛 fix(HuggingFaceEndpoints.py): add model_kwargs parameter to HuggingFaceEndpoint constructor to fix missing argument error --- .../langflow/components/llms/HuggingFaceEndpoints.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/components/llms/HuggingFaceEndpoints.py b/src/backend/langflow/components/llms/HuggingFaceEndpoints.py index ea2b4f20b..0d28d5b9b 100644 --- a/src/backend/langflow/components/llms/HuggingFaceEndpoints.py +++ b/src/backend/langflow/components/llms/HuggingFaceEndpoints.py @@ -1,6 +1,6 @@ from typing import Optional from langflow import CustomComponent -from langchain.llms import HuggingFaceEndpoint +from langchain.llms.huggingface_endpoint import HuggingFaceEndpoint from langchain.llms.base import BaseLLM @@ -13,7 +13,6 @@ class HuggingFaceEndpointsComponent(CustomComponent): "endpoint_url": {"display_name": "Endpoint URL", "password": True}, "task": { "display_name": "Task", - "type": "select", "options": ["text2text-generation", "text-generation", "summarization"], }, "huggingfacehub_api_token": {"display_name": "API token", "password": True}, @@ -27,7 +26,7 @@ class HuggingFaceEndpointsComponent(CustomComponent): def build( self, endpoint_url: str, - task="text2text-generation", + task: str = "text2text-generation", huggingfacehub_api_token: Optional[str] = None, model_kwargs: Optional[dict] = None, ) -> BaseLLM: @@ -36,6 +35,7 @@ class HuggingFaceEndpointsComponent(CustomComponent): endpoint_url=endpoint_url, task=task, huggingfacehub_api_token=huggingfacehub_api_token, + model_kwargs=model_kwargs, ) except Exception as e: raise ValueError("Could not connect to HuggingFace Endpoints API.") from e