Ayushnangia commited on
Commit
331a2e2
·
1 Parent(s): e044332
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -267,7 +267,6 @@ from langchain_core.runnables import RunnablePassthrough
267
  import chromadb
268
  chromadb.api.client.SharedSystemClient.clear_system_cache()
269
  os.environ['MISTRAL_API_KEY'] = 'XuyOObDE7trMbpAeI7OXYr3dnmoWy3L0'
270
-
271
  class VectorData():
272
  def __init__(self):
273
  embedding_model_name = 'l3cube-pune/punjabi-sentence-similarity-sbert'
@@ -278,32 +277,26 @@ class VectorData():
278
  model_kwargs=model_kwargs
279
  )
280
 
281
- # Initialize ChromaDB client with proper settings
282
- client_settings = chromadb.Settings(
283
- chroma_db_impl="duckdb+parquet",
284
- persist_directory="chroma_db",
285
- anonymized_telemetry=False
286
- )
287
 
288
- # Create ChromaDB client
289
- self.client = chromadb.Client(client_settings)
290
-
291
- # Create or get collection
292
- self.collection = self.client.create_collection(
293
  name="my_collection",
294
- get_or_create=True
295
  )
296
 
297
- # Initialize vectorstore with the client
298
  self.vectorstore = Chroma(
299
  client=self.client,
300
  collection_name="my_collection",
301
- embedding_function=self.embeddings,
302
- persist_directory="chroma_db"
303
  )
 
304
  self.retriever = self.vectorstore.as_retriever()
305
  self.ingested_files = []
306
 
 
307
  self.prompt = ChatPromptTemplate.from_messages(
308
  [
309
  (
 
267
  import chromadb
268
  chromadb.api.client.SharedSystemClient.clear_system_cache()
269
  os.environ['MISTRAL_API_KEY'] = 'XuyOObDE7trMbpAeI7OXYr3dnmoWy3L0'
 
270
  class VectorData():
271
  def __init__(self):
272
  embedding_model_name = 'l3cube-pune/punjabi-sentence-similarity-sbert'
 
277
  model_kwargs=model_kwargs
278
  )
279
 
280
+ # Initialize ChromaDB with new configuration
281
+ self.client = chromadb.PersistentClient(path="chroma_db")
 
 
 
 
282
 
283
+ # Create or get collection with embeddings
284
+ self.collection = self.client.get_or_create_collection(
 
 
 
285
  name="my_collection",
286
+ metadata={"hnsw:space": "cosine"}
287
  )
288
 
289
+ # Initialize vectorstore
290
  self.vectorstore = Chroma(
291
  client=self.client,
292
  collection_name="my_collection",
293
+ embedding_function=self.embeddings
 
294
  )
295
+
296
  self.retriever = self.vectorstore.as_retriever()
297
  self.ingested_files = []
298
 
299
+ # Rest of your initialization code remains the same
300
  self.prompt = ChatPromptTemplate.from_messages(
301
  [
302
  (