cohere-haystack 2.0.0__tar.gz → 2.0.2__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 (27) hide show
  1. cohere_haystack-2.0.2/CHANGELOG.md +187 -0
  2. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/PKG-INFO +2 -2
  3. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/pyproject.toml +11 -7
  4. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/embedders/cohere/document_embedder.py +1 -1
  5. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/generators/cohere/__init__.py +1 -1
  6. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/generators/cohere/chat/chat_generator.py +5 -5
  7. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/generators/cohere/generator.py +3 -3
  8. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/tests/test_cohere_chat_generator.py +13 -34
  9. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/tests/test_cohere_generator.py +1 -21
  10. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/tests/test_cohere_ranker.py +1 -0
  11. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/tests/test_document_embedder.py +1 -0
  12. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/tests/test_text_embedder.py +1 -0
  13. cohere_haystack-2.0.0/CHANGELOG.md +0 -108
  14. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/.gitignore +0 -0
  15. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/LICENSE.txt +0 -0
  16. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/README.md +0 -0
  17. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/examples/cohere_embedding.py +0 -0
  18. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/examples/cohere_generation.py +0 -0
  19. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/examples/cohere_ranker.py +0 -0
  20. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/pydoc/config.yml +0 -0
  21. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/embedders/cohere/__init__.py +0 -0
  22. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/embedders/cohere/text_embedder.py +0 -0
  23. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/embedders/cohere/utils.py +0 -0
  24. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/generators/cohere/chat/__init__.py +0 -0
  25. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/rankers/cohere/__init__.py +0 -0
  26. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/src/haystack_integrations/components/rankers/cohere/ranker.py +0 -0
  27. {cohere_haystack-2.0.0 → cohere_haystack-2.0.2}/tests/__init__.py +0 -0
@@ -0,0 +1,187 @@
1
+ # Changelog
2
+
3
+ ## [integrations/cohere-v2.0.1] - 2024-12-09
4
+
5
+ ### ⚙️ CI
6
+
7
+ - Adopt uv as installer (#1142)
8
+
9
+ ### 🧹 Chores
10
+
11
+ - Update ruff linting scripts and settings (#1105)
12
+ - Fix linting/isort (#1215)
13
+
14
+ ### 🌀 Miscellaneous
15
+
16
+ - Chore: use class methods to create `ChatMessage` (#1222)
17
+ - Chore: use `text` instead of `content` for `ChatMessage` in Cohere and Anthropic (#1237)
18
+
19
+ ## [integrations/cohere-v2.0.0] - 2024-09-16
20
+
21
+ ### 🚀 Features
22
+
23
+ - Update Anthropic/Cohere for tools use (#790)
24
+ - Update Cohere default LLMs, add examples and update unit tests (#838)
25
+ - Cohere LLM - adjust token counting meta to match OpenAI format (#1086)
26
+
27
+ ### 🐛 Bug Fixes
28
+
29
+ - Lints in `cohere-haystack` (#995)
30
+
31
+ ### 🧪 Testing
32
+
33
+ - Do not retry tests in `hatch run test` command (#954)
34
+
35
+ ### ⚙️ CI
36
+
37
+ - Retry tests to reduce flakyness (#836)
38
+
39
+ ### 🧹 Chores
40
+
41
+ - Update ruff invocation to include check parameter (#853)
42
+
43
+ ### 🌀 Miscellaneous
44
+
45
+ - Ci: install `pytest-rerunfailures` where needed; add retry config to `test-cov` script (#845)
46
+ - Update CohereChatGenerator docstrings (#958)
47
+ - Update CohereGenerator docstrings (#960)
48
+
49
+ ## [integrations/cohere-v1.1.1] - 2024-06-12
50
+
51
+ ### 🌀 Miscellaneous
52
+
53
+ - Chore: `CohereGenerator` - remove warning about `generate` API (#805)
54
+
55
+ ## [integrations/cohere-v1.1.0] - 2024-05-24
56
+
57
+ ### 🐛 Bug Fixes
58
+
59
+ - Remove support for generate API (#755)
60
+
61
+ ### 🌀 Miscellaneous
62
+
63
+ - Chore: change the pydoc renderer class (#718)
64
+
65
+ ## [integrations/cohere-v1.0.0] - 2024-05-03
66
+
67
+ ### 🌀 Miscellaneous
68
+
69
+ - Follow up: update Cohere integration to use Cohere SDK v5 (#711)
70
+
71
+ ## [integrations/cohere-v0.7.0] - 2024-05-02
72
+
73
+ ### 🌀 Miscellaneous
74
+
75
+ - Chore: add license classifiers (#680)
76
+ - Update Cohere integration to use Cohere SDK v5 (#702)
77
+
78
+ ## [integrations/cohere-v0.6.0] - 2024-04-08
79
+
80
+ ### 🚀 Features
81
+
82
+ - Add Cohere ranker (#643)
83
+
84
+ ## [integrations/cohere-v0.5.0] - 2024-03-29
85
+
86
+ ### 🌀 Miscellaneous
87
+
88
+ - Add the Cohere client name to cohere requests (#362)
89
+
90
+ ## [integrations/cohere-v0.4.1] - 2024-03-21
91
+
92
+ ### 🐛 Bug Fixes
93
+
94
+ - Fix order of API docs (#447)
95
+ - Fix tests (#561)
96
+
97
+ ### 📚 Documentation
98
+
99
+ - Update category slug (#442)
100
+ - Review cohere integration (#500)
101
+ - Small consistency improvements (#536)
102
+ - Disable-class-def (#556)
103
+
104
+ ### 🧹 Chores
105
+
106
+ - Update Cohere integration to use new generic callable (de)serializers for their callback handlers (#453)
107
+ - Use `serialize_callable` instead of `serialize_callback_handler` in Cohere (#460)
108
+
109
+ ### 🌀 Miscellaneous
110
+
111
+ - Choere - remove matching error message from tests (#419)
112
+ - Fix linting (#509)
113
+ - Make tests show coverage (#566)
114
+ - Refactor tests (#574)
115
+ - Test: relax test constraints (#591)
116
+ - Remove references to Python 3.7 (#601)
117
+ - Fix: Pin cohere version (#609)
118
+
119
+ ## [integrations/cohere-v0.4.0] - 2024-02-12
120
+
121
+ ### 🐛 Bug Fixes
122
+
123
+ - Fix Cohere tests (#337)
124
+ - Cohere inconsistent embeddings and documents lengths (#284)
125
+
126
+ ### 🚜 Refactor
127
+
128
+ - [**breaking**] Use `Secret` for API keys in Cohere components (#386)
129
+
130
+ ### 🧪 Testing
131
+
132
+ - Fix failing `TestCohereChatGenerator.test_from_dict_fail_wo_env_var` test (#393)
133
+
134
+ ### 🌀 Miscellaneous
135
+
136
+ - Cohere: generate api docs (#321)
137
+ - Fix: update to latest haystack-ai version (#348)
138
+
139
+ ## [integrations/cohere-v0.3.0] - 2024-01-25
140
+
141
+ ### 🐛 Bug Fixes
142
+
143
+ - Fix project URLs (#96)
144
+ - Cohere namespace reorg (#271)
145
+
146
+ ### 🚜 Refactor
147
+
148
+ - Use `hatch_vcs` to manage integrations versioning (#103)
149
+
150
+ ### 🧹 Chores
151
+
152
+ - [**breaking**] Rename `model_name` to `model` in the Cohere integration (#222)
153
+ - Cohere namespace change (#247)
154
+
155
+ ### 🌀 Miscellaneous
156
+
157
+ - Cohere: remove unused constant (#91)
158
+ - Change default 'input_type' for CohereTextEmbedder (#99)
159
+ - Change metadata to meta (#152)
160
+ - Add cohere chat generator (#88)
161
+ - Optimize API key reading (#162)
162
+ - Cohere - change metadata to meta (#178)
163
+
164
+ ## [integrations/cohere-v0.2.0] - 2023-12-11
165
+
166
+ ### 🚀 Features
167
+
168
+ - Add support for V3 Embed models to CohereEmbedders (#89)
169
+
170
+ ### 🌀 Miscellaneous
171
+
172
+ - Cohere: increase version to prepare release (#92)
173
+
174
+ ## [integrations/cohere-v0.1.1] - 2023-12-07
175
+
176
+ ### 🌀 Miscellaneous
177
+
178
+ - [cohere] Add text and document embedders (#80)
179
+ - [cohere] fix cohere pypi version badge and add Embedder note (#86)
180
+
181
+ ## [integrations/cohere-v0.0.1] - 2023-12-04
182
+
183
+ ### 🌀 Miscellaneous
184
+
185
+ - Add `cohere_haystack` integration package (#75)
186
+
187
+ <!-- generated by git-cliff -->
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: cohere-haystack
3
- Version: 2.0.0
3
+ Version: 2.0.2
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
@@ -41,6 +41,7 @@ root = "../.."
41
41
  git_describe_command = 'git describe --tags --match="integrations/cohere-v[0-9]*"'
42
42
 
43
43
  [tool.hatch.envs.default]
44
+ installer = "uv"
44
45
  dependencies = [
45
46
  "coverage[toml]>=6.5",
46
47
  "pytest",
@@ -60,15 +61,16 @@ docs = ["pydoc-markdown pydoc/config.yml"]
60
61
  python = ["3.8", "3.9", "3.10", "3.11"]
61
62
 
62
63
  [tool.hatch.envs.lint]
64
+ installer = "uv"
63
65
  detached = true
64
- dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
66
+ dependencies = ["pip", "black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
65
67
  [tool.hatch.envs.lint.scripts]
66
68
  typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
67
69
  style = [
68
- "ruff check {args:. --exclude tests/}",
70
+ "ruff check {args:.}",
69
71
  "black --check --diff {args:.}",
70
72
  ]
71
- fmt = ["black {args:.}", "ruff --fix {args:. --exclude tests/}", "style"]
73
+ fmt = ["black {args:.}", "ruff check --fix {args:}", "style"]
72
74
  all = ["style", "typing"]
73
75
 
74
76
  [tool.black]
@@ -79,6 +81,8 @@ skip-string-normalization = true
79
81
  [tool.ruff]
80
82
  target-version = "py38"
81
83
  line-length = 120
84
+
85
+ [tool.ruff.lint]
82
86
  select = [
83
87
  "A",
84
88
  "ARG",
@@ -127,13 +131,13 @@ unfixable = [
127
131
  "F401",
128
132
  ]
129
133
 
130
- [tool.ruff.isort]
131
- known-first-party = ["src"]
134
+ [tool.ruff.lint.isort]
135
+ known-first-party = ["haystack_integrations"]
132
136
 
133
- [tool.ruff.flake8-tidy-imports]
137
+ [tool.ruff.lint.flake8-tidy-imports]
134
138
  ban-relative-imports = "parents"
135
139
 
136
- [tool.ruff.per-file-ignores]
140
+ [tool.ruff.lint.per-file-ignores]
137
141
  # Tests can use magic values, assertions, and relative imports
138
142
  "tests/**/*" = ["PLR2004", "S101", "TID252"]
139
143
 
@@ -146,7 +146,7 @@ class CohereDocumentEmbedder:
146
146
  - `meta`: metadata about the embedding process.
147
147
  :raises TypeError: if the input is not a list of `Documents`.
148
148
  """
149
- if not isinstance(documents, list) or documents and not isinstance(documents[0], Document):
149
+ if not isinstance(documents, list) or (documents and not isinstance(documents[0], Document)):
150
150
  msg = (
151
151
  "CohereDocumentEmbedder expects a list of Documents as input."
152
152
  "In case you want to embed a string, please use the CohereTextEmbedder."
@@ -4,4 +4,4 @@
4
4
  from .chat.chat_generator import CohereChatGenerator
5
5
  from .generator import CohereGenerator
6
6
 
7
- __all__ = ["CohereGenerator", "CohereChatGenerator"]
7
+ __all__ = ["CohereChatGenerator", "CohereGenerator"]
@@ -136,7 +136,7 @@ class CohereChatGenerator:
136
136
 
137
137
  def _message_to_dict(self, message: ChatMessage) -> Dict[str, str]:
138
138
  role = "User" if message.role == ChatRole.USER else "Chatbot"
139
- chat_message = {"user_name": role, "text": message.content}
139
+ chat_message = {"user_name": role, "text": message.text}
140
140
  return chat_message
141
141
 
142
142
  @component.output_types(replies=List[ChatMessage])
@@ -157,7 +157,7 @@ class CohereChatGenerator:
157
157
  chat_history = [self._message_to_dict(m) for m in messages[:-1]]
158
158
  if self.streaming_callback:
159
159
  response = self.client.chat_stream(
160
- message=messages[-1].content,
160
+ message=messages[-1].text,
161
161
  model=self.model,
162
162
  chat_history=chat_history,
163
163
  **generation_kwargs,
@@ -172,7 +172,7 @@ class CohereChatGenerator:
172
172
  response_text += event.text
173
173
  elif event.event_type == "stream-end":
174
174
  finish_response = event.response
175
- chat_message = ChatMessage.from_assistant(content=response_text)
175
+ chat_message = ChatMessage.from_assistant(response_text)
176
176
 
177
177
  if finish_response and finish_response.meta:
178
178
  if finish_response.meta.billed_units:
@@ -190,7 +190,7 @@ class CohereChatGenerator:
190
190
  )
191
191
  else:
192
192
  response = self.client.chat(
193
- message=messages[-1].content,
193
+ message=messages[-1].text,
194
194
  model=self.model,
195
195
  chat_history=chat_history,
196
196
  **generation_kwargs,
@@ -219,7 +219,7 @@ class CohereChatGenerator:
219
219
  # TODO revisit to see if we need to handle multiple tool calls
220
220
  message = ChatMessage.from_assistant(cohere_response.tool_calls[0].json())
221
221
  elif cohere_response.text:
222
- message = ChatMessage.from_assistant(content=cohere_response.text)
222
+ message = ChatMessage.from_assistant(cohere_response.text)
223
223
  message.meta.update(
224
224
  {
225
225
  "model": self.model,
@@ -5,7 +5,7 @@ import logging
5
5
  from typing import Any, Callable, Dict, List, Optional
6
6
 
7
7
  from haystack import component
8
- from haystack.dataclasses import ChatMessage, ChatRole
8
+ from haystack.dataclasses import ChatMessage
9
9
  from haystack.utils import Secret
10
10
 
11
11
  from .chat.chat_generator import CohereChatGenerator
@@ -64,7 +64,7 @@ class CohereGenerator(CohereChatGenerator):
64
64
  - `replies`: A list of replies generated by the model.
65
65
  - `meta`: Information about the request.
66
66
  """
67
- chat_message = ChatMessage(content=prompt, role=ChatRole.USER, name="", meta={})
67
+ chat_message = ChatMessage.from_user(prompt)
68
68
  # Note we have to call super() like this because of the way components are dynamically built with the decorator
69
69
  results = super(CohereGenerator, self).run([chat_message]) # noqa
70
- return {"replies": [results["replies"][0].content], "meta": [results["replies"][0].meta]}
70
+ return {"replies": [results["replies"][0].text], "meta": [results["replies"][0].meta]}
@@ -7,6 +7,7 @@ from cohere.core import ApiError
7
7
  from haystack.components.generators.utils import print_streaming_chunk
8
8
  from haystack.dataclasses import ChatMessage, ChatRole, StreamingChunk
9
9
  from haystack.utils import Secret
10
+
10
11
  from haystack_integrations.components.generators.cohere import CohereChatGenerator
11
12
 
12
13
  pytestmark = pytest.mark.chat_generators
@@ -26,7 +27,7 @@ def streaming_chunk(text: str):
26
27
 
27
28
  @pytest.fixture
28
29
  def chat_messages():
29
- return [ChatMessage(content="What's the capital of France", role=ChatRole.ASSISTANT, name=None)]
30
+ return [ChatMessage.from_assistant("What's the capital of France")]
30
31
 
31
32
 
32
33
  class TestCohereChatGenerator:
@@ -97,26 +98,6 @@ class TestCohereChatGenerator:
97
98
  },
98
99
  }
99
100
 
100
- def test_to_dict_with_lambda_streaming_callback(self, monkeypatch):
101
- monkeypatch.setenv("COHERE_API_KEY", "test-api-key")
102
- component = CohereChatGenerator(
103
- model="command-r",
104
- streaming_callback=lambda x: x,
105
- api_base_url="test-base-url",
106
- generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"},
107
- )
108
- data = component.to_dict()
109
- assert data == {
110
- "type": "haystack_integrations.components.generators.cohere.chat.chat_generator.CohereChatGenerator",
111
- "init_parameters": {
112
- "model": "command-r",
113
- "api_base_url": "test-base-url",
114
- "api_key": {"env_vars": ["COHERE_API_KEY", "CO_API_KEY"], "strict": True, "type": "env_var"},
115
- "streaming_callback": "tests.test_cohere_chat_generator.<lambda>",
116
- "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
117
- },
118
- }
119
-
120
101
  def test_from_dict(self, monkeypatch):
121
102
  monkeypatch.setenv("COHERE_API_KEY", "fake-api-key")
122
103
  monkeypatch.setenv("CO_API_KEY", "fake-api-key")
@@ -163,12 +144,12 @@ class TestCohereChatGenerator:
163
144
  )
164
145
  @pytest.mark.integration
165
146
  def test_live_run(self):
166
- chat_messages = [ChatMessage(content="What's the capital of France", role=ChatRole.USER, name="", meta={})]
147
+ chat_messages = [ChatMessage.from_user("What's the capital of France")]
167
148
  component = CohereChatGenerator(generation_kwargs={"temperature": 0.8})
168
149
  results = component.run(chat_messages)
169
150
  assert len(results["replies"]) == 1
170
151
  message: ChatMessage = results["replies"][0]
171
- assert "Paris" in message.content
152
+ assert "Paris" in message.text
172
153
  assert "usage" in message.meta
173
154
  assert "prompt_tokens" in message.meta["usage"]
174
155
  assert "completion_tokens" in message.meta["usage"]
@@ -200,13 +181,11 @@ class TestCohereChatGenerator:
200
181
 
201
182
  callback = Callback()
202
183
  component = CohereChatGenerator(streaming_callback=callback)
203
- results = component.run(
204
- [ChatMessage(content="What's the capital of France? answer in a word", role=ChatRole.USER, name=None)]
205
- )
184
+ results = component.run([ChatMessage.from_user("What's the capital of France? answer in a word")])
206
185
 
207
186
  assert len(results["replies"]) == 1
208
187
  message: ChatMessage = results["replies"][0]
209
- assert "Paris" in message.content
188
+ assert "Paris" in message.text
210
189
 
211
190
  assert message.meta["finish_reason"] == "COMPLETE"
212
191
 
@@ -223,12 +202,12 @@ class TestCohereChatGenerator:
223
202
  )
224
203
  @pytest.mark.integration
225
204
  def test_live_run_with_connector(self):
226
- chat_messages = [ChatMessage(content="What's the capital of France", role=ChatRole.USER, name="", meta={})]
205
+ chat_messages = [ChatMessage.from_user("What's the capital of France")]
227
206
  component = CohereChatGenerator(generation_kwargs={"temperature": 0.8})
228
207
  results = component.run(chat_messages, generation_kwargs={"connectors": [{"id": "web-search"}]})
229
208
  assert len(results["replies"]) == 1
230
209
  message: ChatMessage = results["replies"][0]
231
- assert "Paris" in message.content
210
+ assert "Paris" in message.text
232
211
  assert message.meta["documents"] is not None
233
212
  assert "citations" in message.meta # Citations might be None
234
213
 
@@ -248,13 +227,13 @@ class TestCohereChatGenerator:
248
227
  self.responses += chunk.content if chunk.content else ""
249
228
 
250
229
  callback = Callback()
251
- chat_messages = [ChatMessage(content="What's the capital of France? answer in a word", role=None, name=None)]
230
+ chat_messages = [ChatMessage.from_user("What's the capital of France? answer in a word")]
252
231
  component = CohereChatGenerator(streaming_callback=callback)
253
232
  results = component.run(chat_messages, generation_kwargs={"connectors": [{"id": "web-search"}]})
254
233
 
255
234
  assert len(results["replies"]) == 1
256
235
  message: ChatMessage = results["replies"][0]
257
- assert "Paris" in message.content
236
+ assert "Paris" in message.text
258
237
 
259
238
  assert message.meta["finish_reason"] == "COMPLETE"
260
239
 
@@ -292,10 +271,10 @@ class TestCohereChatGenerator:
292
271
 
293
272
  first_reply = replies[0]
294
273
  assert isinstance(first_reply, ChatMessage), "First reply is not a ChatMessage instance"
295
- assert first_reply.content, "First reply has no content"
274
+ assert first_reply.text, "First reply has no text"
296
275
  assert ChatMessage.is_from(first_reply, ChatRole.ASSISTANT), "First reply is not from the assistant"
297
- assert "get_stock_price" in first_reply.content.lower(), "First reply does not contain get_stock_price"
276
+ assert "get_stock_price" in first_reply.text.lower(), "First reply does not contain get_stock_price"
298
277
  assert first_reply.meta, "First reply has no metadata"
299
- fc_response = json.loads(first_reply.content)
278
+ fc_response = json.loads(first_reply.text)
300
279
  assert "name" in fc_response, "First reply does not contain name of the tool"
301
280
  assert "parameters" in fc_response, "First reply does not contain parameters of the tool"
@@ -7,6 +7,7 @@ import pytest
7
7
  from cohere.core import ApiError
8
8
  from haystack.components.generators.utils import print_streaming_chunk
9
9
  from haystack.utils import Secret
10
+
10
11
  from haystack_integrations.components.generators.cohere import CohereGenerator
11
12
 
12
13
  pytestmark = pytest.mark.generators
@@ -77,27 +78,6 @@ class TestCohereGenerator:
77
78
  },
78
79
  }
79
80
 
80
- def test_to_dict_with_lambda_streaming_callback(self, monkeypatch):
81
- monkeypatch.setenv("COHERE_API_KEY", "test-api-key")
82
- component = CohereGenerator(
83
- model="command-r",
84
- max_tokens=10,
85
- some_test_param="test-params",
86
- streaming_callback=lambda x: x,
87
- api_base_url="test-base-url",
88
- )
89
- data = component.to_dict()
90
- assert data == {
91
- "type": "haystack_integrations.components.generators.cohere.generator.CohereGenerator",
92
- "init_parameters": {
93
- "model": "command-r",
94
- "streaming_callback": "tests.test_cohere_generator.<lambda>",
95
- "api_base_url": "test-base-url",
96
- "api_key": {"type": "env_var", "env_vars": ["COHERE_API_KEY", "CO_API_KEY"], "strict": True},
97
- "generation_kwargs": {},
98
- },
99
- }
100
-
101
81
  def test_from_dict(self, monkeypatch):
102
82
  monkeypatch.setenv("COHERE_API_KEY", "fake-api-key")
103
83
  monkeypatch.setenv("CO_API_KEY", "fake-api-key")
@@ -4,6 +4,7 @@ from unittest.mock import Mock, patch
4
4
  import pytest
5
5
  from haystack import Document
6
6
  from haystack.utils.auth import Secret
7
+
7
8
  from haystack_integrations.components.rankers.cohere import CohereRanker
8
9
 
9
10
  pytestmark = pytest.mark.ranker
@@ -6,6 +6,7 @@ import os
6
6
  import pytest
7
7
  from haystack import Document
8
8
  from haystack.utils import Secret
9
+
9
10
  from haystack_integrations.components.embedders.cohere import CohereDocumentEmbedder
10
11
 
11
12
  pytestmark = pytest.mark.embedders
@@ -5,6 +5,7 @@ import os
5
5
 
6
6
  import pytest
7
7
  from haystack.utils import Secret
8
+
8
9
  from haystack_integrations.components.embedders.cohere import CohereTextEmbedder
9
10
 
10
11
  pytestmark = pytest.mark.embedders
@@ -1,108 +0,0 @@
1
- # Changelog
2
-
3
- ## [unreleased]
4
-
5
- ### 🚀 Features
6
-
7
- - Update Anthropic/Cohere for tools use (#790)
8
- - Update Cohere default LLMs, add examples and update unit tests (#838)
9
-
10
- ### ⚙️ Miscellaneous Tasks
11
-
12
- - Retry tests to reduce flakyness (#836)
13
-
14
- ## [integrations/cohere-v1.1.1] - 2024-06-12
15
-
16
- ## [integrations/cohere-v1.1.0] - 2024-05-24
17
-
18
- ### 🐛 Bug Fixes
19
-
20
- - Remove support for generate API (#755)
21
-
22
- ## [integrations/cohere-v1.0.0] - 2024-05-03
23
-
24
- ## [integrations/cohere-v0.7.0] - 2024-05-02
25
-
26
- ## [integrations/cohere-v0.6.0] - 2024-04-08
27
-
28
- ### 🚀 Features
29
-
30
- - Add Cohere ranker (#643)
31
-
32
- ## [integrations/cohere-v0.5.0] - 2024-03-29
33
-
34
- ## [integrations/cohere-v0.4.1] - 2024-03-21
35
-
36
- ### 🐛 Bug Fixes
37
-
38
- - Fix order of API docs (#447)
39
-
40
- This PR will also push the docs to Readme
41
- - Fix tests (#561)
42
-
43
- * fix unit tests
44
-
45
- * try
46
-
47
- * remove flaky check
48
-
49
- ### 📚 Documentation
50
-
51
- - Update category slug (#442)
52
- - Review cohere integration (#500)
53
- - Small consistency improvements (#536)
54
- - Disable-class-def (#556)
55
-
56
- ### ⚙️ Miscellaneous Tasks
57
-
58
- - Update Cohere integration to use new generic callable (de)serializers for their callback handlers (#453)
59
- - Use `serialize_callable` instead of `serialize_callback_handler` in Cohere (#460)
60
-
61
- ### Cohere
62
-
63
- - Fix linting (#509)
64
-
65
- ## [integrations/cohere-v0.4.0] - 2024-02-12
66
-
67
- ### 🐛 Bug Fixes
68
-
69
- - Fix Cohere tests (#337)
70
- - Cohere inconsistent embeddings and documents lengths (#284)
71
-
72
- ### 🚜 Refactor
73
-
74
- - [**breaking**] Use `Secret` for API keys in Cohere components (#386)
75
-
76
- ### 🧪 Testing
77
-
78
- - Fix failing `TestCohereChatGenerator.test_from_dict_fail_wo_env_var` test (#393)
79
-
80
- ## [integrations/cohere-v0.3.0] - 2024-01-25
81
-
82
- ### 🐛 Bug Fixes
83
-
84
- - Fix project urls (#96)
85
-
86
-
87
- - Cohere namespace reorg (#271)
88
-
89
- ### 🚜 Refactor
90
-
91
- - Use `hatch_vcs` to manage integrations versioning (#103)
92
-
93
- ### ⚙️ Miscellaneous Tasks
94
-
95
- - [**breaking**] Rename `model_name` to `model` in the Cohere integration (#222)
96
- - Cohere namespace change (#247)
97
-
98
- ## [integrations/cohere-v0.2.0] - 2023-12-11
99
-
100
- ### 🚀 Features
101
-
102
- - Add support for V3 Embed models to CohereEmbedders (#89)
103
-
104
- ## [integrations/cohere-v0.1.1] - 2023-12-07
105
-
106
- ## [integrations/cohere-v0.0.1] - 2023-12-04
107
-
108
- <!-- generated by git-cliff -->