cohere-haystack 9.2.0__tar.gz → 9.3.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 (38) hide show
  1. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/CHANGELOG.md +11 -0
  2. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/PKG-INFO +1 -1
  3. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/generators/cohere/chat/chat_generator.py +6 -3
  4. cohere_haystack-9.3.0/tests/conftest.py +18 -0
  5. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_chat_generator.py +11 -15
  6. cohere_haystack-9.2.0/tests/conftest.py +0 -8
  7. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/.gitignore +0 -0
  8. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/LICENSE.txt +0 -0
  9. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/README.md +0 -0
  10. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/examples/cohere_embedding.py +0 -0
  11. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/examples/cohere_generation.py +0 -0
  12. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/examples/cohere_ranker.py +0 -0
  13. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/pydoc/config_docusaurus.yml +0 -0
  14. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/pyproject.toml +0 -0
  15. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/embedders/cohere/__init__.py +0 -0
  16. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/embedders/cohere/document_embedder.py +0 -0
  17. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/embedders/cohere/document_image_embedder.py +0 -0
  18. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/embedders/cohere/embedding_types.py +0 -0
  19. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/embedders/cohere/text_embedder.py +0 -0
  20. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/embedders/cohere/utils.py +0 -0
  21. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
  22. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/generators/cohere/__init__.py +0 -0
  23. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/generators/cohere/chat/__init__.py +0 -0
  24. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/generators/cohere/generator.py +0 -0
  25. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/generators/py.typed +0 -0
  26. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/rankers/cohere/__init__.py +0 -0
  27. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/rankers/cohere/ranker.py +0 -0
  28. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/src/haystack_integrations/components/rankers/py.typed +0 -0
  29. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/__init__.py +0 -0
  30. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_chat_generator_async.py +0 -0
  31. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_chat_generator_chunks.py +0 -0
  32. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_document_embedder.py +0 -0
  33. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_document_image_embedder.py +0 -0
  34. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_files/apple.jpg +0 -0
  35. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_files/sample_pdf_1.pdf +0 -0
  36. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_generator.py +0 -0
  37. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_ranker.py +0 -0
  38. {cohere_haystack-9.2.0 → cohere_haystack-9.3.0}/tests/test_text_embedder.py +0 -0
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/cohere-v9.2.0] - 2026-06-05
4
+
5
+ ### 🚀 Features
6
+
7
+ - Cohere - accept str as ChatGenerator input; deprecate generator (#3395)
8
+
9
+ ### 🧹 Chores
10
+
11
+ - Cohere - set lower bound pin for Pydantic (#3284)
12
+
13
+
3
14
  ## [integrations/cohere-v9.1.0] - 2026-04-13
4
15
 
5
16
  ### 🚀 Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cohere-haystack
3
- Version: 9.2.0
3
+ Version: 9.3.0
4
4
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/cohere#readme
5
5
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
6
6
  Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/cohere
@@ -1,3 +1,4 @@
1
+ import inspect
1
2
  import json
2
3
  from collections.abc import AsyncIterator, Iterator
3
4
  from typing import Any, ClassVar, Literal, get_args
@@ -6,7 +7,6 @@ from haystack import component, default_from_dict, default_to_dict, logging
6
7
  from haystack.components.generators.utils import _convert_streaming_chunks_to_chat_message, _normalize_messages
7
8
  from haystack.dataclasses import ChatMessage, ComponentInfo, ImageContent, TextContent, ToolCall
8
9
  from haystack.dataclasses.streaming_chunk import (
9
- AsyncStreamingCallbackT,
10
10
  FinishReason,
11
11
  StreamingCallbackT,
12
12
  StreamingChunk,
@@ -351,7 +351,7 @@ def _parse_streaming_response(
351
351
  async def _parse_async_streaming_response(
352
352
  response: AsyncIterator[StreamedChatResponseV2],
353
353
  model: str,
354
- streaming_callback: AsyncStreamingCallbackT,
354
+ streaming_callback: StreamingCallbackT,
355
355
  component_info: ComponentInfo,
356
356
  ) -> ChatMessage:
357
357
  """
@@ -375,7 +375,10 @@ async def _parse_async_streaming_response(
375
375
 
376
376
  original_chunks.append(chunk)
377
377
  chunks.append(streaming_chunk)
378
- await streaming_callback(streaming_chunk)
378
+ # sync callbacks are allowed in async contexts with Haystack >= 3.0, so only await async ones
379
+ callback_result = streaming_callback(streaming_chunk)
380
+ if inspect.isawaitable(callback_result):
381
+ await callback_result
379
382
 
380
383
  return _convert_streaming_chunks_to_chat_message(chunks=chunks)
381
384
 
@@ -0,0 +1,18 @@
1
+ from pathlib import Path
2
+
3
+ import pytest
4
+
5
+
6
+ @pytest.fixture()
7
+ def test_files_path():
8
+ return Path(__file__).parent / "test_files"
9
+
10
+
11
+ @pytest.fixture(autouse=True)
12
+ def allow_deserialization_of_test_modules(monkeypatch):
13
+ """
14
+ haystack-ai >= 3.0 refuses to deserialize classes and callables from modules outside its
15
+ trusted-module allowlist. Tools and callbacks defined in the test modules live outside that
16
+ allowlist, so trust them explicitly; haystack-ai 2.x ignores this environment variable.
17
+ """
18
+ monkeypatch.setenv("HAYSTACK_DESERIALIZATION_ALLOWLIST", "tests,test_*")
@@ -5,7 +5,11 @@ import pytest
5
5
  from cohere.core import ApiError
6
6
  from haystack import Pipeline
7
7
  from haystack.components.generators.utils import print_streaming_chunk
8
- from haystack.components.tools import ToolInvoker
8
+
9
+ try:
10
+ from haystack.components.tools import ToolInvoker
11
+ except ImportError: # ToolInvoker was removed in Haystack 3.0
12
+ ToolInvoker = None
9
13
  from haystack.dataclasses import ChatMessage, ChatRole, ImageContent, ToolCall
10
14
  from haystack.dataclasses.streaming_chunk import StreamingChunk
11
15
  from haystack.tools import Tool, Toolset
@@ -337,6 +341,11 @@ class TestCohereChatGenerator:
337
341
 
338
342
  pipeline_dict = pipeline.to_dict()
339
343
 
344
+ # the Tool serialization format is owned by haystack-ai and varies across its versions; the
345
+ # dumps/loads round-trip below covers the tools, so exclude them from the pinned-dict comparison
346
+ tools_entries = pipeline_dict["components"]["generator"]["init_parameters"].pop("tools")
347
+ assert len(tools_entries) == 1
348
+
340
349
  expected_dict = {
341
350
  "metadata": {},
342
351
  "max_runs_per_component": 100,
@@ -352,20 +361,6 @@ class TestCohereChatGenerator:
352
361
  "generation_kwargs": {"temperature": 0.7},
353
362
  "timeout": None,
354
363
  "max_retries": None,
355
- "tools": [
356
- {
357
- "type": "haystack.tools.tool.Tool",
358
- "data": {
359
- "name": "weather",
360
- "description": "useful to determine the weather in a given location",
361
- "parameters": {"city": {"type": "string"}},
362
- "function": "tests.test_chat_generator.weather",
363
- "outputs_to_string": tool.outputs_to_string,
364
- "inputs_from_state": tool.inputs_from_state,
365
- "outputs_to_state": tool.outputs_to_state,
366
- },
367
- }
368
- ],
369
364
  },
370
365
  }
371
366
  },
@@ -742,6 +737,7 @@ class TestCohereChatGeneratorInference:
742
737
  assert len(final_message.text) > 0
743
738
  assert "paris" in final_message.text.lower()
744
739
 
740
+ @pytest.mark.skipif(ToolInvoker is None, reason="ToolInvoker is not available in the installed haystack-ai version")
745
741
  def test_pipeline_with_cohere_chat_generator(self):
746
742
  """
747
743
  Test that the CohereChatGenerator component can be used in a pipeline
@@ -1,8 +0,0 @@
1
- from pathlib import Path
2
-
3
- import pytest
4
-
5
-
6
- @pytest.fixture()
7
- def test_files_path():
8
- return Path(__file__).parent / "test_files"