chroma-haystack 3.0.0__tar.gz → 3.2.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 (59) hide show
  1. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/CHANGELOG.md +31 -0
  2. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/PKG-INFO +4 -2
  3. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/pyproject.toml +24 -41
  4. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/src/haystack_integrations/components/retrievers/chroma/__init__.py +4 -0
  5. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/src/haystack_integrations/components/retrievers/chroma/retriever.py +113 -2
  6. chroma_haystack-3.2.0/src/haystack_integrations/document_stores/chroma/__init__.py +7 -0
  7. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/src/haystack_integrations/document_stores/chroma/document_store.py +318 -164
  8. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/src/haystack_integrations/document_stores/chroma/errors.py +2 -1
  9. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/src/haystack_integrations/document_stores/chroma/filters.py +7 -3
  10. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/src/haystack_integrations/document_stores/chroma/utils.py +2 -1
  11. chroma_haystack-3.2.0/tests/__init__.py +3 -0
  12. chroma_haystack-3.2.0/tests/conftest.py +102 -0
  13. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/tests/test_document_store.py +88 -176
  14. chroma_haystack-3.2.0/tests/test_document_store_async.py +122 -0
  15. chroma_haystack-3.2.0/tests/test_retriever.py +165 -0
  16. chroma_haystack-3.0.0/src/haystack_integrations/document_stores/chroma/__init__.py +0 -3
  17. chroma_haystack-3.0.0/tests/__init__.py +0 -3
  18. chroma_haystack-3.0.0/tests/test_retriever.py +0 -107
  19. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/.gitignore +0 -0
  20. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/LICENSE +0 -0
  21. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/README.md +0 -0
  22. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_01.txt +0 -0
  23. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_02.txt +0 -0
  24. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_03.txt +0 -0
  25. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_04.txt +0 -0
  26. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_05.txt +0 -0
  27. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_06.txt +0 -0
  28. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_07.txt +0 -0
  29. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_08.txt +0 -0
  30. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_09.txt +0 -0
  31. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_10.txt +0 -0
  32. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_11.txt +0 -0
  33. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_12.txt +0 -0
  34. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_20.txt +0 -0
  35. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_21.txt +0 -0
  36. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_22.txt +0 -0
  37. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_23.txt +0 -0
  38. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_24.txt +0 -0
  39. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_25.txt +0 -0
  40. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_26.txt +0 -0
  41. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_27.txt +0 -0
  42. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_28.txt +0 -0
  43. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_29.txt +0 -0
  44. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_30.txt +0 -0
  45. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_31.txt +0 -0
  46. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_32.txt +0 -0
  47. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_40.txt +0 -0
  48. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_41.txt +0 -0
  49. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_42.txt +0 -0
  50. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_43.txt +0 -0
  51. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_44.txt +0 -0
  52. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_45.txt +0 -0
  53. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_46.txt +0 -0
  54. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_50.txt +0 -0
  55. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_51.txt +0 -0
  56. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_52.txt +0 -0
  57. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/data/usr_90.txt +0 -0
  58. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/example/example.py +0 -0
  59. {chroma_haystack-3.0.0 → chroma_haystack-3.2.0}/pydoc/config.yml +0 -0
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/chroma-v3.1.0] - 2025-04-14
4
+
5
+ ### 🐛 Bug Fixes
6
+
7
+ - Update test and unpin chroma (#1618)
8
+ - Make chroma backwards compatible (#1619)
9
+
10
+
11
+ ## [integrations/chroma-v2.0.2] - 2025-04-04
12
+
13
+
14
+ ### ⚙️ CI
15
+
16
+ - Review testing workflows (#1541)
17
+
18
+ ### 🌀 Miscellaneous
19
+
20
+ - Fix: Pin chroma (#1608)
21
+
22
+ ## [integrations/chroma-v3.0.0] - 2025-03-11
23
+
24
+
25
+ ### 🧹 Chores
26
+
27
+ - Use Haystack logging across integrations (#1484)
28
+
29
+ ### 🌀 Miscellaneous
30
+
31
+ - Fix: Chroma - relax dataframe/blob test (#1404)
32
+ - Pin haystack and remove dataframe checks (#1501)
33
+
3
34
  ## [integrations/chroma-v2.0.1] - 2025-02-14
4
35
 
5
36
  ### 🌀 Miscellaneous
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chroma-haystack
3
- Version: 3.0.0
3
+ Version: 3.2.0
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
@@ -13,10 +13,12 @@ Classifier: Programming Language :: Python
13
13
  Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
16
18
  Classifier: Programming Language :: Python :: Implementation :: CPython
17
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
18
20
  Requires-Python: >=3.9
19
- Requires-Dist: chromadb>=0.6.0
21
+ Requires-Dist: chromadb>=1.0.0
20
22
  Requires-Dist: haystack-ai>=2.11.0
21
23
  Description-Content-Type: text/markdown
22
24
 
@@ -18,13 +18,12 @@ classifiers = [
18
18
  "Programming Language :: Python :: 3.9",
19
19
  "Programming Language :: Python :: 3.10",
20
20
  "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
21
23
  "Programming Language :: Python :: Implementation :: CPython",
22
24
  "Programming Language :: Python :: Implementation :: PyPy",
23
25
  ]
24
- dependencies = [
25
- "haystack-ai>=2.11.0",
26
- "chromadb>=0.6.0",
27
- ]
26
+ dependencies = ["haystack-ai>=2.11.0", "chromadb>=1.0.0"]
28
27
 
29
28
  [project.urls]
30
29
  Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/chroma#readme"
@@ -44,40 +43,30 @@ git_describe_command = 'git describe --tags --match="integrations/chroma-v[0-9]*
44
43
 
45
44
  [tool.hatch.envs.default]
46
45
  installer = "uv"
47
- dependencies = [
48
- "coverage[toml]>=6.5",
49
- "pytest",
50
- "pytest-rerunfailures",
51
- "haystack-pydoc-tools",
52
- "databind-core<4.5.0", # FIXME: the latest 4.5.0 causes loops in pip resolver
53
- ]
46
+ dependencies = ["haystack-pydoc-tools", "ruff"]
47
+
54
48
  [tool.hatch.envs.default.scripts]
55
- test = "pytest {args:tests}"
56
- test-cov = "coverage run -m pytest {args:tests}"
57
- test-cov-retry = "test-cov --reruns 3 --reruns-delay 30 -x"
58
- cov-report = ["- coverage combine", "coverage report"]
59
- cov = ["test-cov", "cov-report"]
60
- cov-retry = ["test-cov-retry", "cov-report"]
61
49
  docs = ["pydoc-markdown pydoc/config.yml"]
50
+ fmt = "ruff check --fix {args} && ruff format {args}"
51
+ fmt-check = "ruff check {args} && ruff format --check {args}"
62
52
 
63
- [[tool.hatch.envs.all.matrix]]
64
- python = ["3.9", "3.10"]
65
-
66
- [tool.hatch.envs.lint]
67
- installer = "uv"
68
- detached = true
53
+ [tool.hatch.envs.test]
69
54
  dependencies = [
70
- "pip",
71
- "black>=23.1.0",
72
- "mypy>=1.0.0",
73
- "ruff>=0.0.243",
74
- "numpy", # we need the stubs from the main package
55
+ "pytest",
56
+ "pytest-asyncio",
57
+ "pytest-cov",
58
+ "pytest-rerunfailures",
59
+ "mypy",
60
+ "pip"
75
61
  ]
76
- [tool.hatch.envs.lint.scripts]
77
- typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
78
- style = ["ruff check {args:.}", "black --check --diff {args:.}"]
79
- fmt = ["black {args:.}", "ruff check --fix {args:.}", "style"]
80
- all = ["style", "typing"]
62
+
63
+ [tool.hatch.envs.test.scripts]
64
+ unit = 'pytest -m "not integration" {args:tests}'
65
+ integration = 'pytest -m "integration" {args:tests}'
66
+ all = 'pytest {args:tests}'
67
+ cov-retry = 'all --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x'
68
+
69
+ types = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
81
70
 
82
71
  [tool.hatch.metadata]
83
72
  allow-direct-references = true
@@ -170,14 +159,8 @@ exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
170
159
 
171
160
  [tool.pytest.ini_options]
172
161
  minversion = "6.0"
173
- markers = ["unit: unit tests", "integration: integration tests"]
162
+ markers = ["integration: integration tests"]
174
163
 
175
164
  [[tool.mypy.overrides]]
176
- module = [
177
- "chromadb.*",
178
- "haystack.*",
179
- "haystack_integrations.*",
180
- "pytest.*",
181
- "numpy.*",
182
- ]
165
+ module = ["haystack_integrations.*"]
183
166
  ignore_missing_imports = true
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
1
5
  from .retriever import ChromaEmbeddingRetriever, ChromaQueryTextRetriever
2
6
 
3
7
  __all__ = ["ChromaEmbeddingRetriever", "ChromaQueryTextRetriever"]
@@ -1,6 +1,7 @@
1
- # SPDX-FileCopyrightText: 2023-present John Doe <jd@example.com>
1
+ # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
2
  #
3
3
  # SPDX-License-Identifier: Apache-2.0
4
+
4
5
  from typing import Any, Dict, List, Optional, Union
5
6
 
6
7
  from haystack import Document, component, default_from_dict, default_to_dict
@@ -89,6 +90,33 @@ class ChromaQueryTextRetriever:
89
90
  top_k = top_k or self.top_k
90
91
  return {"documents": self.document_store.search([query], top_k, filters)[0]}
91
92
 
93
+ @component.output_types(documents=List[Document])
94
+ async def run_async(
95
+ self,
96
+ query: str,
97
+ filters: Optional[Dict[str, Any]] = None,
98
+ top_k: Optional[int] = None,
99
+ ):
100
+ """
101
+ Asynchronously run the retriever on the given input data.
102
+
103
+ Asynchronous methods are only supported for HTTP connections.
104
+
105
+ :param query: The input data for the retriever. In this case, a plain-text query.
106
+ :param filters: Filters applied to the retrieved Documents. The way runtime filters are applied depends on
107
+ the `filter_policy` chosen at retriever initialization. See init method docstring for more
108
+ details.
109
+ :param top_k: The maximum number of documents to retrieve.
110
+ If not specified, the default value from the constructor is used.
111
+ :returns: A dictionary with the following keys:
112
+ - `documents`: List of documents returned by the search engine.
113
+
114
+ :raises ValueError: If the specified document store is not found or is not a MemoryDocumentStore instance.
115
+ """
116
+ filters = apply_filter_policy(self.filter_policy, self.filters, filters)
117
+ top_k = top_k or self.top_k
118
+ return {"documents": await self.document_store.search_async([query], top_k, filters)[0]}
119
+
92
120
  @classmethod
93
121
  def from_dict(cls, data: Dict[str, Any]) -> "ChromaQueryTextRetriever":
94
122
  """
@@ -125,11 +153,31 @@ class ChromaQueryTextRetriever:
125
153
 
126
154
 
127
155
  @component
128
- class ChromaEmbeddingRetriever(ChromaQueryTextRetriever):
156
+ class ChromaEmbeddingRetriever:
129
157
  """
130
158
  A component for retrieving documents from a [Chroma database](https://docs.trychroma.com/) using embeddings.
131
159
  """
132
160
 
161
+ def __init__(
162
+ self,
163
+ document_store: ChromaDocumentStore,
164
+ filters: Optional[Dict[str, Any]] = None,
165
+ top_k: int = 10,
166
+ filter_policy: Union[str, FilterPolicy] = FilterPolicy.REPLACE,
167
+ ):
168
+ """
169
+ :param document_store: an instance of `ChromaDocumentStore`.
170
+ :param filters: filters to narrow down the search space.
171
+ :param top_k: the maximum number of documents to retrieve.
172
+ :param filter_policy: Policy to determine how filters are applied.
173
+ """
174
+ self.filters = filters or {}
175
+ self.top_k = top_k
176
+ self.document_store = document_store
177
+ self.filter_policy = (
178
+ filter_policy if isinstance(filter_policy, FilterPolicy) else FilterPolicy.from_str(filter_policy)
179
+ )
180
+
133
181
  @component.output_types(documents=List[Document])
134
182
  def run(
135
183
  self,
@@ -156,3 +204,66 @@ class ChromaEmbeddingRetriever(ChromaQueryTextRetriever):
156
204
 
157
205
  query_embeddings = [query_embedding]
158
206
  return {"documents": self.document_store.search_embeddings(query_embeddings, top_k, filters)[0]}
207
+
208
+ @component.output_types(documents=List[Document])
209
+ async def run_async(
210
+ self,
211
+ query_embedding: List[float],
212
+ filters: Optional[Dict[str, Any]] = None,
213
+ top_k: Optional[int] = None,
214
+ ):
215
+ """
216
+ Asynchronously run the retriever on the given input data.
217
+
218
+ Asynchronous methods are only supported for HTTP connections.
219
+
220
+ :param query_embedding: the query embeddings.
221
+ :param filters: Filters applied to the retrieved Documents. The way runtime filters are applied depends on
222
+ the `filter_policy` chosen at retriever initialization. See init method docstring for more
223
+ details.
224
+ :param top_k: the maximum number of documents to retrieve.
225
+ If not specified, the default value from the constructor is used.
226
+
227
+ :returns: a dictionary with the following keys:
228
+ - `documents`: List of documents returned by the search engine.
229
+ """
230
+ filters = apply_filter_policy(self.filter_policy, self.filters, filters)
231
+
232
+ top_k = top_k or self.top_k
233
+
234
+ query_embeddings = [query_embedding]
235
+ return {"documents": await self.document_store.search_embeddings_async(query_embeddings, top_k, filters)[0]}
236
+
237
+ @classmethod
238
+ def from_dict(cls, data: Dict[str, Any]) -> "ChromaEmbeddingRetriever":
239
+ """
240
+ Deserializes the component from a dictionary.
241
+
242
+ :param data:
243
+ Dictionary to deserialize from.
244
+ :returns:
245
+ Deserialized component.
246
+ """
247
+ document_store = ChromaDocumentStore.from_dict(data["init_parameters"]["document_store"])
248
+ data["init_parameters"]["document_store"] = document_store
249
+ # Pipelines serialized with old versions of the component might not
250
+ # have the filter_policy field.
251
+ if filter_policy := data["init_parameters"].get("filter_policy"):
252
+ data["init_parameters"]["filter_policy"] = FilterPolicy.from_str(filter_policy)
253
+
254
+ return default_from_dict(cls, data)
255
+
256
+ def to_dict(self) -> Dict[str, Any]:
257
+ """
258
+ Serializes the component to a dictionary.
259
+
260
+ :returns:
261
+ Dictionary with serialized data.
262
+ """
263
+ return default_to_dict(
264
+ self,
265
+ filters=self.filters,
266
+ top_k=self.top_k,
267
+ filter_policy=self.filter_policy.value,
268
+ document_store=self.document_store.to_dict(),
269
+ )
@@ -0,0 +1,7 @@
1
+ # SPDX-FileCopyrightText: 2023-present deepset GmbH <info@deepset.ai>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ from .document_store import ChromaDocumentStore
6
+
7
+ __all__ = ["ChromaDocumentStore"]