cohere-haystack 10.0.0__tar.gz → 10.0.1__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.
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/CHANGELOG.md +16 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/PKG-INFO +1 -1
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/embedders/cohere/document_embedder.py +2 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/embedders/cohere/utils.py +26 -17
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_document_embedder.py +29 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/.gitignore +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/LICENSE.txt +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/README.md +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/examples/cohere_embedding.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/examples/cohere_generation.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/examples/cohere_ranker.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/pydoc/config_docusaurus.yml +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/pyproject.toml +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/embedders/cohere/__init__.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/embedders/cohere/document_image_embedder.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/embedders/cohere/embedding_types.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/embedders/cohere/text_embedder.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/embedders/py.typed +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/generators/cohere/__init__.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/generators/cohere/chat/__init__.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/generators/cohere/chat/chat_generator.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/generators/py.typed +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/rankers/cohere/__init__.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/rankers/cohere/ranker.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/src/haystack_integrations/components/rankers/py.typed +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/__init__.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/conftest.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_chat_generator.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_chat_generator_async.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_chat_generator_chunks.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_document_image_embedder.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_files/apple.jpg +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_files/sample_pdf_1.pdf +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_ranker.py +0 -0
- {cohere_haystack-10.0.0 → cohere_haystack-10.0.1}/tests/test_text_embedder.py +0 -0
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/cohere-v10.0.0] - 2026-09-04
|
|
4
|
+
|
|
5
|
+
### 🚜 Refactor
|
|
6
|
+
|
|
7
|
+
- [**breaking**] Cohere - create clients in warm up methods (#3911)
|
|
8
|
+
|
|
9
|
+
### ⚙️ CI
|
|
10
|
+
|
|
11
|
+
- Improve changelog generation; fix existing changelogs (#3883)
|
|
12
|
+
|
|
13
|
+
### 🧹 Chores
|
|
14
|
+
|
|
15
|
+
- Clarify how generation_kwargs passed in run are handled (#3805)
|
|
16
|
+
- [**breaking**] Remove deprecated `CohereGenerator` (use `CohereChatGenerator` instead) (#3885)
|
|
17
|
+
|
|
18
|
+
|
|
3
19
|
## [integrations/cohere-v9.5.0] - 2026-08-11
|
|
4
20
|
|
|
5
21
|
### 🐛 Bug Fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cohere-haystack
|
|
3
|
-
Version: 10.0.
|
|
3
|
+
Version: 10.0.1
|
|
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
|
|
@@ -16,6 +16,8 @@ async def get_async_response(
|
|
|
16
16
|
model_name: str,
|
|
17
17
|
input_type: str,
|
|
18
18
|
truncate: str,
|
|
19
|
+
batch_size: int = 32,
|
|
20
|
+
progress_bar: bool = False,
|
|
19
21
|
embedding_type: EmbeddingTypes | None = None,
|
|
20
22
|
) -> tuple[list[list[float]], dict[str, Any]]:
|
|
21
23
|
"""
|
|
@@ -27,6 +29,9 @@ async def get_async_response(
|
|
|
27
29
|
:param input_type: one of "classification", "clustering", "search_document", "search_query".
|
|
28
30
|
The type of input text provided to embed.
|
|
29
31
|
:param truncate: one of "NONE", "START", "END". How the API handles text longer than the maximum token length.
|
|
32
|
+
:param batch_size: the batch size to use. The Cohere embed endpoint caps the number of texts per call, so the
|
|
33
|
+
texts are sent in batches just like the synchronous path.
|
|
34
|
+
:param progress_bar: if `True`, show a progress bar
|
|
30
35
|
:param embedding_type: the type of embeddings to return. Defaults to float embeddings.
|
|
31
36
|
|
|
32
37
|
:returns: A tuple of the embeddings and metadata.
|
|
@@ -35,24 +40,28 @@ async def get_async_response(
|
|
|
35
40
|
"""
|
|
36
41
|
all_embeddings: list[list[float]] = []
|
|
37
42
|
metadata: dict[str, Any] = {}
|
|
38
|
-
|
|
39
43
|
embedding_type = embedding_type or EmbeddingTypes.FLOAT
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
|
|
45
|
+
for i in tqdm(
|
|
46
|
+
range(0, len(texts), batch_size),
|
|
47
|
+
disable=not progress_bar,
|
|
48
|
+
desc="Calculating embeddings",
|
|
49
|
+
):
|
|
50
|
+
batch = texts[i : i + batch_size]
|
|
51
|
+
response = await cohere_async_client.embed(
|
|
52
|
+
texts=batch,
|
|
53
|
+
model=model_name,
|
|
54
|
+
input_type=input_type,
|
|
55
|
+
truncate=truncate,
|
|
56
|
+
embedding_types=[embedding_type.value],
|
|
57
|
+
)
|
|
58
|
+
for emb_tuple in response.embeddings:
|
|
59
|
+
# emb_tuple[0] is a str denoting the embedding type (e.g. "float", "int8", etc.)
|
|
60
|
+
if emb_tuple[1] is not None:
|
|
61
|
+
# ok we have embeddings for this type, let's take all the embeddings (a list of embeddings)
|
|
62
|
+
all_embeddings.extend(emb_tuple[1])
|
|
63
|
+
if response.meta is not None:
|
|
64
|
+
metadata = response.meta.model_dump()
|
|
56
65
|
|
|
57
66
|
return all_embeddings, metadata
|
|
58
67
|
|
|
@@ -247,6 +247,35 @@ class TestRun:
|
|
|
247
247
|
assert doc_with_embedding.meta == doc.meta
|
|
248
248
|
assert doc_with_embedding.embedding == embedding
|
|
249
249
|
|
|
250
|
+
@pytest.mark.asyncio
|
|
251
|
+
@patch("haystack_integrations.components.embedders.cohere.document_embedder.AsyncClientV2")
|
|
252
|
+
async def test_run_async_sends_texts_in_batches(self, mock_async_client_cls):
|
|
253
|
+
"""
|
|
254
|
+
run_async must honour batch_size like run does. The Cohere embed endpoint caps the number of
|
|
255
|
+
texts per call, so sending every text in a single request breaks on larger inputs.
|
|
256
|
+
"""
|
|
257
|
+
batch_sizes: list[int] = []
|
|
258
|
+
|
|
259
|
+
class _Response:
|
|
260
|
+
def __init__(self, n: int) -> None:
|
|
261
|
+
self.embeddings = [("float", [[0.1, 0.2, 0.3]] * n)]
|
|
262
|
+
self.meta = None
|
|
263
|
+
|
|
264
|
+
async def fake_embed(*, texts, **_kwargs):
|
|
265
|
+
batch_sizes.append(len(texts))
|
|
266
|
+
return _Response(len(texts))
|
|
267
|
+
|
|
268
|
+
mock_async_client_cls.return_value.embed = fake_embed
|
|
269
|
+
|
|
270
|
+
embedder = CohereDocumentEmbedder(api_key=Secret.from_token("test-api-key"), batch_size=2)
|
|
271
|
+
docs = [Document(content=f"doc {i}") for i in range(5)]
|
|
272
|
+
|
|
273
|
+
result = await embedder.run_async(docs)
|
|
274
|
+
|
|
275
|
+
assert batch_sizes == [2, 2, 1]
|
|
276
|
+
assert len(result["documents"]) == 5
|
|
277
|
+
assert all(doc.embedding == [0.1, 0.2, 0.3] for doc in result["documents"])
|
|
278
|
+
|
|
250
279
|
@patch("haystack_integrations.components.embedders.cohere.document_embedder.get_response")
|
|
251
280
|
def test_run_does_not_modify_original_documents(self, mock_get_response):
|
|
252
281
|
embedder = CohereDocumentEmbedder(api_key=Secret.from_token("test-api-key"))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|