Skip to content

Commit

Permalink
chore: use in-memory db by default
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfzc committed Nov 23, 2023
1 parent 3a093cf commit c91688f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from srctag.tagger import Tagger

storage = Storage()
storage.config.db_path = "./chroma"
tagger = Tagger()
tagger.config.tags = ["storage"]
tag_dict = tagger.tag(storage)
Expand Down
1 change: 1 addition & 0 deletions examples/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

ctx = collector.collect_metadata()
storage = Storage()
storage.config.db_path = "./chroma"
storage.embed_ctx(ctx)
9 changes: 7 additions & 2 deletions srctag/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class StorageConfig(BaseSettings):
db_path: str = "./chroma"
db_path: str = ""
collection_name: str = "default_collection"

# English: paraphrase-MiniLM-L6-v2
Expand All @@ -33,7 +33,12 @@ def __init__(self, config: StorageConfig = None):
def init_chroma(self):
if self.chromadb and self.chromadb_collection:
return
self.chromadb = chromadb.PersistentClient(path=self.config.db_path)

if self.config.db_path:
self.chromadb = chromadb.PersistentClient(path=self.config.db_path)
else:
self.chromadb = chromadb.Client()

self.chromadb_collection = self.chromadb.get_or_create_collection(
self.config.collection_name,
embedding_function=SentenceTransformerEmbeddingFunction(
Expand Down

0 comments on commit c91688f

Please sign in to comment.