added huggingface endpoints
This commit is contained in:
parent
4d0771c9c8
commit
e7f94f23e4
2 changed files with 23 additions and 0 deletions
23
src/backend/langflow/components/llms/HuggingFaceEndpoints.py
Normal file
23
src/backend/langflow/components/llms/HuggingFaceEndpoints.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
from typing import Optional
|
||||||
|
from langflow import CustomComponent
|
||||||
|
from langchain.llms import HuggingFaceEndpoint
|
||||||
|
|
||||||
|
class HuggingFaceEndpointsComponent(CustomComponent):
|
||||||
|
display_name: str = "Hugging Face Endpoints"
|
||||||
|
description: str = "LLM model from Inference Hugging Face Endpoints."
|
||||||
|
|
||||||
|
def build_config(self):
|
||||||
|
return {
|
||||||
|
"endpoint_url": {"display_name": "Endpoint URL", "password": True},
|
||||||
|
"task": {"display_name": "Task", "type": "select", "options": ["text2text-generation", "text-generation", "summarization"]},
|
||||||
|
"code": {"show": False},
|
||||||
|
}
|
||||||
|
|
||||||
|
def build(
|
||||||
|
self, endpoint_url: str, task="text2text-generation",
|
||||||
|
) -> HuggingFaceEndpoint:
|
||||||
|
try:
|
||||||
|
output = HuggingFaceEndpoint(endpoint_url=endpoint_url, task=task)
|
||||||
|
except Exception as e:
|
||||||
|
raise ValueError("Could not connect to HuggingFace Endpoints API.") from e
|
||||||
|
return output
|
||||||
0
src/backend/langflow/components/llms/__init__.py
Normal file
0
src/backend/langflow/components/llms/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue