Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,27 @@ device = Config.get_device()
|
|
| 16 |
model = SentenceTransformer(config.MODEL_PATH)
|
| 17 |
collection = None
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
class EmbeddingGemmaPrompts:
|
| 21 |
"""
|
|
|
|
| 16 |
model = SentenceTransformer(config.MODEL_PATH)
|
| 17 |
collection = None
|
| 18 |
|
| 19 |
+
print(f"🔄 Connecting to ChromaDB from cloud...")
|
| 20 |
+
client = chromadb.CloudClient(
|
| 21 |
+
api_key=os.environ.get("chromadb_api_key",""),
|
| 22 |
+
tenant=os.environ.get("chromadb_tenant",""),
|
| 23 |
+
database=os.environ.get("chromadb_db","")
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# === COLLECTION VALIDATION ===
|
| 27 |
+
# Ensure the required collection exists and has data
|
| 28 |
+
try:
|
| 29 |
+
collection = client.get_collection(config.COLLECTION_NAME)
|
| 30 |
+
doc_count = collection.count()
|
| 31 |
+
|
| 32 |
+
if doc_count == 0:
|
| 33 |
+
return False, f"Collection '{config.COLLECTION_NAME}' exists but is empty. Run ingest_studies.py to populate it."
|
| 34 |
+
|
| 35 |
+
print(f"✅ Connected to collection '{config.COLLECTION_NAME}' with {doc_count} documents")
|
| 36 |
+
|
| 37 |
+
except Exception as e:
|
| 38 |
+
return False, f"Collection '{config.COLLECTION_NAME}' not found. Run ingest_studies.py first. Error: {str(e)}"
|
| 39 |
+
|
| 40 |
|
| 41 |
class EmbeddingGemmaPrompts:
|
| 42 |
"""
|