Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1633,8 +1633,30 @@ def download_trustbuilder_as_md(content, trustbuilder_id):
|
|
| 1633 |
download_link = f'<a href="data:text/markdown;base64,{b64_content}" download="TrustBuilder_{trustbuilder_id}.md">Download</a>'
|
| 1634 |
st.sidebar.markdown(download_link, unsafe_allow_html=True)
|
| 1635 |
|
| 1636 |
-
def
|
| 1637 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
|
@@ -1708,6 +1730,23 @@ if st.session_state["used_messages"] < st.session_state["message_limit"]:
|
|
| 1708 |
if prompt:
|
| 1709 |
st.session_state.chat_started = True
|
| 1710 |
st.session_state.chat_history.append({"role": "user", "content": prompt})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1711 |
|
| 1712 |
# Handle save commands based on the user prompt
|
| 1713 |
memory_response = handle_memory_queries(prompt)
|
|
|
|
| 1633 |
download_link = f'<a href="data:text/markdown;base64,{b64_content}" download="TrustBuilder_{trustbuilder_id}.md">Download</a>'
|
| 1634 |
st.sidebar.markdown(download_link, unsafe_allow_html=True)
|
| 1635 |
|
| 1636 |
+
def handle_save_trustbuilder(content, specified_bucket=None):
|
| 1637 |
+
"""
|
| 1638 |
+
Handles saving TrustBuilders by detecting or prompting for the Trust Bucket.
|
| 1639 |
+
"""
|
| 1640 |
+
trust_buckets = ["Stability", "Development", "Relationship", "Benefit", "Vision", "Competence"]
|
| 1641 |
+
bucket = specified_bucket
|
| 1642 |
+
|
| 1643 |
+
# Detect bucket if not explicitly provided
|
| 1644 |
+
if not bucket:
|
| 1645 |
+
for tb in trust_buckets:
|
| 1646 |
+
if tb.lower() in content.lower():
|
| 1647 |
+
bucket = tb
|
| 1648 |
+
break
|
| 1649 |
+
|
| 1650 |
+
if not bucket:
|
| 1651 |
+
st.warning("No Trust Bucket specified. Please indicate the Trust Bucket.")
|
| 1652 |
+
st.session_state["missing_trustbucket_content"] = content
|
| 1653 |
+
return
|
| 1654 |
+
|
| 1655 |
+
# Save TrustBuilder with detected/provided bucket
|
| 1656 |
+
brand = st.session_state.get("brand_input_save", "Unknown")
|
| 1657 |
+
content_to_save = f"{bucket}: Brand: {brand.strip()} | {content.strip()}"
|
| 1658 |
+
save_content(st.session_state["wix_user_id"], content_to_save)
|
| 1659 |
+
st.success(f"TrustBuilder saved under '{bucket}' Trust.")
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
|
|
|
| 1730 |
if prompt:
|
| 1731 |
st.session_state.chat_started = True
|
| 1732 |
st.session_state.chat_history.append({"role": "user", "content": prompt})
|
| 1733 |
+
if "save this as trustbuilder" in prompt.lower():
|
| 1734 |
+
content_to_save = prompt.replace("save this as trustbuilder", "").strip()
|
| 1735 |
+
specified_bucket = None
|
| 1736 |
+
|
| 1737 |
+
# Check for explicit bucket mention in the same prompt
|
| 1738 |
+
match = re.search(r"under\s+(\w+\s*trust)", prompt, re.IGNORECASE)
|
| 1739 |
+
if match:
|
| 1740 |
+
bucket_name = match.group(1).replace("trust", "").strip()
|
| 1741 |
+
if bucket_name in ["Stability", "Development", "Relationship", "Benefit", "Vision", "Competence"]:
|
| 1742 |
+
specified_bucket = bucket_name
|
| 1743 |
+
|
| 1744 |
+
if content_to_save:
|
| 1745 |
+
handle_save_trustbuilder(content_to_save, specified_bucket)
|
| 1746 |
+
else:
|
| 1747 |
+
st.warning("Please provide content to save as TrustBuilder.")
|
| 1748 |
+
|
| 1749 |
+
|
| 1750 |
|
| 1751 |
# Handle save commands based on the user prompt
|
| 1752 |
memory_response = handle_memory_queries(prompt)
|