test_chroma.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import chromadb
  2. from core.rag.datasource.vdb.chroma.chroma_vector import ChromaConfig, ChromaVector
  3. from tests.integration_tests.vdb.test_vector_store import (
  4. AbstractVectorTest,
  5. get_example_text,
  6. setup_mock_redis,
  7. )
  8. class ChromaVectorTest(AbstractVectorTest):
  9. def __init__(self):
  10. super().__init__()
  11. self.vector = ChromaVector(
  12. collection_name=self.collection_name,
  13. config=ChromaConfig(
  14. host="localhost",
  15. port=8000,
  16. tenant=chromadb.DEFAULT_TENANT,
  17. database=chromadb.DEFAULT_DATABASE,
  18. auth_provider="chromadb.auth.token_authn.TokenAuthClientProvider",
  19. auth_credentials="difyai123456",
  20. ),
  21. )
  22. def search_by_full_text(self):
  23. # chroma dos not support full text searching
  24. hits_by_full_text = self.vector.search_by_full_text(query=get_example_text())
  25. assert len(hits_by_full_text) == 0
  26. def test_chroma_vector(setup_mock_redis):
  27. ChromaVectorTest().run_all_tests()