-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added docker image hnswlib rebuild + sqlite3 for debugging
- Added a small test to ensure chroma is up and running. - Docker image rebuilt.
- Loading branch information
Showing
3 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |