huggingface-api-haystack 0.4.0__tar.gz → 0.5.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-0.4.0 → huggingface_api_haystack-0.5.0}/CHANGELOG.md +12 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/PKG-INFO +4 -4
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/README.md +2 -2
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/pyproject.toml +1 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/generators/huggingface_api/chat/chat_generator.py +6 -2
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/rankers/huggingface_api/ranker.py +1 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_chat_generator.py +29 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_ranker.py +8 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/.gitignore +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/LICENSE.txt +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/pydoc/config_docusaurus.yml +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/common/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/common/huggingface_api/utils.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/common/py.typed +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/huggingface_api/document_embedder.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/huggingface_api/text_embedder.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/generators/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/generators/huggingface_api/chat/__init__.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/generators/py.typed +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/rankers/huggingface_api/__init__.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/rankers/py.typed +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/__init__.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/conftest.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_document_embedder.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_files/apple.jpg +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_text_embedder.py +0 -0
- {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_utils.py +0 -0
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [unreleased]
|
|
4
|
+
|
|
5
|
+
### 🧪 Testing
|
|
6
|
+
|
|
7
|
+
- Trust test modules under Haystack 3.0's deserialization allowlist (#3537)
|
|
8
|
+
- Make Tool/Agent serialization assertions version-agnostic for Haystack 2.x/3.x (#3533)
|
|
9
|
+
|
|
10
|
+
### 🧹 Chores
|
|
11
|
+
|
|
12
|
+
- Support sync streaming callbacks in async contexts for Haystack 2.x/3.x compatibility (#3534)
|
|
13
|
+
|
|
14
|
+
|
|
3
15
|
## [integrations/huggingface_api-v0.3.0] - 2026-06-26
|
|
4
16
|
|
|
5
17
|
### 🐛 Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: huggingface-api-haystack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
|
@@ -28,7 +28,7 @@ Description-Content-Type: text/markdown
|
|
|
28
28
|
[](https://pypi.org/project/huggingface-api-haystack)
|
|
29
29
|
[](https://pypi.org/project/huggingface-api-haystack)
|
|
30
30
|
|
|
31
|
-
- [Integration page](https://haystack.deepset.ai/integrations/
|
|
31
|
+
- [Integration page](https://haystack.deepset.ai/integrations/huggingface-api)
|
|
32
32
|
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/huggingface_api/CHANGELOG.md)
|
|
33
33
|
|
|
34
34
|
---
|
|
@@ -37,4 +37,4 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|
|
|
38
38
|
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
39
39
|
|
|
40
|
-
To run integration tests locally, you need to export the `
|
|
40
|
+
To run integration tests locally, you need to export the `HF_TOKEN` environment variable.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://pypi.org/project/huggingface-api-haystack)
|
|
4
4
|
[](https://pypi.org/project/huggingface-api-haystack)
|
|
5
5
|
|
|
6
|
-
- [Integration page](https://haystack.deepset.ai/integrations/
|
|
6
|
+
- [Integration page](https://haystack.deepset.ai/integrations/huggingface-api)
|
|
7
7
|
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/huggingface_api/CHANGELOG.md)
|
|
8
8
|
|
|
9
9
|
---
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
|
|
13
13
|
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
14
14
|
|
|
15
|
-
To run integration tests locally, you need to export the `
|
|
15
|
+
To run integration tests locally, you need to export the `HF_TOKEN` environment variable.
|
|
@@ -505,7 +505,9 @@ class HuggingFaceAPIChatGenerator:
|
|
|
505
505
|
A list of ChatMessage objects representing the input messages. If a string is provided, it is converted
|
|
506
506
|
to a list containing a ChatMessage with user role.
|
|
507
507
|
:param generation_kwargs:
|
|
508
|
-
Additional keyword arguments for text generation.
|
|
508
|
+
Additional keyword arguments for text generation. These are merged per key with the
|
|
509
|
+
`generation_kwargs` passed at initialization: keys provided here take precedence, keys set only
|
|
510
|
+
at initialization are kept.
|
|
509
511
|
:param tools:
|
|
510
512
|
A list of tools or a Toolset for which the model can prepare calls. If set, it will override
|
|
511
513
|
the `tools` parameter set during component initialization. This parameter can accept either a
|
|
@@ -565,7 +567,9 @@ class HuggingFaceAPIChatGenerator:
|
|
|
565
567
|
A list of ChatMessage objects representing the input messages. If a string is provided, it is converted
|
|
566
568
|
to a list containing a ChatMessage with user role.
|
|
567
569
|
:param generation_kwargs:
|
|
568
|
-
Additional keyword arguments for text generation.
|
|
570
|
+
Additional keyword arguments for text generation. These are merged per key with the
|
|
571
|
+
`generation_kwargs` passed at initialization: keys provided here take precedence, keys set only
|
|
572
|
+
at initialization are kept.
|
|
569
573
|
:param tools:
|
|
570
574
|
A list of tools or a Toolset for which the model can prepare calls. If set, it will override the `tools`
|
|
571
575
|
parameter set during component initialization. This parameter can accept either a list of `Tool` objects
|
{huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_chat_generator.py
RENAMED
|
@@ -374,6 +374,19 @@ class TestHuggingFaceAPIChatGenerator:
|
|
|
374
374
|
assert len(response["replies"]) == 1
|
|
375
375
|
assert [isinstance(reply, ChatMessage) for reply in response["replies"]]
|
|
376
376
|
|
|
377
|
+
def test_run_with_generation_kwargs(self, mock_check_valid_model, mock_chat_completion, chat_messages):
|
|
378
|
+
generator = HuggingFaceAPIChatGenerator(
|
|
379
|
+
api_type=HFGenerationAPIType.SERVERLESS_INFERENCE_API,
|
|
380
|
+
api_params={"model": "meta-llama/Llama-2-13b-chat-hf"},
|
|
381
|
+
generation_kwargs={"max_tokens": 100, "temperature": 0.5},
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
generator.run(messages=chat_messages, generation_kwargs={"temperature": 0.9})
|
|
385
|
+
|
|
386
|
+
_, kwargs = mock_chat_completion.call_args
|
|
387
|
+
assert kwargs["max_tokens"] == 100
|
|
388
|
+
assert kwargs["temperature"] == 0.9
|
|
389
|
+
|
|
377
390
|
def test_run_with_string_input(self, mock_check_valid_model, mock_chat_completion):
|
|
378
391
|
generator = HuggingFaceAPIChatGenerator(
|
|
379
392
|
api_type=HFGenerationAPIType.SERVERLESS_INFERENCE_API,
|
|
@@ -914,6 +927,22 @@ class TestHuggingFaceAPIChatGenerator:
|
|
|
914
927
|
assert len(response["replies"]) == 1
|
|
915
928
|
assert [isinstance(reply, ChatMessage) for reply in response["replies"]]
|
|
916
929
|
|
|
930
|
+
@pytest.mark.asyncio
|
|
931
|
+
async def test_run_async_with_generation_kwargs(
|
|
932
|
+
self, mock_check_valid_model, mock_chat_completion_async, chat_messages
|
|
933
|
+
):
|
|
934
|
+
generator = HuggingFaceAPIChatGenerator(
|
|
935
|
+
api_type=HFGenerationAPIType.SERVERLESS_INFERENCE_API,
|
|
936
|
+
api_params={"model": "meta-llama/Llama-2-13b-chat-hf"},
|
|
937
|
+
generation_kwargs={"max_tokens": 100, "temperature": 0.5},
|
|
938
|
+
)
|
|
939
|
+
|
|
940
|
+
await generator.run_async(messages=chat_messages, generation_kwargs={"temperature": 0.9})
|
|
941
|
+
|
|
942
|
+
_, kwargs = mock_chat_completion_async.call_args
|
|
943
|
+
assert kwargs["max_tokens"] == 100
|
|
944
|
+
assert kwargs["temperature"] == 0.9
|
|
945
|
+
|
|
917
946
|
@pytest.mark.asyncio
|
|
918
947
|
async def test_run_async_with_string_input(self, mock_check_valid_model, mock_chat_completion_async):
|
|
919
948
|
generator = HuggingFaceAPIChatGenerator(
|
|
@@ -60,6 +60,14 @@ class TestHuggingFaceTEIRanker:
|
|
|
60
60
|
assert data["init_parameters"]["max_retries"] == 4
|
|
61
61
|
assert data["init_parameters"]["retry_status_codes"] == [500, 502]
|
|
62
62
|
|
|
63
|
+
def test_raw_scores_survives_a_serialization_round_trip(self, del_hf_env_vars_if_empty):
|
|
64
|
+
"""raw_scores goes into the request payload, so losing it changes what the API returns."""
|
|
65
|
+
ranker = HuggingFaceTEIRanker(url="https://api.my-tei-service.com", raw_scores=True)
|
|
66
|
+
|
|
67
|
+
restored = HuggingFaceTEIRanker.from_dict(ranker.to_dict())
|
|
68
|
+
|
|
69
|
+
assert restored.raw_scores is True
|
|
70
|
+
|
|
63
71
|
def test_from_dict(self, del_hf_env_vars_if_empty):
|
|
64
72
|
"""Test deserialization from dict with environment variable token"""
|
|
65
73
|
data = {
|
|
File without changes
|
|
File without changes
|
{huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.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
|
{huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_document_embedder.py
RENAMED
|
File without changes
|
{huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_files/apple.jpg
RENAMED
|
File without changes
|
{huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_text_embedder.py
RENAMED
|
File without changes
|
|
File without changes
|