Skip to content

Commit

Permalink
fix: huggingface embedder error messages not being displayed (#8537)
Browse files Browse the repository at this point in the history
* initial import

* fixing too-many-arguments - since file is now changed pylint checks it

* more fixes

* disable too-arguments pylint
  • Loading branch information
davidsbatista authored Nov 12, 2024
1 parent 852900d commit fcdf392
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
progress_bar: bool = True,
meta_fields_to_embed: Optional[List[str]] = None,
embedding_separator: str = "\n",
):
): # pylint: disable=too-many-positional-arguments
"""
Creates a HuggingFaceAPIDocumentEmbedder component.
Expand Down Expand Up @@ -168,7 +168,7 @@ def __init__(
model_or_url = url
else:
msg = f"Unknown api_type {api_type}"
raise ValueError(api_type)
raise ValueError(msg)

self.api_type = api_type
self.api_params = api_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
suffix: str = "",
truncate: bool = True,
normalize: bool = False,
):
): # pylint: disable=too-many-positional-arguments
"""
Creates a HuggingFaceAPITextEmbedder component.
Expand Down Expand Up @@ -138,7 +138,7 @@ def __init__(
model_or_url = url
else:
msg = f"Unknown api_type {api_type}"
raise ValueError()
raise ValueError(msg)

self.api_type = api_type
self.api_params = api_params
Expand Down
4 changes: 2 additions & 2 deletions haystack/components/generators/chat/hugging_face_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class HuggingFaceAPIChatGenerator:
```
"""

def __init__(
def __init__( # pylint: disable=too-many-positional-arguments
self,
api_type: Union[HFGenerationAPIType, str],
api_params: Dict[str, str],
Expand Down Expand Up @@ -162,7 +162,7 @@ def __init__(
model_or_url = url
else:
msg = f"Unknown api_type {api_type}"
raise ValueError(api_type)
raise ValueError(msg)

# handle generation kwargs setup
generation_kwargs = generation_kwargs.copy() if generation_kwargs else {}
Expand Down
2 changes: 1 addition & 1 deletion haystack/components/generators/hugging_face_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__( # pylint: disable=too-many-positional-arguments
model_or_url = url
else:
msg = f"Unknown api_type {api_type}"
raise ValueError(api_type)
raise ValueError(msg)

# handle generation kwargs setup
generation_kwargs = generation_kwargs.copy() if generation_kwargs else {}
Expand Down

0 comments on commit fcdf392

Please sign in to comment.