fix: Add missing inputs for HuggingFace model component and include pytest (#4291)

* fix: Add missing inputs for HuggingFace model component and include pytest

- Added missing inputs to the HuggingFace model component.
- Implemented pytest to ensure the inputs are correctly handled.

* remove print statement
This commit is contained in:
Edwin Jose 2024-10-26 15:41:32 -04:00 committed by GitHub
commit a0c42d148d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 71 additions and 1 deletions

View file

@ -0,0 +1,31 @@
from langflow.inputs.inputs import DictInput, DropdownInput, FloatInput, HandleInput, IntInput, SecretStrInput, StrInput
from src.backend.base.langflow.components.models.huggingface import HuggingFaceEndpointsComponent
def test_huggingface_inputs():
component = HuggingFaceEndpointsComponent()
inputs = component.inputs
# Define expected input types and their names
expected_inputs = {
"model_id": StrInput,
"max_new_tokens": IntInput,
"top_k": IntInput,
"top_p": FloatInput,
"typical_p": FloatInput,
"temperature": FloatInput,
"repetition_penalty": FloatInput,
"inference_endpoint": StrInput,
"task": DropdownInput,
"huggingfacehub_api_token": SecretStrInput,
"model_kwargs": DictInput,
"retry_attempts": IntInput,
"output_parser": HandleInput,
}
# Check if all expected inputs are present
for name, input_type in expected_inputs.items():
assert any(
isinstance(inp, input_type) and inp.name == name for inp in inputs
), f"Missing or incorrect input: {name}"