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.
Files changed (29) hide show
  1. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/CHANGELOG.md +12 -0
  2. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/PKG-INFO +4 -4
  3. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/README.md +2 -2
  4. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/pyproject.toml +1 -0
  5. {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
  6. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/rankers/huggingface_api/ranker.py +1 -0
  7. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_chat_generator.py +29 -0
  8. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_ranker.py +8 -0
  9. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/.gitignore +0 -0
  10. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/LICENSE.txt +0 -0
  11. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/pydoc/config_docusaurus.yml +0 -0
  12. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/common/huggingface_api/__init__.py +0 -0
  13. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/common/huggingface_api/utils.py +0 -0
  14. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/common/py.typed +0 -0
  15. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/huggingface_api/__init__.py +0 -0
  16. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/huggingface_api/document_embedder.py +0 -0
  17. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/huggingface_api/text_embedder.py +0 -0
  18. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
  19. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/generators/huggingface_api/__init__.py +0 -0
  20. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/generators/huggingface_api/chat/__init__.py +0 -0
  21. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/generators/py.typed +0 -0
  22. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/rankers/huggingface_api/__init__.py +0 -0
  23. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/src/haystack_integrations/components/rankers/py.typed +0 -0
  24. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/__init__.py +0 -0
  25. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/conftest.py +0 -0
  26. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_document_embedder.py +0 -0
  27. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_files/apple.jpg +0 -0
  28. {huggingface_api_haystack-0.4.0 → huggingface_api_haystack-0.5.0}/tests/test_text_embedder.py +0 -0
  29. {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.4
1
+ Metadata-Version: 2.5
2
2
  Name: huggingface-api-haystack
3
- Version: 0.4.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
  [![PyPI - Version](https://img.shields.io/pypi/v/huggingface-api-haystack.svg)](https://pypi.org/project/huggingface-api-haystack)
29
29
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/huggingface-api-haystack.svg)](https://pypi.org/project/huggingface-api-haystack)
30
30
 
31
- - [Integration page](https://haystack.deepset.ai/integrations/huggingface_api)
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 `HF_API_TOKEN` environment variable.
40
+ To run integration tests locally, you need to export the `HF_TOKEN` environment variable.
@@ -3,7 +3,7 @@
3
3
  [![PyPI - Version](https://img.shields.io/pypi/v/huggingface-api-haystack.svg)](https://pypi.org/project/huggingface-api-haystack)
4
4
  [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/huggingface-api-haystack.svg)](https://pypi.org/project/huggingface-api-haystack)
5
5
 
6
- - [Integration page](https://haystack.deepset.ai/integrations/huggingface_api)
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 `HF_API_TOKEN` environment variable.
15
+ To run integration tests locally, you need to export the `HF_TOKEN` environment variable.
@@ -132,6 +132,7 @@ ignore = [
132
132
  "PLR0912",
133
133
  "PLR0913",
134
134
  "PLR0915",
135
+ "PLR0917",
135
136
  # Allow `Any` type - used legitimately for dynamic types and SDK boundaries
136
137
  "ANN401",
137
138
  ]
@@ -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
@@ -108,6 +108,7 @@ class HuggingFaceTEIRanker:
108
108
  self,
109
109
  url=self.url,
110
110
  top_k=self.top_k,
111
+ raw_scores=self.raw_scores,
111
112
  timeout=self.timeout,
112
113
  token=self.token,
113
114
  max_retries=self.max_retries,
@@ -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 = {