chroma-haystack 5.1.1__tar.gz → 5.1.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 (59) hide show
  1. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/CHANGELOG.md +7 -0
  2. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/PKG-INFO +1 -1
  3. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/document_stores/chroma/document_store.py +23 -13
  4. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/tests/test_document_store.py +23 -0
  5. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/.gitignore +0 -0
  6. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/LICENSE.txt +0 -0
  7. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/README.md +0 -0
  8. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_01.txt +0 -0
  9. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_02.txt +0 -0
  10. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_03.txt +0 -0
  11. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_04.txt +0 -0
  12. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_05.txt +0 -0
  13. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_06.txt +0 -0
  14. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_07.txt +0 -0
  15. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_08.txt +0 -0
  16. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_09.txt +0 -0
  17. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_10.txt +0 -0
  18. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_11.txt +0 -0
  19. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_12.txt +0 -0
  20. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_20.txt +0 -0
  21. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_21.txt +0 -0
  22. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_22.txt +0 -0
  23. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_23.txt +0 -0
  24. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_24.txt +0 -0
  25. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_25.txt +0 -0
  26. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_26.txt +0 -0
  27. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_27.txt +0 -0
  28. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_28.txt +0 -0
  29. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_29.txt +0 -0
  30. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_30.txt +0 -0
  31. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_31.txt +0 -0
  32. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_32.txt +0 -0
  33. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_40.txt +0 -0
  34. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_41.txt +0 -0
  35. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_42.txt +0 -0
  36. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_43.txt +0 -0
  37. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_44.txt +0 -0
  38. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_45.txt +0 -0
  39. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_46.txt +0 -0
  40. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_50.txt +0 -0
  41. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_51.txt +0 -0
  42. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_52.txt +0 -0
  43. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/data/usr_90.txt +0 -0
  44. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/example/example.py +0 -0
  45. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/pydoc/config_docusaurus.yml +0 -0
  46. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/pyproject.toml +0 -0
  47. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/components/retrievers/chroma/__init__.py +0 -0
  48. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/components/retrievers/chroma/retriever.py +0 -0
  49. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/components/retrievers/py.typed +0 -0
  50. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/document_stores/chroma/__init__.py +0 -0
  51. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/document_stores/chroma/errors.py +0 -0
  52. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/document_stores/chroma/filters.py +0 -0
  53. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/document_stores/chroma/utils.py +0 -0
  54. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/src/haystack_integrations/document_stores/py.typed +0 -0
  55. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/tests/__init__.py +0 -0
  56. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/tests/conftest.py +0 -0
  57. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/tests/test_document_store_async.py +0 -0
  58. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/tests/test_filters.py +0 -0
  59. {chroma_haystack-5.1.1 → chroma_haystack-5.1.2}/tests/test_retriever.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [integrations/chroma-v5.1.1] - 2026-11-19
4
+
5
+ ### 🐛 Bug Fixes
6
+
7
+ - Chroma - handle IDs repeated within a write_documents batch (#4241)
8
+
9
+
3
10
  ## [integrations/chroma-v5.1.0] - 2026-11-11
4
11
 
5
12
  ### 🐛 Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: chroma-haystack
3
- Version: 5.1.1
3
+ Version: 5.1.2
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
@@ -478,18 +478,37 @@ class ChromaDocumentStore:
478
478
  return self._get_result_to_documents(result)
479
479
 
480
480
  @staticmethod
481
- def _filter_metadata(meta: dict[str, Any]) -> dict[str, str | int | float | bool | None]:
481
+ def _is_supported_metadata_value(value: Any) -> bool:
482
+ """
483
+ Checks whether Chroma can store a metadata value.
484
+
485
+ Chroma stores `str`, `int`, `float` and `bool` values, and non-empty lists whose items all share one of those
486
+ types.
487
+ """
488
+ if isinstance(value, SUPPORTED_TYPES_FOR_METADATA_VALUES):
489
+ return True
490
+ return (
491
+ isinstance(value, list)
492
+ and len(value) > 0
493
+ and type(value[0]) in SUPPORTED_TYPES_FOR_METADATA_VALUES
494
+ and all(isinstance(item, type(value[0])) for item in value)
495
+ )
496
+
497
+ @staticmethod
498
+ def _filter_metadata(
499
+ meta: dict[str, Any],
500
+ ) -> dict[str, SUPPORTED_METADATA_VALUES_TYPE | list[SUPPORTED_METADATA_VALUES_TYPE] | None]:
482
501
  """
483
502
  Filters metadata to only include supported types for Chroma.
484
503
 
485
504
  returns:
486
505
  A new dictionary with only valid metadata values.
487
506
  """
488
- valid_meta: dict[str, str | int | float | bool | None] = {}
507
+ valid_meta: dict[str, SUPPORTED_METADATA_VALUES_TYPE | list[SUPPORTED_METADATA_VALUES_TYPE] | None] = {}
489
508
  discarded_keys = []
490
509
 
491
510
  for k, v in meta.items():
492
- if v is None or isinstance(v, SUPPORTED_TYPES_FOR_METADATA_VALUES):
511
+ if v is None or ChromaDocumentStore._is_supported_metadata_value(v):
493
512
  valid_meta[k] = v
494
513
  else:
495
514
  discarded_keys.append(k)
@@ -557,16 +576,7 @@ class ChromaDocumentStore:
557
576
  discarded_keys = []
558
577
 
559
578
  for k, v in doc.meta.items():
560
- if isinstance(v, SUPPORTED_TYPES_FOR_METADATA_VALUES):
561
- valid_meta[k] = v
562
- # For list metadata values, list must not be empty, must be of all same type
563
- # and be one of `SUPPORTED_TYPES_FOR_METADATA_VALUES`
564
- elif (
565
- isinstance(v, list)
566
- and len(v) > 0
567
- and (first_type := type(v[0])) in SUPPORTED_TYPES_FOR_METADATA_VALUES
568
- and all(isinstance(item, first_type) for item in v)
569
- ):
579
+ if ChromaDocumentStore._is_supported_metadata_value(v):
570
580
  valid_meta[k] = v
571
581
  else:
572
582
  discarded_keys.append(k)
@@ -239,6 +239,11 @@ class TestDocumentStoreUnit:
239
239
  assert result == {"ok": "x", "also_ok": None}
240
240
  assert "bad" in caplog.text and "worse" in caplog.text
241
241
 
242
+ def test_filter_metadata_keeps_list_values(self):
243
+ meta = {"tags": ["a", "b"], "pages": [1, 2], "mixed": ["a", 1], "empty": []}
244
+ result = ChromaDocumentStore._filter_metadata(meta)
245
+ assert result == {"tags": ["a", "b"], "pages": [1, 2]}
246
+
242
247
  def test_convert_document_to_chroma_rejects_non_document(self):
243
248
  with pytest.raises(ValueError, match="must contain a list of objects of type Document"):
244
249
  ChromaDocumentStore._convert_document_to_chroma("not a document") # type: ignore[arg-type]
@@ -337,6 +342,24 @@ class TestDocumentStore(
337
342
 
338
343
  assert [document.id for document in document_store.filter_documents(filters=filters)] == expected_ids
339
344
 
345
+ def test_update_by_filter_with_list_metadata(self, document_store: ChromaDocumentStore):
346
+ document_store.write_documents(
347
+ [
348
+ Document(id="1", content="first", meta={"lang": "en", "tags": ["draft"]}),
349
+ Document(id="2", content="second", meta={"lang": "de", "tags": ["draft"]}),
350
+ ]
351
+ )
352
+
353
+ updated = document_store.update_by_filter(
354
+ filters={"field": "meta.lang", "operator": "==", "value": "en"},
355
+ meta={"tags": ["draft", "reviewed"]},
356
+ )
357
+
358
+ assert updated == 1
359
+ documents = {document.id: document for document in document_store.filter_documents()}
360
+ assert documents["1"].meta["tags"] == ["draft", "reviewed"]
361
+ assert documents["2"].meta["tags"] == ["draft"]
362
+
340
363
  def test_delete_by_filter_metadata_id(self, document_store: ChromaDocumentStore):
341
364
  document_store.write_documents(
342
365
  [