Skip to content

Commit 66a8542

Browse files
committed
Fixed Arguments
1 parent 9a8e62c commit 66a8542

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

libs/community/langchain_community/tools/huggingface.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from langchain.tools import BaseTool
2+
from langchain_community.tools import BaseTool
33

44
class HuggingFaceHubTool(BaseTool):
55
"""Base tool for interacting with the Hugging Face Hub."""
@@ -19,7 +19,11 @@ def __init__(self, **kwargs):
1919
) from e
2020

2121
def _run(self, query: str) -> str:
22-
"""Use the tool."""
22+
"""Use the tool to search Hugging Face Hub.
23+
24+
Args:
25+
query: The search query string to find models or datasets.
26+
"""
2327
try:
2428
if self.task == "models":
2529
results_list = self.api_client.list_models(
@@ -44,8 +48,12 @@ def _run(self, query: str) -> str:
4448

4549
return "\n\n---\n\n".join(formatted_results)
4650

51+
except ConnectionError as e:
52+
return f"Error: Failed to connect to HuggingFace API. {str(e)}"
53+
except ValueError as e:
54+
return f"Error: Invalid input to HuggingFace API. {str(e)}"
4755
except Exception as e:
48-
return f"An error occurred: {e}"
56+
return f"Unexpected error when calling HuggingFace API: {str(e)}"
4957

5058
async def _arun(self, query: str) -> str:
5159
"""Use the tool asynchronously."""

libs/community/pyproject.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@ version = "0.3.29"
2626
description = "Community contributed LangChain integrations."
2727
readme = "README.md"
2828

29-
[project.optional-dependencies]
30-
all = [
31-
"huggingface-hub",
32-
]
33-
3429
[project.urls]
3530
"Source Code" = "https://github.com/langchain-ai/langchain-community/tree/main/libs/community"
3631
"Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-community%3D%3D0%22&expanded=true"
3732
repository = "https://github.com/langchain-ai/langchain-community"
3833

3934
[dependency-groups]
35+
huggingface = ["huggingface-hub"]
4036
test = [
4137
"pytest<9.0.0,>=8.4.1",
4238
"pytest-cov<7.0.0,>=6.2.1",

0 commit comments

Comments
 (0)