fix: you can only delete something that might exist

Signed-off-by: Matt Williams <m@technovangelist.com>
This commit is contained in:
Matt Williams 2024-04-12 09:55:30 -07:00
parent e42f53623a
commit b2a2cfcb40

View file

@ -2,9 +2,13 @@ import ollama, chromadb, time
from utilities import readtext, getconfig
from mattsollamatools import chunker, chunk_text_by_sentences
collectionname="buildragwithpython"
chroma = chromadb.HttpClient(host="localhost", port=8000)
chroma.delete_collection("buildragwithpython")
print(chroma.list_collections())
if any(collection.name == collectionname for collection in chroma.list_collections()):
print('deleting collection')
chroma.delete_collection("buildragwithpython")
collection = chroma.get_or_create_collection(name="buildragwithpython", metadata={"hnsw:space": "cosine"})
embedmodel = getconfig()["embedmodel"]