huggingface-api-haystack 2.0.0__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/CHANGELOG.md +11 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/PKG-INFO +1 -1
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/generators/huggingface_api/chat/chat_generator.py +2 -15
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_chat_generator.py +0 -109
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/.gitignore +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/LICENSE.txt +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/README.md +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/docker-compose.yml +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/pydoc/config_docusaurus.yml +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/pyproject.toml +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/common/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/common/huggingface_api/utils.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/common/py.typed +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/embedders/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/embedders/huggingface_api/document_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/embedders/huggingface_api/sparse_document_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/embedders/huggingface_api/sparse_embedding_utils.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/embedders/huggingface_api/sparse_text_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/embedders/huggingface_api/text_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/generators/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/generators/huggingface_api/chat/__init__.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/generators/py.typed +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/rankers/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/rankers/huggingface_api/ranker.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/src/haystack_integrations/components/rankers/py.typed +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/__init__.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/conftest.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_document_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_files/apple.jpg +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_ranker.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_sparse_document_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_sparse_text_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_text_embedder.py +0 -0
- {huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_utils.py +0 -0
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/huggingface_api-v2.0.0] - 2026-10-01
|
|
4
|
+
|
|
5
|
+
### 🚀 Features
|
|
6
|
+
|
|
7
|
+
- [**breaking**] Add grpc support for the huggingface TEI components; rename HuggingFace API Sparse Embedders -> Hugging Face TEI Sparse Embedders (#3870)
|
|
8
|
+
|
|
9
|
+
### 🧪 Testing
|
|
10
|
+
|
|
11
|
+
- HF API - use Groq for gpt-oss-20b (#4001)
|
|
12
|
+
|
|
13
|
+
|
|
3
14
|
## [integrations/huggingface_api-v1.0.0] - 2026-09-07
|
|
4
15
|
|
|
5
16
|
### 🚀 Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: huggingface-api-haystack
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Haystack integration for Hugging Face API
|
|
5
5
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/huggingface_api#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
@@ -27,7 +27,6 @@ from haystack.tools import (
|
|
|
27
27
|
deserialize_tools_or_toolset_inplace,
|
|
28
28
|
flatten_tools_or_toolsets,
|
|
29
29
|
serialize_tools_or_toolset,
|
|
30
|
-
warm_up_tools,
|
|
31
30
|
)
|
|
32
31
|
from haystack.utils import Secret, deserialize_callable, serialize_callable
|
|
33
32
|
from haystack.utils.hf import convert_message_to_hf_format
|
|
@@ -442,7 +441,6 @@ class HuggingFaceAPIChatGenerator:
|
|
|
442
441
|
self._model_or_url = model_or_url
|
|
443
442
|
self._client: InferenceClient | None = None
|
|
444
443
|
self._async_client: AsyncInferenceClient | None = None
|
|
445
|
-
self._tools_warmed_up = False
|
|
446
444
|
|
|
447
445
|
def _client_kwargs(self) -> dict[str, Any]:
|
|
448
446
|
"""Build the keyword arguments used to create Hugging Face clients."""
|
|
@@ -452,26 +450,15 @@ class HuggingFaceAPIChatGenerator:
|
|
|
452
450
|
**{k: v for k, v in self.api_params.items() if k not in ("model", "url")},
|
|
453
451
|
}
|
|
454
452
|
|
|
455
|
-
def _warm_up_tools(self) -> None:
|
|
456
|
-
if not self._tools_warmed_up:
|
|
457
|
-
warm_up_tools(self.tools)
|
|
458
|
-
self._tools_warmed_up = True
|
|
459
|
-
|
|
460
453
|
def warm_up(self) -> None:
|
|
461
|
-
"""
|
|
462
|
-
Warm up the Hugging Face API chat generator.
|
|
463
|
-
|
|
464
|
-
This creates the synchronous client and warms up the configured tools.
|
|
465
|
-
"""
|
|
466
|
-
self._warm_up_tools()
|
|
454
|
+
"""Create the synchronous Hugging Face client."""
|
|
467
455
|
if self._client is None:
|
|
468
456
|
if self.api_type == HFGenerationAPIType.SERVERLESS_INFERENCE_API:
|
|
469
457
|
_check_valid_model(self._model_or_url, HFModelType.GENERATION, self.token)
|
|
470
458
|
self._client = InferenceClient(**self._client_kwargs())
|
|
471
459
|
|
|
472
460
|
async def warm_up_async(self) -> None:
|
|
473
|
-
"""Create the asynchronous Hugging Face client
|
|
474
|
-
self._warm_up_tools()
|
|
461
|
+
"""Create the asynchronous Hugging Face client."""
|
|
475
462
|
if self._async_client is None:
|
|
476
463
|
if self.api_type == HFGenerationAPIType.SERVERLESS_INFERENCE_API:
|
|
477
464
|
await _check_valid_model_async(self._model_or_url, HFModelType.GENERATION, self.token)
|
{huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_chat_generator.py
RENAMED
|
@@ -1334,115 +1334,6 @@ class TestTools:
|
|
|
1334
1334
|
assert hf_tools[0].function.description == "useful to determine the weather in a given location"
|
|
1335
1335
|
assert hf_tools[0].function.parameters == {"city": {"type": "string"}}
|
|
1336
1336
|
|
|
1337
|
-
def test_warm_up_with_tools(self, mock_check_valid_model):
|
|
1338
|
-
"""Test that warm_up() calls warm_up on tools and is idempotent."""
|
|
1339
|
-
|
|
1340
|
-
# Create a mock tool that tracks if warm_up() was called
|
|
1341
|
-
class MockTool(Tool):
|
|
1342
|
-
warm_up_call_count = 0 # Class variable to track calls
|
|
1343
|
-
|
|
1344
|
-
def __init__(self):
|
|
1345
|
-
super().__init__(
|
|
1346
|
-
name="mock_tool",
|
|
1347
|
-
description="A mock tool for testing",
|
|
1348
|
-
parameters={"x": {"type": "string"}},
|
|
1349
|
-
function=lambda x: x,
|
|
1350
|
-
)
|
|
1351
|
-
|
|
1352
|
-
def warm_up(self):
|
|
1353
|
-
MockTool.warm_up_call_count += 1
|
|
1354
|
-
|
|
1355
|
-
# Reset the class variable before test
|
|
1356
|
-
MockTool.warm_up_call_count = 0
|
|
1357
|
-
mock_tool = MockTool()
|
|
1358
|
-
|
|
1359
|
-
# Create HuggingFaceAPIChatGenerator with the mock tool
|
|
1360
|
-
component = HuggingFaceAPIChatGenerator(
|
|
1361
|
-
api_type=HFGenerationAPIType.SERVERLESS_INFERENCE_API,
|
|
1362
|
-
api_params={"model": "HuggingFaceH4/zephyr-7b-alpha"},
|
|
1363
|
-
tools=[mock_tool],
|
|
1364
|
-
)
|
|
1365
|
-
|
|
1366
|
-
# Verify initial state - warm_up not called yet
|
|
1367
|
-
assert MockTool.warm_up_call_count == 0
|
|
1368
|
-
assert not component._tools_warmed_up
|
|
1369
|
-
|
|
1370
|
-
# Call warm_up() on the generator
|
|
1371
|
-
component.warm_up()
|
|
1372
|
-
|
|
1373
|
-
# Assert that the tool's warm_up() was called
|
|
1374
|
-
assert MockTool.warm_up_call_count == 1
|
|
1375
|
-
assert component._tools_warmed_up
|
|
1376
|
-
|
|
1377
|
-
# Call warm_up() again and verify it's idempotent (only warms up once)
|
|
1378
|
-
component.warm_up()
|
|
1379
|
-
|
|
1380
|
-
# The tool's warm_up should still only have been called once
|
|
1381
|
-
assert MockTool.warm_up_call_count == 1
|
|
1382
|
-
assert component._tools_warmed_up
|
|
1383
|
-
|
|
1384
|
-
def test_warm_up_with_no_tools(self, mock_check_valid_model):
|
|
1385
|
-
"""Test that warm_up() works when no tools are provided."""
|
|
1386
|
-
component = HuggingFaceAPIChatGenerator(
|
|
1387
|
-
api_type=HFGenerationAPIType.SERVERLESS_INFERENCE_API, api_params={"model": "HuggingFaceH4/zephyr-7b-alpha"}
|
|
1388
|
-
)
|
|
1389
|
-
|
|
1390
|
-
# Verify initial state
|
|
1391
|
-
assert not component._tools_warmed_up
|
|
1392
|
-
assert component.tools is None
|
|
1393
|
-
|
|
1394
|
-
# Call warm_up() - should not raise an error
|
|
1395
|
-
component.warm_up()
|
|
1396
|
-
|
|
1397
|
-
# Verify the component is warmed up
|
|
1398
|
-
assert component._tools_warmed_up
|
|
1399
|
-
|
|
1400
|
-
# Call warm_up() again - should be idempotent
|
|
1401
|
-
component.warm_up()
|
|
1402
|
-
assert component._tools_warmed_up
|
|
1403
|
-
|
|
1404
|
-
def test_warm_up_with_multiple_tools(self, mock_check_valid_model):
|
|
1405
|
-
"""Test that warm_up() works with multiple tools."""
|
|
1406
|
-
# Track warm_up calls
|
|
1407
|
-
warm_up_calls = []
|
|
1408
|
-
|
|
1409
|
-
class MockTool(Tool):
|
|
1410
|
-
def __init__(self, tool_name):
|
|
1411
|
-
super().__init__(
|
|
1412
|
-
name=tool_name,
|
|
1413
|
-
description=f"Mock tool {tool_name}",
|
|
1414
|
-
parameters={"type": "object", "properties": {"x": {"type": "string"}}, "required": ["x"]},
|
|
1415
|
-
function=lambda x: f"{tool_name} result: {x}",
|
|
1416
|
-
)
|
|
1417
|
-
|
|
1418
|
-
def warm_up(self):
|
|
1419
|
-
warm_up_calls.append(self.name)
|
|
1420
|
-
|
|
1421
|
-
mock_tool1 = MockTool("tool1")
|
|
1422
|
-
mock_tool2 = MockTool("tool2")
|
|
1423
|
-
|
|
1424
|
-
# Use a LIST of tools, not a Toolset
|
|
1425
|
-
component = HuggingFaceAPIChatGenerator(
|
|
1426
|
-
api_type=HFGenerationAPIType.SERVERLESS_INFERENCE_API,
|
|
1427
|
-
api_params={"model": "HuggingFaceH4/zephyr-7b-alpha"},
|
|
1428
|
-
tools=[mock_tool1, mock_tool2],
|
|
1429
|
-
)
|
|
1430
|
-
|
|
1431
|
-
# Call warm_up()
|
|
1432
|
-
component.warm_up()
|
|
1433
|
-
|
|
1434
|
-
# Assert that both tools' warm_up() were called
|
|
1435
|
-
assert "tool1" in warm_up_calls
|
|
1436
|
-
assert "tool2" in warm_up_calls
|
|
1437
|
-
assert component._tools_warmed_up
|
|
1438
|
-
|
|
1439
|
-
# Track count
|
|
1440
|
-
call_count = len(warm_up_calls)
|
|
1441
|
-
|
|
1442
|
-
# Verify idempotency
|
|
1443
|
-
component.warm_up()
|
|
1444
|
-
assert len(warm_up_calls) == call_count
|
|
1445
|
-
|
|
1446
1337
|
|
|
1447
1338
|
class TestReasoning:
|
|
1448
1339
|
def test_run_with_reasoning_non_streaming(self, mock_check_valid_model, chat_messages):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/pydoc/config_docusaurus.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_document_embedder.py
RENAMED
|
File without changes
|
{huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_files/apple.jpg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_sparse_text_embedder.py
RENAMED
|
File without changes
|
{huggingface_api_haystack-2.0.0 → huggingface_api_haystack-2.1.0}/tests/test_text_embedder.py
RENAMED
|
File without changes
|
|
File without changes
|