Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -170,22 +170,23 @@ def fetch_trustbuilders(user_id, keyword=None, brand=None, bucket=None):
|
|
| 170 |
try:
|
| 171 |
st.write(f"Fetching TrustBuilders with keyword='{keyword}', brand='{brand}', bucket='{bucket}'")
|
| 172 |
trustbuilders = db.child("users").child(user_id).child("TrustBuilder").get().val()
|
| 173 |
-
st.write("TrustBuilders retrieved from
|
|
|
|
| 174 |
if not trustbuilders:
|
| 175 |
-
st.write("No TrustBuilders found in
|
| 176 |
return {}
|
| 177 |
|
| 178 |
filtered_trustbuilders = {}
|
| 179 |
-
for
|
| 180 |
-
message =
|
| 181 |
-
brand_field =
|
| 182 |
-
bucket_field =
|
| 183 |
-
|
|
|
|
| 184 |
st.write(f" Message: {message}")
|
| 185 |
st.write(f" Brand: {brand_field}")
|
| 186 |
st.write(f" Bucket: {bucket_field}")
|
| 187 |
|
| 188 |
-
# Apply filters
|
| 189 |
if keyword and keyword.lower() not in message:
|
| 190 |
st.write(" Keyword does not match.")
|
| 191 |
continue
|
|
@@ -195,8 +196,10 @@ def fetch_trustbuilders(user_id, keyword=None, brand=None, bucket=None):
|
|
| 195 |
if bucket and bucket != "All" and bucket != bucket_field:
|
| 196 |
st.write(f" Bucket '{bucket_field}' does not match selected '{bucket}'.")
|
| 197 |
continue
|
|
|
|
| 198 |
st.write(" TrustBuilder matches filters.")
|
| 199 |
-
filtered_trustbuilders[
|
|
|
|
| 200 |
st.write("Filtered TrustBuilders:", filtered_trustbuilders)
|
| 201 |
return filtered_trustbuilders
|
| 202 |
except Exception as e:
|
|
@@ -563,21 +566,21 @@ def load_user_content(user_id):
|
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
-
|
| 567 |
def save_content(user_id, brand, trust_builder_text, trust_bucket=None):
|
| 568 |
try:
|
| 569 |
trustbuilder_id = str(uuid.uuid4())
|
| 570 |
data = {
|
| 571 |
-
"brand": brand,
|
| 572 |
-
"message": trust_builder_text,
|
| 573 |
-
"bucket": trust_bucket
|
| 574 |
}
|
| 575 |
-
# Output the data being saved
|
| 576 |
st.write("Saving TrustBuilder with data:", data)
|
| 577 |
db.child("users").child(user_id).child("TrustBuilder").child(trustbuilder_id).set(data)
|
| 578 |
st.success(f"TrustBuilder saved to {trust_bucket} bucket.")
|
| 579 |
except Exception as e:
|
| 580 |
st.error(f"Error saving TrustBuilder: {e}")
|
|
|
|
|
|
|
| 581 |
def ai_allocate_trust_bucket(trust_builder_text):
|
| 582 |
# Implement your AI allocation logic here
|
| 583 |
return "Stability"
|
|
|
|
| 170 |
try:
|
| 171 |
st.write(f"Fetching TrustBuilders with keyword='{keyword}', brand='{brand}', bucket='{bucket}'")
|
| 172 |
trustbuilders = db.child("users").child(user_id).child("TrustBuilder").get().val()
|
| 173 |
+
st.write("TrustBuilders retrieved from Firebase:", trustbuilders)
|
| 174 |
+
|
| 175 |
if not trustbuilders:
|
| 176 |
+
st.write("No TrustBuilders found in Firebase.")
|
| 177 |
return {}
|
| 178 |
|
| 179 |
filtered_trustbuilders = {}
|
| 180 |
+
for key, value in trustbuilders.items():
|
| 181 |
+
message = value.get("message", "").lower()
|
| 182 |
+
brand_field = value.get("brand", "").lower()
|
| 183 |
+
bucket_field = value.get("bucket", "")
|
| 184 |
+
|
| 185 |
+
st.write(f"Checking TrustBuilder {key}:")
|
| 186 |
st.write(f" Message: {message}")
|
| 187 |
st.write(f" Brand: {brand_field}")
|
| 188 |
st.write(f" Bucket: {bucket_field}")
|
| 189 |
|
|
|
|
| 190 |
if keyword and keyword.lower() not in message:
|
| 191 |
st.write(" Keyword does not match.")
|
| 192 |
continue
|
|
|
|
| 196 |
if bucket and bucket != "All" and bucket != bucket_field:
|
| 197 |
st.write(f" Bucket '{bucket_field}' does not match selected '{bucket}'.")
|
| 198 |
continue
|
| 199 |
+
|
| 200 |
st.write(" TrustBuilder matches filters.")
|
| 201 |
+
filtered_trustbuilders[key] = value
|
| 202 |
+
|
| 203 |
st.write("Filtered TrustBuilders:", filtered_trustbuilders)
|
| 204 |
return filtered_trustbuilders
|
| 205 |
except Exception as e:
|
|
|
|
| 566 |
|
| 567 |
|
| 568 |
|
|
|
|
| 569 |
def save_content(user_id, brand, trust_builder_text, trust_bucket=None):
|
| 570 |
try:
|
| 571 |
trustbuilder_id = str(uuid.uuid4())
|
| 572 |
data = {
|
| 573 |
+
"brand": str(brand),
|
| 574 |
+
"message": str(trust_builder_text),
|
| 575 |
+
"bucket": str(trust_bucket)
|
| 576 |
}
|
|
|
|
| 577 |
st.write("Saving TrustBuilder with data:", data)
|
| 578 |
db.child("users").child(user_id).child("TrustBuilder").child(trustbuilder_id).set(data)
|
| 579 |
st.success(f"TrustBuilder saved to {trust_bucket} bucket.")
|
| 580 |
except Exception as e:
|
| 581 |
st.error(f"Error saving TrustBuilder: {e}")
|
| 582 |
+
|
| 583 |
+
|
| 584 |
def ai_allocate_trust_bucket(trust_builder_text):
|
| 585 |
# Implement your AI allocation logic here
|
| 586 |
return "Stability"
|