Mr-Geo commited on
Commit
162eca4
·
verified ·
1 Parent(s): 71eb119

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -31,16 +31,16 @@ def load_chroma_db():
31
  )
32
  print(f"Downloaded database zip to: {zip_path}")
33
 
34
- # Extract to a temporary directory
35
- extract_dir = "/tmp/chroma_db"
36
  with zipfile.ZipFile(zip_path, 'r') as zip_ref:
37
  zip_ref.extractall(extract_dir)
38
 
39
  print(f"Extracted database to: {extract_dir}")
40
 
41
- # Initialize ChromaDB with the extracted database
42
  db = chromadb.PersistentClient(
43
- path=os.path.join(extract_dir, "chroma_db"), # Add chroma_db to the path
44
  settings=Settings(
45
  anonymized_telemetry=False,
46
  allow_reset=True,
@@ -48,8 +48,12 @@ def load_chroma_db():
48
  )
49
  )
50
 
51
- # Debug: Print collections
52
- print("Available collections:", db.list_collections())
 
 
 
 
53
 
54
  return db
55
 
 
31
  )
32
  print(f"Downloaded database zip to: {zip_path}")
33
 
34
+ # Extract to a temporary directory that matches local structure
35
+ extract_dir = "/tmp" # Changed to /tmp so we can create /tmp/chroma_db
36
  with zipfile.ZipFile(zip_path, 'r') as zip_ref:
37
  zip_ref.extractall(extract_dir)
38
 
39
  print(f"Extracted database to: {extract_dir}")
40
 
41
+ # Initialize ChromaDB with the extracted database - matching local path structure
42
  db = chromadb.PersistentClient(
43
+ path="/tmp/chroma_db", # Exactly matching the local ./chroma_db structure
44
  settings=Settings(
45
  anonymized_telemetry=False,
46
  allow_reset=True,
 
48
  )
49
  )
50
 
51
+ # Debug: Print collections and document count
52
+ collections = db.list_collections()
53
+ print("Available collections:", collections)
54
+ if collections:
55
+ collection = db.get_collection(name="website_content")
56
+ print(f"Found {collection.count()} documents in collection")
57
 
58
  return db
59