File tree Expand file tree Collapse file tree
integrations/huggingface_api
src/haystack_integrations/components/generators/huggingface_api/chat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ classifiers = [
2323 " Programming Language :: Python :: Implementation :: CPython" ,
2424 " Programming Language :: Python :: Implementation :: PyPy" ,
2525]
26- dependencies = [" haystack-ai>=2.30.0" , " huggingface_hub[inference]>=0.27 .0" ]
26+ dependencies = [" haystack-ai>=2.30.0" , " huggingface_hub[inference]>=0.35 .0" ]
2727
2828[project .urls ]
2929Documentation = " https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/huggingface_api#readme"
Original file line number Diff line number Diff line change @@ -148,20 +148,15 @@ def _convert_tools_to_hfapi_tools(tools: ToolsType | None) -> list["ChatCompleti
148148 if not tools :
149149 return None
150150
151- # huggingface_hub<0.31.0 uses "arguments", huggingface_hub>=0.31.0 uses "parameters"
152- parameters_name = "arguments" if hasattr (ChatCompletionInputFunctionDefinition , "arguments" ) else "parameters"
153-
154151 hf_tools = []
155152 for tool in flatten_tools_or_toolsets (tools ):
156- hf_tools_args = {
157- "name" : tool .name ,
158- "description" : tool .description ,
159- parameters_name : _resolve_schema_refs (tool .parameters ),
160- }
161-
162153 hf_tools .append (
163154 ChatCompletionInputTool (
164- function = ChatCompletionInputFunctionDefinition (** hf_tools_args ), # type: ignore[arg-type]
155+ function = ChatCompletionInputFunctionDefinition (
156+ name = tool .name ,
157+ description = tool .description ,
158+ parameters = _resolve_schema_refs (tool .parameters ),
159+ ),
165160 type = "function" ,
166161 )
167162 )
Original file line number Diff line number Diff line change @@ -1231,28 +1231,6 @@ def test_convert_tools_to_hfapi_tools(self):
12311231 assert hf_tools [0 ].function .description == "useful to determine the weather in a given location"
12321232 assert hf_tools [0 ].function .parameters == {"city" : {"type" : "string" }}
12331233
1234- def test_convert_tools_to_hfapi_tools_legacy (self ):
1235- # this satisfies the check hasattr(ChatCompletionInputFunctionDefinition, "arguments")
1236- mock_class = MagicMock ()
1237-
1238- with patch (
1239- "haystack_integrations.components.generators.huggingface_api.chat.chat_generator.ChatCompletionInputFunctionDefinition" ,
1240- mock_class ,
1241- ):
1242- tool = Tool (
1243- name = "weather" ,
1244- description = "useful to determine the weather in a given location" ,
1245- parameters = {"city" : {"type" : "string" }},
1246- function = get_weather ,
1247- )
1248- _convert_tools_to_hfapi_tools ([tool ])
1249-
1250- mock_class .assert_called_once_with (
1251- name = "weather" ,
1252- arguments = {"city" : {"type" : "string" }},
1253- description = "useful to determine the weather in a given location" ,
1254- )
1255-
12561234 def test_warm_up_with_tools (self , mock_check_valid_model ):
12571235 """Test that warm_up() calls warm_up on tools and is idempotent."""
12581236
You can’t perform that action at this time.
0 commit comments