veerukhannan commited on
Commit
4ed9501
·
verified ·
1 Parent(s): e55cfd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -18,11 +18,17 @@ class SentenceTransformerEmbeddings:
18
  class LegalAssistant:
19
  def __init__(self):
20
  try:
21
- # Verify ChromaDB content first
 
 
 
 
22
  if not test_chromadb_content():
23
- raise ValueError("ChromaDB content verification failed")
 
 
24
 
25
- # Initialize ChromaDB
26
  base_path = os.path.dirname(os.path.abspath(__file__))
27
  chroma_path = os.path.join(base_path, 'chroma_db')
28
 
@@ -35,6 +41,8 @@ class LegalAssistant:
35
  embedding_function=self.embedding_function
36
  )
37
 
 
 
38
  # Initialize Mistral AI client
39
  self.mistral_client = OpenAI(
40
  api_key=os.environ.get("MISTRAL_API_KEY", "dfb2j1YDsa298GXTgZo3juSjZLGUCfwi"),
 
18
  class LegalAssistant:
19
  def __init__(self):
20
  try:
21
+ # Initialize and verify ChromaDB content
22
+ logger.info("Initializing LegalAssistant...")
23
+ from test_embeddings import test_chromadb_content, initialize_chromadb
24
+
25
+ # Try to verify content, if fails, try to initialize
26
  if not test_chromadb_content():
27
+ logger.warning("ChromaDB verification failed, attempting to initialize...")
28
+ if not initialize_chromadb():
29
+ raise ValueError("Failed to initialize ChromaDB")
30
 
31
+ # Initialize ChromaDB client
32
  base_path = os.path.dirname(os.path.abspath(__file__))
33
  chroma_path = os.path.join(base_path, 'chroma_db')
34
 
 
41
  embedding_function=self.embedding_function
42
  )
43
 
44
+ logger.info(f"Collection loaded with {self.collection.count()} documents")
45
+
46
  # Initialize Mistral AI client
47
  self.mistral_client = OpenAI(
48
  api_key=os.environ.get("MISTRAL_API_KEY", "dfb2j1YDsa298GXTgZo3juSjZLGUCfwi"),