Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,14 +84,22 @@ def init_astra_db():
|
|
| 84 |
|
| 85 |
# Initialize the client
|
| 86 |
db = DataAPIClient(api_endpoint=astra_db_endpoint, token=astra_db_application_token)
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
# Return DB client and collections for use in application
|
| 96 |
return {
|
| 97 |
"db": db,
|
|
|
|
| 84 |
|
| 85 |
# Initialize the client
|
| 86 |
db = DataAPIClient(api_endpoint=astra_db_endpoint, token=astra_db_application_token)
|
| 87 |
+
|
| 88 |
+
try:
|
| 89 |
+
product_embeddings = db.collection("product_embeddings")
|
| 90 |
+
query_analytics = db.collection("query_analytics")
|
| 91 |
+
product_images = db.collection("product_images")
|
| 92 |
+
except Exception as collection_error:
|
| 93 |
+
print(f"Error creating collections: {collection_error}")
|
| 94 |
+
|
| 95 |
+
print(f"Connected to Astra DB")
|
| 96 |
+
|
| 97 |
+
try:
|
| 98 |
+
collections = db.list_collections()
|
| 99 |
+
print(f"Available collections: {collections}")
|
| 100 |
+
except AttributeError:
|
| 101 |
+
print("Unable to list collections (method not available)")
|
| 102 |
+
|
| 103 |
# Return DB client and collections for use in application
|
| 104 |
return {
|
| 105 |
"db": db,
|