Update app.py
Browse files
app.py
CHANGED
@@ -39,19 +39,33 @@ class CustomEmbeddingFunction:
|
|
39 |
|
40 |
|
41 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
))
|
48 |
embedding_fn = CustomEmbeddingFunction()
|
49 |
collection_name = "crm_data"
|
50 |
|
|
|
51 |
try:
|
|
|
52 |
collection = chroma_client.get_collection(collection_name)
|
53 |
except Exception:
|
54 |
collection = chroma_client.create_collection(collection_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
def get_google_sheets_service():
|
57 |
creds = Credentials.from_service_account_file(
|
|
|
39 |
|
40 |
|
41 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
42 |
+
chroma_client = Client(Settings(persist_directory="/home/user/app/chromadb_storage"))
|
43 |
+
|
44 |
+
# Reset ChromaDB (this will clear existing data)
|
45 |
+
chroma_client.reset()
|
46 |
+
|
|
|
47 |
embedding_fn = CustomEmbeddingFunction()
|
48 |
collection_name = "crm_data"
|
49 |
|
50 |
+
# Ensure database is available
|
51 |
try:
|
52 |
+
chroma_client.heartbeat() # Check if ChromaDB is alive
|
53 |
collection = chroma_client.get_collection(collection_name)
|
54 |
except Exception:
|
55 |
collection = chroma_client.create_collection(collection_name)
|
56 |
+
# chroma_client = Client(Settings(persist_directory="chromadb_storage"))
|
57 |
+
# chroma_client = Client(Settings(
|
58 |
+
# persist_directory="/home/user/app/chromadb_storage",
|
59 |
+
# tenant="default_tenant",
|
60 |
+
# database="default_db"
|
61 |
+
# ))
|
62 |
+
# embedding_fn = CustomEmbeddingFunction()
|
63 |
+
# collection_name = "crm_data"
|
64 |
+
|
65 |
+
# try:
|
66 |
+
# collection = chroma_client.get_collection(collection_name)
|
67 |
+
# except Exception:
|
68 |
+
# collection = chroma_client.create_collection(collection_name)
|
69 |
|
70 |
def get_google_sheets_service():
|
71 |
creds = Credentials.from_service_account_file(
|