Skip to content

Commit

Permalink
fix: Added docker image hnswlib rebuild + sqlite3 for debugging
Browse files Browse the repository at this point in the history
- Added a small test to ensure chroma is up and running.
- Docker image rebuilt.
  • Loading branch information
tazarov committed Jul 29, 2023
1 parent cd09329 commit 5baff1e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
5 changes: 4 additions & 1 deletion image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM ghcr.io/chroma-core/chroma:0.4.3

COPY ./image/docker_entrypoint.sh /docker_entrypoint.sh
RUN find /chroma -mindepth 1 -maxdepth 1 ! \( -name 'chromadb' -o -name 'LICENSE' -o -name 'requirements.txt' \) -exec rm -rf {} \; && \
groupadd chroma && \
useradd -g chroma chroma && \
chown -R chroma:chroma /chroma
chown -R chroma:chroma /chroma && \
pip install --force-reinstall --no-cache-dir chroma-hnswlib && \
apt-get update -qq && apt-get install sqlite3
EXPOSE 8000
USER chroma
WORKDIR /chroma
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
chromadb-client==0.4.3.dev0
pytest==7.4.0
pytest==7.4.0
openai
python-dotenv
sentence_transformers
32 changes: 29 additions & 3 deletions tests/test_chroma.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
import os
import uuid

import chromadb
from chromadb import Settings
from chromadb.utils import embedding_functions
from dotenv import load_dotenv

load_dotenv()


def get_embedding_function():
"""
Get the embedding function
:return: Embedding function
"""

openai_ef = embedding_functions.OpenAIEmbeddingFunction(
model_name="text-embedding-ada-002",
api_key=os.environ.get('OPENAI_API_KEY')
)
return openai_ef


sentence_transformer_ef = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="all-MiniLM-L6-v2")


def test_chroma():
client = chromadb.HttpClient(host="localhost", port=8000)
client.heartbeat()
client.reset()
# collection = client.create_collection("all1-my-documents")
collection = client.get_or_create_collection("all1-my-documents",
embedding_function=sentence_transformer_ef)
collection.add(documents=["this is a test embedding"], metadatas=[{"type": "page"}], ids=[str(uuid.uuid4())])
assert len(collection.get()['ids']) == 1


if __name__ == '__main__':
test_chroma()
test_chroma()

0 comments on commit 5baff1e

Please sign in to comment.