transformers-haystack 1.0.1__tar.gz → 1.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.
Files changed (36) hide show
  1. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/CHANGELOG.md +7 -0
  2. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/PKG-INFO +1 -1
  3. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/generators/transformers/chat/chat_generator.py +2 -6
  4. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/test_chat_generator.py +0 -127
  5. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/.gitignore +0 -0
  6. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/LICENSE.txt +0 -0
  7. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/README.md +0 -0
  8. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/pydoc/config_docusaurus.yml +0 -0
  9. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/pyproject.toml +0 -0
  10. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/common/py.typed +0 -0
  11. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/common/transformers/__init__.py +0 -0
  12. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/common/transformers/utils.py +0 -0
  13. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/classifiers/py.typed +0 -0
  14. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/classifiers/transformers/__init__.py +0 -0
  15. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/classifiers/transformers/zero_shot_document_classifier.py +0 -0
  16. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/extractors/py.typed +0 -0
  17. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/extractors/transformers/__init__.py +0 -0
  18. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/extractors/transformers/named_entity_extractor.py +0 -0
  19. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/generators/py.typed +0 -0
  20. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/generators/transformers/__init__.py +0 -0
  21. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/generators/transformers/chat/__init__.py +0 -0
  22. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/readers/py.typed +0 -0
  23. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/readers/transformers/__init__.py +0 -0
  24. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/readers/transformers/extractive_reader.py +0 -0
  25. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/routers/py.typed +0 -0
  26. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/routers/transformers/__init__.py +0 -0
  27. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/routers/transformers/text_router.py +0 -0
  28. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/src/haystack_integrations/components/routers/transformers/zero_shot_text_router.py +0 -0
  29. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/__init__.py +0 -0
  30. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/conftest.py +0 -0
  31. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/test_extractive_reader.py +0 -0
  32. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/test_named_entity_extractor.py +0 -0
  33. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/test_text_router.py +0 -0
  34. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/test_utils.py +0 -0
  35. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/test_zero_shot_document_classifier.py +0 -0
  36. {transformers_haystack-1.0.1 → transformers_haystack-1.1.0}/tests/test_zero_shot_text_router.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/transformers-v1.0.1] - 2026-09-23
4
+
5
+ ### 🐛 Bug Fixes
6
+
7
+ - Serialize missing init params in `to_dict` (transformers, amazon_bedrock) (#3873)
8
+
9
+
3
10
  ## [integrations/transformers-v1.0.0] - 2026-09-10
4
11
 
5
12
  ### 🐛 Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: transformers-haystack
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: Haystack integration for transformers
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/transformers#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -24,7 +24,6 @@ from haystack.tools import (
24
24
  flatten_tools_or_toolsets,
25
25
  serialize_tools_or_toolset,
26
26
  )
27
- from haystack.tools.utils import warm_up_tools
28
27
  from haystack.utils import ComponentDevice, Secret, deserialize_callable, serialize_callable
29
28
  from haystack.utils.hf import convert_message_to_hf_format, deserialize_hf_model_kwargs, serialize_hf_model_kwargs
30
29
  from huggingface_hub import model_info
@@ -238,7 +237,7 @@ class TransformersChatGenerator:
238
237
 
239
238
  def warm_up(self) -> None:
240
239
  """
241
- Initializes the component and warms up tools if provided.
240
+ Initializes the Transformers pipeline and the executor owned by the component.
242
241
  """
243
242
  if self.pipeline is None:
244
243
  pipeline_kwargs = _with_hf_token(self.huggingface_pipeline_kwargs, self.token)
@@ -251,10 +250,7 @@ class TransformersChatGenerator:
251
250
  raise ValueError(msg)
252
251
  pipeline_kwargs["task"] = task
253
252
 
254
- hf_pipeline = pipeline(**pipeline_kwargs)
255
- if self.tools:
256
- warm_up_tools(self.tools)
257
- self.pipeline = hf_pipeline
253
+ self.pipeline = pipeline(**pipeline_kwargs)
258
254
 
259
255
  if self._owns_executor and self.executor is None:
260
256
  self.executor = ThreadPoolExecutor(
@@ -365,133 +365,6 @@ class TestComponentLifecycle:
365
365
  device="cpu",
366
366
  )
367
367
 
368
- @patch("haystack_integrations.components.generators.transformers.chat.chat_generator.pipeline")
369
- def test_warm_up_with_tools(self, pipeline_mock):
370
- """Test that warm_up() calls warm_up on tools and is idempotent."""
371
-
372
- # Create a mock tool that tracks if warm_up() was called
373
- class MockTool(Tool):
374
- warm_up_call_count = 0 # Class variable to track calls
375
-
376
- def __init__(self):
377
- super().__init__(
378
- name="mock_tool",
379
- description="A mock tool for testing",
380
- parameters={"x": {"type": "string"}},
381
- function=lambda x: x,
382
- )
383
-
384
- def warm_up(self):
385
- MockTool.warm_up_call_count += 1
386
-
387
- # Reset the class variable before test
388
- MockTool.warm_up_call_count = 0
389
- mock_tool = MockTool()
390
-
391
- # Create TransformersChatGenerator with the mock tool
392
- generator = TransformersChatGenerator(
393
- model="mistralai/Mistral-7B-Instruct-v0.2",
394
- task="text-generation",
395
- device=ComponentDevice.from_str("cpu"),
396
- tools=[mock_tool],
397
- )
398
-
399
- # Verify initial state - warm_up not called yet
400
- assert MockTool.warm_up_call_count == 0
401
- assert generator.pipeline is None
402
-
403
- # Call warm_up() on the generator
404
- generator.warm_up()
405
-
406
- # Assert that the tool's warm_up() was called
407
- assert MockTool.warm_up_call_count == 1
408
- assert generator.pipeline is not None
409
-
410
- # Verify pipeline was initialized
411
- pipeline_mock.assert_called_once()
412
-
413
- # Call warm_up() again and verify it's idempotent (only warms up once)
414
- generator.warm_up()
415
-
416
- # The tool's warm_up should still only have been called once
417
- assert MockTool.warm_up_call_count == 1
418
- assert generator.pipeline is not None
419
- # Pipeline should still only have been called once
420
- pipeline_mock.assert_called_once()
421
-
422
- @patch("haystack_integrations.components.generators.transformers.chat.chat_generator.pipeline")
423
- def test_warm_up_with_no_tools(self, pipeline_mock):
424
- """Test that warm_up() works when no tools are provided."""
425
-
426
- generator = TransformersChatGenerator(
427
- model="mistralai/Mistral-7B-Instruct-v0.2", task="text-generation", device=ComponentDevice.from_str("cpu")
428
- )
429
-
430
- # Verify initial state
431
- assert generator.pipeline is None
432
- assert generator.tools is None
433
-
434
- # Call warm_up() - should not raise an error
435
- generator.warm_up()
436
-
437
- # Verify the component is warmed up
438
- assert generator.pipeline is not None
439
- pipeline_mock.assert_called_once()
440
-
441
- # Call warm_up() again - should be idempotent
442
- generator.warm_up()
443
- assert generator.pipeline is not None
444
- # Pipeline should still only have been called once
445
- pipeline_mock.assert_called_once()
446
-
447
- @patch("haystack_integrations.components.generators.transformers.chat.chat_generator.pipeline")
448
- def test_warm_up_with_multiple_tools(self, pipeline_mock):
449
- """Test that warm_up() works with multiple tools."""
450
-
451
- # Track warm_up calls
452
- warm_up_calls = []
453
-
454
- class MockTool(Tool):
455
- def __init__(self, tool_name):
456
- super().__init__(
457
- name=tool_name,
458
- description=f"Mock tool {tool_name}",
459
- parameters={"type": "object", "properties": {"x": {"type": "string"}}, "required": ["x"]},
460
- function=lambda x: f"{tool_name} result: {x}",
461
- )
462
-
463
- def warm_up(self):
464
- warm_up_calls.append(self.name)
465
-
466
- mock_tool1 = MockTool("tool1")
467
- mock_tool2 = MockTool("tool2")
468
-
469
- # Use a LIST of tools, not a Toolset
470
- generator = TransformersChatGenerator(
471
- model="mistralai/Mistral-7B-Instruct-v0.2",
472
- task="text-generation",
473
- device=ComponentDevice.from_str("cpu"),
474
- tools=[mock_tool1, mock_tool2],
475
- )
476
-
477
- # Call warm_up()
478
- generator.warm_up()
479
-
480
- # Assert that both tools' warm_up() were called
481
- assert "tool1" in warm_up_calls
482
- assert "tool2" in warm_up_calls
483
- assert generator.pipeline is not None
484
- pipeline_mock.assert_called_once()
485
-
486
- # Track count
487
- call_count = len(warm_up_calls)
488
-
489
- # Verify idempotency
490
- generator.warm_up()
491
- assert len(warm_up_calls) == call_count
492
- # Pipeline should still only have been called once
493
- pipeline_mock.assert_called_once()
494
-
495
368
 
496
369
  class TestRun:
497
370
  def test_run(self, mock_pipeline_with_tokenizer, chat_messages):