Comments (1)
Hello @dyomed93,
I'm here to assist you with any questions or issues you may have. I'm a bot that can help you solve bugs, answer questions, and become a contributor. Let's see how I can help you today!
You can find documentation or examples for the "Hugging Face API" module on Langflow, specifically for the Endpoint URL and model fields, in the HuggingFaceEndpointsComponent
class within the src/backend/langflow/components/llms/HuggingFaceEndpoints.py
file.
Here is the relevant code snippet:
from typing import Optional
from langchain.llms.base import BaseLLM
from langchain.llms.huggingface_endpoint import HuggingFaceEndpoint
from langflow import CustomComponent
class HuggingFaceEndpointsComponent(CustomComponent):
display_name: str = "Hugging Face Inference API"
description: str = "LLM model from Hugging Face Inference API."
def build_config(self):
return {
"endpoint_url": {"display_name": "Endpoint URL", "password": True},
"task": {
"display_name": "Task",
"options": ["text2text-generation", "text-generation", "summarization"],
},
"huggingfacehub_api_token": {"display_name": "API token", "password": True},
"model_kwargs": {
"display_name": "Model Keyword Arguments",
"field_type": "code",
},
"code": {"show": False},
}
def build(
self,
endpoint_url: str,
task: str = "text2text-generation",
huggingfacehub_api_token: Optional[str] = None,
model_kwargs: Optional[dict] = None,
) -> BaseLLM:
try:
output = HuggingFaceEndpoint( # type: ignore
endpoint_url=endpoint_url,
task=task,
huggingfacehub_api_token=huggingfacehub_api_token,
model_kwargs=model_kwargs or {},
)
except Exception as e:
raise ValueError("Could not connect to HuggingFace Endpoints API.") from e
return output
This class defines the configuration for the Hugging Face API, including the endpoint_url
and model
fields [1].
Additionally, the Langflow repository provides specific examples and sample configurations for using the Hugging Face API module with different models, including Mistral 7B. Here is a sample configuration for the MistralAIModelComponent:
def build_config(self):
return {
"input_value": {"display_name": "Input", "input_types": ["Text", "Record", "Prompt"]},
"max_tokens": {
"display_name": "Max Tokens",
"advanced": True,
"info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.",
},
"model_name": {
"display_name": "Model Name",
"advanced": False,
"options": [
"open-mistral-7b",
"open-mixtral-8x7b",
"open-mixtral-8x22b",
"mistral-small-latest",
"mistral-medium-latest",
"mistral-large-latest",
],
"value": "open-mistral-7b",
},
"mistral_api_base": {
"display_name": "Mistral API Base",
"advanced": True,
"info": (
"The base URL of the Mistral API. Defaults to https://api.mistral.ai.\n\n"
"You can change this to use other APIs like JinaChat, LocalAI and Prem."
),
},
"mistral_api_key": {
"display_name": "Mistral API Key",
"info": "The Mistral API Key to use for the Mistral model.",
"advanced": False,
"password": True,
},
"temperature": {
"display_name": "Temperature",
"advanced": False,
"value": 0.1,
},
"stream": {
"display_name": "Stream",
"info": STREAM_INFO_TEXT,
"advanced": True,
},
"system_message": {
"display_name": "System Message",
"info": "System message to pass to the model.",
"advanced": True,
},
"max_retries": {
"display_name": "Max Retries",
"advanced": True,
},
"timeout": {
"display_name": "Timeout",
"advanced": True,
},
"max_concurrent_requests": {
"display_name": "Max Concurrent Requests",
"advanced": True,
},
"top_p": {
"display_name": "Top P",
"advanced": True,
},
"random_seed": {
"display_name": "Random Seed",
"advanced": True,
},
"safe_mode": {
"display_name": "Safe Mode",
"advanced": True,
},
}
This configuration includes the model "open-mistral-7b" among other options [2][3].
To continue talking to Dosu, mention @dosu.
from langflow.
Related Issues (20)
- Faiss search error HOT 2
- The outout of the Chat Input is not been recognized as text by OpenAI model HOT 4
- Error Building Component Error building Component Astra DB: {"errors":[{"message":"Request invalid: field 'command.name' value \"english-test\" not valid. Problem: must match \"[a-zA-Z][a-zA-Z0-9_]*\".","errorCode":"COMMAND_FIELD_INVALID"}]} HOT 1
- ValidationError: 2 validation errors for HumanMessage at v1.0.0a59 HOT 2
- Encountering error in building ASTRA DB Search node in the canvas. Error Building Component Error building Component Astra DB Search: Invalid inputs provided. HOT 4
- API Request ERROR HOT 3
- [Feature Request]: Allow local cassandra connections
- idea
- [Request] Please add openrouter as LLM Model
- Nested chats HOT 1
- Module langflow.inputs not found HOT 1
- CommandError: Multiple head revisions are present for given argument 'head'; please specify a specific target revision, '<branchname>@head' to narrow to a specific head, or 'heads' for all heads HOT 1
- Questions about Run Flow HOT 1
- An error was thrown while using the groq component HOT 1
- Issue with Chat Input component HOT 5
- Question: Inquiry on Session Management and Parameter Passing in Langflow API HOT 3
- Langflow Store Suspension HOT 1
- Documentation to use Flow as Tool HOT 3
- Method not Allowed on API HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langflow.