chroma-haystack 2.0.0__tar.gz → 2.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.
Files changed (54) hide show
  1. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/CHANGELOG.md +98 -11
  2. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/PKG-INFO +1 -1
  3. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/src/haystack_integrations/document_stores/chroma/document_store.py +19 -7
  4. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/tests/test_document_store.py +22 -14
  5. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/.gitignore +0 -0
  6. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/LICENSE +0 -0
  7. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/README.md +0 -0
  8. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_01.txt +0 -0
  9. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_02.txt +0 -0
  10. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_03.txt +0 -0
  11. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_04.txt +0 -0
  12. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_05.txt +0 -0
  13. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_06.txt +0 -0
  14. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_07.txt +0 -0
  15. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_08.txt +0 -0
  16. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_09.txt +0 -0
  17. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_10.txt +0 -0
  18. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_11.txt +0 -0
  19. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_12.txt +0 -0
  20. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_20.txt +0 -0
  21. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_21.txt +0 -0
  22. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_22.txt +0 -0
  23. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_23.txt +0 -0
  24. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_24.txt +0 -0
  25. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_25.txt +0 -0
  26. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_26.txt +0 -0
  27. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_27.txt +0 -0
  28. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_28.txt +0 -0
  29. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_29.txt +0 -0
  30. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_30.txt +0 -0
  31. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_31.txt +0 -0
  32. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_32.txt +0 -0
  33. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_40.txt +0 -0
  34. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_41.txt +0 -0
  35. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_42.txt +0 -0
  36. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_43.txt +0 -0
  37. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_44.txt +0 -0
  38. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_45.txt +0 -0
  39. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_46.txt +0 -0
  40. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_50.txt +0 -0
  41. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_51.txt +0 -0
  42. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_52.txt +0 -0
  43. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/data/usr_90.txt +0 -0
  44. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/example/example.py +0 -0
  45. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/pydoc/config.yml +0 -0
  46. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/pyproject.toml +0 -0
  47. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/src/haystack_integrations/components/retrievers/chroma/__init__.py +0 -0
  48. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/src/haystack_integrations/components/retrievers/chroma/retriever.py +0 -0
  49. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/src/haystack_integrations/document_stores/chroma/__init__.py +0 -0
  50. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/src/haystack_integrations/document_stores/chroma/errors.py +0 -0
  51. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/src/haystack_integrations/document_stores/chroma/filters.py +0 -0
  52. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/src/haystack_integrations/document_stores/chroma/utils.py +0 -0
  53. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/tests/__init__.py +0 -0
  54. {chroma_haystack-2.0.0 → chroma_haystack-2.0.1}/tests/test_retriever.py +0 -0
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/chroma-v1.0.1] - 2025-02-14
4
+
5
+ ### 🧹 Chores
6
+
7
+ - Inherit from `FilterDocumentsTestWithDataframe` in Document Stores (#1290)
8
+
9
+ ### 🌀 Miscellaneous
10
+
11
+ - Fix: Chroma - make `filter_documents` method return embeddings (#1361)
12
+
13
+ ## [integrations/chroma-v2.0.0] - 2025-01-02
14
+
15
+ ### 🧹 Chores
16
+
17
+ - Fix linting/isort (#1215)
18
+ - Chroma - pin `tokenizers` (#1223)
19
+
20
+ ### 🌀 Miscellaneous
21
+
22
+ - Unpin tokenizers (#1233)
23
+ - Fix: updates for Chroma 0.6.0 (#1270)
24
+
3
25
  ## [integrations/chroma-v1.0.0] - 2024-11-06
4
26
 
5
27
  ### 🐛 Bug Fixes
@@ -7,13 +29,14 @@
7
29
  - Fixing Chroma tests due `chromadb` update behaviour change (#1148)
8
30
  - Adapt our implementation to breaking changes in Chroma 0.5.17 (#1165)
9
31
 
10
- ### ⚙️ Miscellaneous Tasks
32
+ ### ⚙️ CI
11
33
 
12
34
  - Adopt uv as installer (#1142)
13
35
 
36
+
14
37
  ## [integrations/chroma-v0.22.1] - 2024-09-30
15
38
 
16
- ### Chroma
39
+ ### 🌀 Miscellaneous
17
40
 
18
41
  - Empty filters should behave as no filters (#1117)
19
42
 
@@ -26,32 +49,36 @@
26
49
 
27
50
  ### 🐛 Bug Fixes
28
51
 
29
- - Fix chroma linting; rm numpy (#1063)
30
-
31
- Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
52
+ - Refactor: fix chroma linting; do not use numpy (#1063)
32
53
  - Filters in chroma integration (#1072)
33
54
 
34
55
  ### 🧪 Testing
35
56
 
36
57
  - Do not retry tests in `hatch run test` command (#954)
37
58
 
38
- ### ⚙️ Miscellaneous Tasks
59
+ ### 🧹 Chores
39
60
 
40
61
  - Chroma - ruff update, don't ruff tests (#983)
41
62
  - Update ruff linting scripts and settings (#1105)
42
63
 
64
+ ### 🌀 Miscellaneous
65
+
66
+ - Chore: ChromaDocumentStore lint fix (#1065)
67
+
43
68
  ## [integrations/chroma-v0.21.1] - 2024-07-17
44
69
 
45
70
  ### 🐛 Bug Fixes
46
71
 
47
72
  - `ChromaDocumentStore` - discard `meta` items when the type of their value is not supported in Chroma (#907)
48
73
 
74
+
49
75
  ## [integrations/chroma-v0.21.0] - 2024-07-16
50
76
 
51
77
  ### 🚀 Features
52
78
 
53
79
  - Add metadata parameter to ChromaDocumentStore. (#906)
54
80
 
81
+
55
82
  ## [integrations/chroma-v0.20.1] - 2024-07-15
56
83
 
57
84
  ### 🚀 Features
@@ -64,15 +91,32 @@ Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
64
91
  - Allow search in ChromaDocumentStore without metadata (#863)
65
92
  - `Chroma` - Fallback to default filter policy when deserializing retrievers without the init parameter (#897)
66
93
 
67
- ### ⚙️ Miscellaneous Tasks
94
+ ### ⚙️ CI
68
95
 
69
96
  - Retry tests to reduce flakyness (#836)
97
+
98
+ ### 🧹 Chores
99
+
70
100
  - Update ruff invocation to include check parameter (#853)
71
101
 
102
+ ### 🌀 Miscellaneous
103
+
104
+ - Ci: install `pytest-rerunfailures` where needed; add retry config to `test-cov` script (#845)
105
+ - Chore: Minor retriever pydoc fix (#884)
106
+
72
107
  ## [integrations/chroma-v0.18.0] - 2024-05-31
73
108
 
109
+ ### 🌀 Miscellaneous
110
+
111
+ - Chore: pin chromadb>=0.5.0 (#777)
112
+
74
113
  ## [integrations/chroma-v0.17.0] - 2024-05-10
75
114
 
115
+ ### 🌀 Miscellaneous
116
+
117
+ - Chore: change the pydoc renderer class (#718)
118
+ - Implement filters for chromaQueryTextRetriever via existing haystack filters logic (#705)
119
+
76
120
  ## [integrations/chroma-v0.16.0] - 2024-05-02
77
121
 
78
122
  ### 📚 Documentation
@@ -80,15 +124,27 @@ Co-authored-by: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com>
80
124
  - Small consistency improvements (#536)
81
125
  - Disable-class-def (#556)
82
126
 
127
+ ### 🌀 Miscellaneous
128
+
129
+ - Make tests show coverage (#566)
130
+ - Refactor tests (#574)
131
+ - Remove references to Python 3.7 (#601)
132
+ - Make Document Stores initially skip `SparseEmbedding` (#606)
133
+ - Pin databind-core (#619)
134
+ - Chore: add license classifiers (#680)
135
+ - Feature/bump chromadb dep to 0.5.0 (#700)
136
+
83
137
  ## [integrations/chroma-v0.15.0] - 2024-03-01
84
138
 
139
+ ### 🌀 Miscellaneous
140
+
141
+ - Release chroma on python 3.8 (#512)
142
+
85
143
  ## [integrations/chroma-v0.14.0] - 2024-02-29
86
144
 
87
145
  ### 🐛 Bug Fixes
88
146
 
89
147
  - Fix order of API docs (#447)
90
-
91
- This PR will also push the docs to Readme
92
148
  - Serialize the path to the local db (#506)
93
149
 
94
150
  ### 📚 Documentation
@@ -96,35 +152,59 @@ This PR will also push the docs to Readme
96
152
  - Update category slug (#442)
97
153
  - Review chroma integration (#501)
98
154
 
155
+ ### 🌀 Miscellaneous
156
+
157
+ - Small improvements (#443)
158
+ - Fix: make write_documents compatible with the DocumentStore protocol (#505)
159
+
99
160
  ## [integrations/chroma-v0.13.0] - 2024-02-13
100
161
 
162
+ ### 🌀 Miscellaneous
163
+
164
+ - Chroma: rename retriever (#407)
165
+
101
166
  ## [integrations/chroma-v0.12.0] - 2024-02-06
102
167
 
103
168
  ### 🚀 Features
104
169
 
105
170
  - Generate API docs (#262)
106
171
 
172
+ ### 🌀 Miscellaneous
173
+
174
+ - Add typing_extensions pin to Chroma integration (#295)
175
+ - Allows filters and persistent document stores for Chroma (#342)
176
+
107
177
  ## [integrations/chroma-v0.11.0] - 2024-01-18
108
178
 
109
179
  ### 🐛 Bug Fixes
110
180
 
111
181
  - Chroma DocumentStore creation for pre-existing collection name (#157)
112
182
 
183
+ ### 🌀 Miscellaneous
184
+
185
+ - Mount chroma integration under `haystack_integrations.*` (#193)
186
+ - Remove ChromaSingleQueryRetriever (#240)
187
+
113
188
  ## [integrations/chroma-v0.9.0] - 2023-12-20
114
189
 
115
190
  ### 🐛 Bug Fixes
116
191
 
117
- - Fix project urls (#96)
192
+ - Fix project URLs (#96)
118
193
 
119
194
  ### 🚜 Refactor
120
195
 
121
196
  - Use `hatch_vcs` to manage integrations versioning (#103)
122
197
 
198
+ ### 🌀 Miscellaneous
199
+
200
+ - Chore: pin chroma version (#104)
201
+ - Fix: update to the latest Document format (#127)
202
+
123
203
  ## [integrations/chroma-v0.8.1] - 2023-12-05
124
204
 
125
205
  ### 🐛 Bug Fixes
126
206
 
127
- - Fix import and increase version (#77)
207
+ - Document Stores: fix protocol import (#77)
128
208
 
129
209
  ## [integrations/chroma-v0.8.0] - 2023-12-04
130
210
 
@@ -132,4 +212,11 @@ This PR will also push the docs to Readme
132
212
 
133
213
  - Fix license headers
134
214
 
215
+ ### 🌀 Miscellaneous
216
+
217
+ - Reorganize repository (#62)
218
+ - Update import paths (#64)
219
+ - Patch chroma filters tests (#67)
220
+ - Remove Document Store decorator (#76)
221
+
135
222
  <!-- generated by git-cliff -->
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chroma-haystack
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/chroma#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/chroma
@@ -9,6 +9,7 @@ from chromadb.api.types import GetResult, QueryResult
9
9
  from haystack import default_from_dict, default_to_dict
10
10
  from haystack.dataclasses import Document
11
11
  from haystack.document_stores.types import DuplicatePolicy
12
+ from numpy import ndarray
12
13
 
13
14
  from .filters import _convert_filters
14
15
  from .utils import get_embedding_function
@@ -208,18 +209,18 @@ class ChromaDocumentStore:
208
209
  self._ensure_initialized()
209
210
  assert self._collection is not None
210
211
 
212
+ kwargs: Dict[str, Any] = {"include": ["embeddings", "documents", "metadatas"]}
213
+
211
214
  if filters:
212
215
  chroma_filter = _convert_filters(filters)
213
- kwargs: Dict[str, Any] = {"where": chroma_filter.where}
216
+ kwargs["where"] = chroma_filter.where
214
217
 
215
218
  if chroma_filter.ids:
216
219
  kwargs["ids"] = chroma_filter.ids
217
220
  if chroma_filter.where_document:
218
221
  kwargs["where_document"] = chroma_filter.where_document
219
222
 
220
- result = self._collection.get(**kwargs)
221
- else:
222
- result = self._collection.get()
223
+ result = self._collection.get(**kwargs)
223
224
 
224
225
  return self._get_result_to_documents(result)
225
226
 
@@ -249,11 +250,19 @@ class ChromaDocumentStore:
249
250
  if doc.content is None:
250
251
  logger.warning(
251
252
  "ChromaDocumentStore cannot store documents with `content=None`. "
252
- "`array`, `dataframe` and `blob` are not supported. "
253
253
  "Document with id %s will be skipped.",
254
254
  doc.id,
255
255
  )
256
256
  continue
257
+ elif (hasattr(doc, "dataframe") and doc.dataframe is not None) or (
258
+ hasattr(doc, "blob") and doc.blob is not None
259
+ ):
260
+ logger.warning(
261
+ "Document with id %s contains `dataframe` or `blob` fields. "
262
+ "ChromaDocumentStore cannot store `dataframe` or `blob` fields. "
263
+ "These fields will be ignored. ",
264
+ doc.id,
265
+ )
257
266
  data = {"ids": [doc.id], "documents": [doc.content]}
258
267
 
259
268
  if doc.meta:
@@ -416,8 +425,11 @@ class ChromaDocumentStore:
416
425
  document_dict["meta"] = result_metadata[i]
417
426
 
418
427
  result_embeddings = result.get("embeddings")
419
- if result_embeddings:
420
- document_dict["embedding"] = list(result_embeddings[i])
428
+ if result_embeddings is not None:
429
+ if isinstance(result_embeddings[i], ndarray):
430
+ document_dict["embedding"] = result_embeddings[i].tolist()
431
+ else:
432
+ document_dict["embedding"] = result_embeddings[i]
421
433
 
422
434
  retval.append(Document.from_dict(document_dict))
423
435
 
@@ -11,7 +11,7 @@ from unittest import mock
11
11
  import numpy as np
12
12
  import pytest
13
13
  from chromadb.api.types import Documents, EmbeddingFunction, Embeddings
14
- from haystack import Document
14
+ from haystack.dataclasses import ByteStream, Document
15
15
  from haystack.testing.document_store import (
16
16
  TEST_EMBEDDING_1,
17
17
  TEST_EMBEDDING_2,
@@ -179,7 +179,13 @@ class TestDocumentStore(CountDocumentsTest, DeleteDocumentsTest, FilterDocuments
179
179
  document_store.write_documents([doc])
180
180
  document_store.delete_documents(["non_existing"])
181
181
  filters = {"operator": "==", "field": "id", "value": doc.id}
182
- assert document_store.filter_documents(filters=filters) == [doc]
182
+
183
+ assert document_store.filter_documents(filters=filters)[0].id == doc.id
184
+
185
+ def test_filter_documents_return_embeddings(self, document_store: ChromaDocumentStore):
186
+ document_store.write_documents([Document(content="test doc", embedding=TEST_EMBEDDING_1)])
187
+
188
+ assert document_store.filter_documents()[0].embedding == pytest.approx(TEST_EMBEDDING_1)
183
189
 
184
190
  def test_search(self):
185
191
  document_store = ChromaDocumentStore()
@@ -227,6 +233,20 @@ class TestDocumentStore(CountDocumentsTest, DeleteDocumentsTest, FilterDocuments
227
233
  assert written_docs[1].meta == {}
228
234
  assert written_docs[2].meta == {"ok": 123}
229
235
 
236
+ def test_documents_with_content_none_are_not_stored(self, document_store: ChromaDocumentStore):
237
+ document_store.write_documents([Document(content=None)])
238
+ assert document_store.filter_documents() == []
239
+
240
+ def test_dataframe_and_blob_are_not_stored(self, document_store: ChromaDocumentStore):
241
+ bs = ByteStream(data=b"test")
242
+ doc_mixed = Document(content="test", blob=bs)
243
+ doc_mixed.dataframe = "non null content" # just a placeholder
244
+
245
+ document_store.write_documents([doc_mixed])
246
+
247
+ expected_doc = Document(id=doc_mixed.id, content="test")
248
+ assert document_store.filter_documents() == [expected_doc]
249
+
230
250
  @pytest.mark.integration
231
251
  def test_to_dict(self, request):
232
252
  ds = ChromaDocumentStore(
@@ -406,18 +426,6 @@ class TestDocumentStore(CountDocumentsTest, DeleteDocumentsTest, FilterDocuments
406
426
  ],
407
427
  )
408
428
 
409
- @pytest.mark.skip(reason="Filter on dataframe contents is not supported.")
410
- def test_comparison_equal_with_dataframe(
411
- self, document_store: ChromaDocumentStore, filterable_docs: List[Document]
412
- ):
413
- pass
414
-
415
- @pytest.mark.skip(reason="Filter on dataframe contents is not supported.")
416
- def test_comparison_not_equal_with_dataframe(
417
- self, document_store: ChromaDocumentStore, filterable_docs: List[Document]
418
- ):
419
- pass
420
-
421
429
  @pytest.mark.skip(reason="Chroma does not support comparison with null values")
422
430
  def test_comparison_equal_with_none(self, document_store, filterable_docs):
423
431
  pass
File without changes