cohere-haystack 10.1.0__tar.gz → 11.0.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 (39) hide show
  1. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/CHANGELOG.md +7 -0
  2. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/PKG-INFO +4 -3
  3. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/pyproject.toml +9 -3
  4. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/embedders/cohere/document_embedder.py +1 -3
  5. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/embedders/cohere/document_image_embedder.py +1 -2
  6. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/embedders/cohere/text_embedder.py +1 -3
  7. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/generators/cohere/chat/chat_generator.py +7 -17
  8. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/rankers/cohere/ranker.py +1 -2
  9. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_chat_generator.py +7 -21
  10. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/.gitignore +0 -0
  11. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/LICENSE.txt +0 -0
  12. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/README.md +0 -0
  13. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/examples/cohere_embedding.py +0 -0
  14. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/examples/cohere_generation.py +0 -0
  15. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/examples/cohere_ranker.py +0 -0
  16. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/pydoc/config_docusaurus.yml +0 -0
  17. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/embedders/cohere/__init__.py +0 -0
  18. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/embedders/cohere/embedding_types.py +0 -0
  19. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/embedders/cohere/utils.py +0 -0
  20. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/embedders/py.typed +0 -0
  21. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/generators/cohere/__init__.py +0 -0
  22. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/generators/cohere/chat/__init__.py +0 -0
  23. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/generators/py.typed +0 -0
  24. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/rankers/cohere/__init__.py +0 -0
  25. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/components/rankers/py.typed +0 -0
  26. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/utils/cohere/__init__.py +0 -0
  27. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/utils/cohere/api_base_url.py +0 -0
  28. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/src/haystack_integrations/utils/py.typed +0 -0
  29. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/__init__.py +0 -0
  30. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/conftest.py +0 -0
  31. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_api_base_url.py +0 -0
  32. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_chat_generator_async.py +0 -0
  33. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_chat_generator_chunks.py +0 -0
  34. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_document_embedder.py +0 -0
  35. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_document_image_embedder.py +0 -0
  36. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_files/apple.jpg +0 -0
  37. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_files/sample_pdf_1.pdf +0 -0
  38. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_ranker.py +0 -0
  39. {cohere_haystack-10.1.0 → cohere_haystack-11.0.0}/tests/test_text_embedder.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/cohere-v10.1.0] - 2026-09-28
4
+
5
+ ### 🚀 Features
6
+
7
+ - *(cohere)* Add utility for API base URL validation (#4015)
8
+
9
+
3
10
  ## [integrations/cohere-v10.0.1] - 2026-09-10
4
11
 
5
12
  ### 🐛 Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: cohere-haystack
3
- Version: 10.1.0
3
+ Version: 11.0.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
@@ -10,17 +10,18 @@ License-File: LICENSE.txt
10
10
  Classifier: Development Status :: 4 - Beta
11
11
  Classifier: License :: OSI Approved :: Apache Software License
12
12
  Classifier: Programming Language :: Python
13
- Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
17
16
  Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
18
18
  Classifier: Programming Language :: Python :: Implementation :: CPython
19
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
- Requires-Python: >=3.10
20
+ Requires-Python: >=3.11
21
21
  Requires-Dist: cohere>=5.17.0
22
22
  Requires-Dist: haystack-ai>=3.0.0
23
23
  Requires-Dist: pydantic>=2.12.0
24
+ Requires-Dist: pydantic>=2.14.0; python_version >= '3.15'
24
25
  Description-Content-Type: text/markdown
25
26
 
26
27
  # cohere-haystack
@@ -7,7 +7,7 @@ name = "cohere-haystack"
7
7
  dynamic = ["version"]
8
8
  description = ''
9
9
  readme = "README.md"
10
- requires-python = ">=3.10"
10
+ requires-python = ">=3.11"
11
11
  license = "Apache-2.0"
12
12
  keywords = []
13
13
  authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
@@ -15,15 +15,21 @@ classifiers = [
15
15
  "License :: OSI Approved :: Apache Software License",
16
16
  "Development Status :: 4 - Beta",
17
17
  "Programming Language :: Python",
18
- "Programming Language :: Python :: 3.10",
19
18
  "Programming Language :: Python :: 3.11",
20
19
  "Programming Language :: Python :: 3.12",
21
20
  "Programming Language :: Python :: 3.13",
22
21
  "Programming Language :: Python :: 3.14",
22
+ "Programming Language :: Python :: 3.15",
23
23
  "Programming Language :: Python :: Implementation :: CPython",
24
24
  "Programming Language :: Python :: Implementation :: PyPy",
25
25
  ]
26
- dependencies = ["haystack-ai>=3.0.0", "cohere>=5.17.0", "pydantic>=2.12.0"]
26
+ dependencies = [
27
+ "haystack-ai>=3.0.0",
28
+ "cohere>=5.17.0",
29
+ "pydantic>=2.12.0",
30
+ # pydantic 2.14.0 is the first release whose pydantic-core has Python 3.15 wheels.
31
+ "pydantic>=2.14.0; python_version >= '3.15'",
32
+ ]
27
33
 
28
34
  [project.urls]
29
35
  Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/cohere#readme"
@@ -5,7 +5,7 @@ from dataclasses import replace
5
5
  from typing import Any, ClassVar
6
6
 
7
7
  from haystack import Document, component, default_from_dict, default_to_dict
8
- from haystack.utils import Secret, deserialize_secrets_inplace
8
+ from haystack.utils import Secret
9
9
 
10
10
  from cohere import AsyncClientV2, ClientV2
11
11
  from haystack_integrations.utils.cohere import validate_api_base_url
@@ -159,8 +159,6 @@ class CohereDocumentEmbedder:
159
159
  # drop legacy use_async_client parameter
160
160
  init_params.pop("use_async_client", None)
161
161
 
162
- deserialize_secrets_inplace(init_params, ["api_key"])
163
-
164
162
  # Convert embedding_type string to EmbeddingTypes enum value
165
163
  init_params["embedding_type"] = EmbeddingTypes.from_str(init_params["embedding_type"])
166
164
 
@@ -13,7 +13,7 @@ from haystack.components.converters.image.image_utils import (
13
13
  _PDFPageInfo,
14
14
  )
15
15
  from haystack.dataclasses import ByteStream
16
- from haystack.utils.auth import Secret, deserialize_secrets_inplace
16
+ from haystack.utils.auth import Secret
17
17
  from tqdm import tqdm
18
18
 
19
19
  from cohere import AsyncClientV2, ClientV2
@@ -188,7 +188,6 @@ class CohereDocumentImageEmbedder:
188
188
  Deserialized component.
189
189
  """
190
190
  init_params = data["init_parameters"]
191
- deserialize_secrets_inplace(init_params, keys=["api_key"])
192
191
  init_params["embedding_type"] = EmbeddingTypes.from_str(init_params["embedding_type"])
193
192
 
194
193
  return default_from_dict(cls, data)
@@ -4,7 +4,7 @@
4
4
  from typing import Any, ClassVar
5
5
 
6
6
  from haystack import component, default_from_dict, default_to_dict
7
- from haystack.utils import Secret, deserialize_secrets_inplace
7
+ from haystack.utils import Secret
8
8
 
9
9
  from cohere import AsyncClientV2, ClientV2
10
10
  from haystack_integrations.utils.cohere import validate_api_base_url
@@ -146,8 +146,6 @@ class CohereTextEmbedder:
146
146
  # drop legacy use_async_client parameter
147
147
  init_params.pop("use_async_client", None)
148
148
 
149
- deserialize_secrets_inplace(init_params, ["api_key"])
150
-
151
149
  # Convert embedding_type string to EmbeddingTypes enum value
152
150
  init_params["embedding_type"] = EmbeddingTypes.from_str(init_params["embedding_type"])
153
151
 
@@ -460,13 +460,11 @@ class CohereChatGenerator:
460
460
 
461
461
  ### Advanced example
462
462
 
463
- CohereChatGenerator can be integrated into pipelines and supports Haystack's tooling
464
- architecture, enabling tools to be invoked seamlessly across various generators.
463
+ CohereChatGenerator supports Haystack's tooling architecture, so it can drive tool calls in an `Agent`.
465
464
 
466
465
  ```python
467
- from haystack import Pipeline
466
+ from haystack.components.agents import Agent
468
467
  from haystack.dataclasses import ChatMessage
469
- from haystack.components.tools import ToolInvoker
470
468
  from haystack.tools import Tool
471
469
  from haystack_integrations.components.generators.cohere import CohereChatGenerator
472
470
 
@@ -490,20 +488,12 @@ class CohereChatGenerator:
490
488
  function=weather,
491
489
  )
492
490
 
493
- # Create and set up the pipeline
494
- pipeline = Pipeline()
495
- pipeline.add_component("generator", CohereChatGenerator(tools=[weather_tool]))
496
- pipeline.add_component("tool_invoker", ToolInvoker(tools=[weather_tool]))
497
- pipeline.connect("generator", "tool_invoker")
491
+ # The Agent calls the tool and feeds the result back to the model
492
+ agent = Agent(chat_generator=CohereChatGenerator(), tools=[weather_tool])
493
+ result = agent.run(messages=[ChatMessage.from_user("What's the weather like in Paris?")])
498
494
 
499
- # Run the pipeline with a weather query
500
- results = pipeline.run(
501
- data={"generator": {"messages": [ChatMessage.from_user("What's the weather like in Paris?")]}}
502
- )
503
-
504
- # The tool result will be available in the pipeline output
505
- print(results["tool_invoker"]["tool_messages"][0].tool_call_result.result)
506
- # Output: "The weather in Paris is sunny and 32°C"
495
+ print(result["last_message"].text)
496
+ # Output: "The weather in Paris is sunny and 32°C."
507
497
  ```
508
498
  """
509
499
 
@@ -2,7 +2,7 @@ from dataclasses import replace
2
2
  from typing import Any
3
3
 
4
4
  from haystack import Document, component, default_from_dict, default_to_dict, logging
5
- from haystack.utils import Secret, deserialize_secrets_inplace
5
+ from haystack.utils import Secret
6
6
 
7
7
  from cohere import AsyncClientV2, ClientV2
8
8
  from haystack_integrations.utils.cohere import validate_api_base_url
@@ -123,7 +123,6 @@ class CohereRanker:
123
123
  # was serialized with the old version
124
124
  data["init_parameters"].pop("max_chunks_per_doc", None)
125
125
 
126
- deserialize_secrets_inplace(data["init_parameters"], keys=["api_key"])
127
126
  return default_from_dict(cls, data)
128
127
 
129
128
  def _prepare_cohere_input_docs(self, documents: list[Document], top_k: int | None = None) -> tuple[list[str], int]:
@@ -4,12 +4,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
4
4
  import pytest
5
5
  from cohere.core import ApiError
6
6
  from haystack import Pipeline
7
+ from haystack.components.agents import Agent
7
8
  from haystack.components.generators.utils import print_streaming_chunk
8
-
9
- try:
10
- from haystack.components.tools import ToolInvoker
11
- except ImportError: # ToolInvoker was removed in Haystack 3.0
12
- ToolInvoker = None
13
9
  from haystack.dataclasses import ChatMessage, ChatRole, ImageContent, ToolCall
14
10
  from haystack.dataclasses.streaming_chunk import StreamingChunk
15
11
  from haystack.tools import Tool, Toolset
@@ -810,10 +806,9 @@ class TestCohereChatGeneratorInference:
810
806
  assert len(final_message.text) > 0
811
807
  assert "paris" in final_message.text.lower()
812
808
 
813
- @pytest.mark.skipif(ToolInvoker is None, reason="ToolInvoker is not available in the installed haystack-ai version")
814
- def test_pipeline_with_cohere_chat_generator(self):
809
+ def test_agent_with_cohere_chat_generator(self):
815
810
  """
816
- Test that the CohereChatGenerator component can be used in a pipeline
811
+ Test that the CohereChatGenerator component can drive tool calls in an Agent
817
812
  """
818
813
  weather_tool = Tool(
819
814
  name="weather",
@@ -831,20 +826,11 @@ class TestCohereChatGeneratorInference:
831
826
  function=weather,
832
827
  )
833
828
 
834
- pipeline = Pipeline()
835
- pipeline.add_component("generator", CohereChatGenerator(model="command-r7b-12-2024", tools=[weather_tool]))
836
- pipeline.add_component("tool_invoker", ToolInvoker(tools=[weather_tool]))
837
-
838
- pipeline.connect("generator", "tool_invoker")
829
+ agent = Agent(chat_generator=CohereChatGenerator(model="command-r7b-12-2024"), tools=[weather_tool])
830
+ result = agent.run(messages=[ChatMessage.from_user("What's the weather like in Paris?")])
839
831
 
840
- results = pipeline.run(
841
- data={"generator": {"messages": [ChatMessage.from_user("What's the weather like in Paris?")]}}
842
- )
843
-
844
- assert (
845
- "The weather in Paris is sunny and 32°C"
846
- == results["tool_invoker"]["tool_messages"][0].tool_call_result.result
847
- )
832
+ tool_results = [msg.tool_call_result.result for msg in result["messages"] if msg.tool_call_result]
833
+ assert "The weather in Paris is sunny and 32°C" in tool_results
848
834
 
849
835
  def test_live_run_multimodal(self):
850
836
  generator = CohereChatGenerator(