Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -719,10 +719,13 @@ def side():
|
|
| 719 |
st.markdown("For detailed descriptions, visit [Academy](https://www.trustifier.ai/account/academy)")
|
| 720 |
|
| 721 |
|
| 722 |
-
|
|
|
|
|
|
|
| 723 |
# Image paths and labels (pre-resized images in your folder)
|
| 724 |
st.sidebar.header("TrustVault®")
|
| 725 |
-
|
|
|
|
| 726 |
st.markdown("""
|
| 727 |
<style>
|
| 728 |
.scrollable-container {
|
|
@@ -735,15 +738,15 @@ def side():
|
|
| 735 |
}
|
| 736 |
</style>
|
| 737 |
""", unsafe_allow_html=True)
|
| 738 |
-
|
| 739 |
# Container for Saved Documents
|
| 740 |
with st.container():
|
| 741 |
st.subheader("Saved Documents")
|
| 742 |
st.write("Save documents like your brand tonality, key phrases, or segments here.")
|
| 743 |
st.markdown('<div class="scrollable-container">', unsafe_allow_html=True)
|
| 744 |
-
|
| 745 |
docs = fetch_documents(st.session_state["wix_user_id"])
|
| 746 |
-
|
| 747 |
if docs:
|
| 748 |
for doc_id, doc_data in docs.items():
|
| 749 |
st.markdown(f"**Document ID:** {doc_id[:8]}")
|
|
@@ -756,9 +759,9 @@ def side():
|
|
| 756 |
delete_document(st.session_state["wix_user_id"], doc_id)
|
| 757 |
else:
|
| 758 |
st.write("No saved documents found.")
|
| 759 |
-
|
| 760 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 761 |
-
|
| 762 |
# File Upload Section
|
| 763 |
st.subheader("Upload New Documents")
|
| 764 |
with st.form(key='upload_form'):
|
|
@@ -768,7 +771,7 @@ def side():
|
|
| 768 |
accept_multiple_files=True
|
| 769 |
)
|
| 770 |
submit_upload = st.form_submit_button(label='Upload')
|
| 771 |
-
|
| 772 |
if submit_upload:
|
| 773 |
if uploaded_files:
|
| 774 |
md_contents = []
|
|
@@ -793,17 +796,17 @@ def side():
|
|
| 793 |
st.warning("No valid files uploaded.")
|
| 794 |
else:
|
| 795 |
st.warning("Please select at least one file to upload.")
|
| 796 |
-
|
| 797 |
# Show My TrustBuilders Section
|
| 798 |
st.subheader("Show my TrustBuilders®")
|
| 799 |
search_query = st.text_input("Search by keyword", key="search_query")
|
| 800 |
brand_input = st.text_input("Brand/Product/Person", key="brand_input")
|
| 801 |
-
|
| 802 |
-
# Trust Bucket Selection
|
| 803 |
st.write("Choose the Trust Bucket®")
|
| 804 |
bucket_options = ["All"] + bucket_labels
|
| 805 |
selected_bucket = st.selectbox("Select Trust Bucket", options=bucket_options, key="selected_bucket")
|
| 806 |
-
|
| 807 |
if st.button("Show TrustBuilders"):
|
| 808 |
search_results = fetch_trustbuilders(
|
| 809 |
st.session_state["wix_user_id"],
|
|
@@ -819,24 +822,21 @@ def side():
|
|
| 819 |
st.write(f"Message: {result_data.get('message', '')}")
|
| 820 |
else:
|
| 821 |
st.write("No TrustBuilders found.")
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
# Trust Bucket Selection
|
| 825 |
st.write("Choose the Trust Bucket®")
|
| 826 |
-
trust_buckets = ["S", "D", "R", "B", "V", "C"]
|
| 827 |
-
bucket_labels = ["Stability", "Development", "Relationship", "Benefit", "Vision", "Competence"]
|
| 828 |
cols = st.columns(len(trust_buckets))
|
| 829 |
for idx, (bucket, label) in enumerate(zip(trust_buckets, bucket_labels)):
|
| 830 |
with cols[idx]:
|
| 831 |
if st.button(f"{bucket}", key=f"bucket_{label}"):
|
| 832 |
st.write(f"Selected Trust Bucket: {label}")
|
| 833 |
-
st.session_state["
|
| 834 |
-
|
| 835 |
# Save TrustBuilders Section
|
| 836 |
st.subheader("Save TrustBuilders®")
|
| 837 |
brand = st.text_input("Brand/Product/Person", key="brand_product")
|
| 838 |
trust_builder_text = st.text_area("Type/paste Trust Builder®", height=100)
|
| 839 |
-
|
| 840 |
# Allocate TrustBuilders to Buckets
|
| 841 |
st.write("Allocate to")
|
| 842 |
cols_allocate = st.columns(len(trust_buckets))
|
|
@@ -844,44 +844,12 @@ def side():
|
|
| 844 |
with cols_allocate[idx]:
|
| 845 |
if st.button(f"{bucket}", key=f"allocate_{label}"):
|
| 846 |
save_content(st.session_state["wix_user_id"], brand, trust_builder_text, trust_bucket=label)
|
| 847 |
-
|
| 848 |
-
if st.button("Let AI allocate"):
|
| 849 |
-
allocated_bucket = ai_allocate_trust_bucket(trust_builder_text)
|
| 850 |
-
if allocated_bucket:
|
| 851 |
-
save_content(st.session_state["wix_user_id"], brand, trust_builder_text, trust_bucket=allocated_bucket)
|
| 852 |
-
st.success(f"AI allocated the Trust Bucket: {allocated_bucket} and saved your TrustBuilder.")
|
| 853 |
-
else:
|
| 854 |
-
st.error("AI could not allocate the Trust Bucket.")
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
|
| 875 |
|
|
|
|
| 876 |
|
| 877 |
|
| 878 |
-
|
| 879 |
side()
|
| 880 |
-
# Load knowledge base
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
# Initialize embeddings and FAISS index only when wix_user_id is set
|
| 884 |
-
|
| 885 |
if st.session_state.get("wix_user_id") and "faiss_db" not in st.session_state:
|
| 886 |
refresh_faiss_index()
|
| 887 |
|
|
|
|
| 719 |
st.markdown("For detailed descriptions, visit [Academy](https://www.trustifier.ai/account/academy)")
|
| 720 |
|
| 721 |
|
| 722 |
+
trust_buckets = ["S", "D", "R", "B", "V", "C"]
|
| 723 |
+
bucket_labels = ["Stability", "Development", "Relationship", "Benefit", "Vision", "Competence"]
|
| 724 |
+
|
| 725 |
# Image paths and labels (pre-resized images in your folder)
|
| 726 |
st.sidebar.header("TrustVault®")
|
| 727 |
+
|
| 728 |
+
# CSS for scrollable container with gray border
|
| 729 |
st.markdown("""
|
| 730 |
<style>
|
| 731 |
.scrollable-container {
|
|
|
|
| 738 |
}
|
| 739 |
</style>
|
| 740 |
""", unsafe_allow_html=True)
|
| 741 |
+
|
| 742 |
# Container for Saved Documents
|
| 743 |
with st.container():
|
| 744 |
st.subheader("Saved Documents")
|
| 745 |
st.write("Save documents like your brand tonality, key phrases, or segments here.")
|
| 746 |
st.markdown('<div class="scrollable-container">', unsafe_allow_html=True)
|
| 747 |
+
|
| 748 |
docs = fetch_documents(st.session_state["wix_user_id"])
|
| 749 |
+
|
| 750 |
if docs:
|
| 751 |
for doc_id, doc_data in docs.items():
|
| 752 |
st.markdown(f"**Document ID:** {doc_id[:8]}")
|
|
|
|
| 759 |
delete_document(st.session_state["wix_user_id"], doc_id)
|
| 760 |
else:
|
| 761 |
st.write("No saved documents found.")
|
| 762 |
+
|
| 763 |
st.markdown('</div>', unsafe_allow_html=True)
|
| 764 |
+
|
| 765 |
# File Upload Section
|
| 766 |
st.subheader("Upload New Documents")
|
| 767 |
with st.form(key='upload_form'):
|
|
|
|
| 771 |
accept_multiple_files=True
|
| 772 |
)
|
| 773 |
submit_upload = st.form_submit_button(label='Upload')
|
| 774 |
+
|
| 775 |
if submit_upload:
|
| 776 |
if uploaded_files:
|
| 777 |
md_contents = []
|
|
|
|
| 796 |
st.warning("No valid files uploaded.")
|
| 797 |
else:
|
| 798 |
st.warning("Please select at least one file to upload.")
|
| 799 |
+
|
| 800 |
# Show My TrustBuilders Section
|
| 801 |
st.subheader("Show my TrustBuilders®")
|
| 802 |
search_query = st.text_input("Search by keyword", key="search_query")
|
| 803 |
brand_input = st.text_input("Brand/Product/Person", key="brand_input")
|
| 804 |
+
|
| 805 |
+
# Trust Bucket Selection for Filtering
|
| 806 |
st.write("Choose the Trust Bucket®")
|
| 807 |
bucket_options = ["All"] + bucket_labels
|
| 808 |
selected_bucket = st.selectbox("Select Trust Bucket", options=bucket_options, key="selected_bucket")
|
| 809 |
+
|
| 810 |
if st.button("Show TrustBuilders"):
|
| 811 |
search_results = fetch_trustbuilders(
|
| 812 |
st.session_state["wix_user_id"],
|
|
|
|
| 822 |
st.write(f"Message: {result_data.get('message', '')}")
|
| 823 |
else:
|
| 824 |
st.write("No TrustBuilders found.")
|
| 825 |
+
|
| 826 |
+
# Trust Bucket Selection for Saving
|
|
|
|
| 827 |
st.write("Choose the Trust Bucket®")
|
|
|
|
|
|
|
| 828 |
cols = st.columns(len(trust_buckets))
|
| 829 |
for idx, (bucket, label) in enumerate(zip(trust_buckets, bucket_labels)):
|
| 830 |
with cols[idx]:
|
| 831 |
if st.button(f"{bucket}", key=f"bucket_{label}"):
|
| 832 |
st.write(f"Selected Trust Bucket: {label}")
|
| 833 |
+
st.session_state["selected_bucket_to_save"] = label
|
| 834 |
+
|
| 835 |
# Save TrustBuilders Section
|
| 836 |
st.subheader("Save TrustBuilders®")
|
| 837 |
brand = st.text_input("Brand/Product/Person", key="brand_product")
|
| 838 |
trust_builder_text = st.text_area("Type/paste Trust Builder®", height=100)
|
| 839 |
+
|
| 840 |
# Allocate TrustBuilders to Buckets
|
| 841 |
st.write("Allocate to")
|
| 842 |
cols_allocate = st.columns(len(trust_buckets))
|
|
|
|
| 844 |
with cols_allocate[idx]:
|
| 845 |
if st.button(f"{bucket}", key=f"allocate_{label}"):
|
| 846 |
save_content(st.session_state["wix_user_id"], brand, trust_builder_text, trust_bucket=label)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 847 |
|
| 848 |
|
| 849 |
+
# Initialize embeddings and FAISS index only when wix_user_id is set
|
| 850 |
|
| 851 |
|
|
|
|
| 852 |
side()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 853 |
if st.session_state.get("wix_user_id") and "faiss_db" not in st.session_state:
|
| 854 |
refresh_faiss_index()
|
| 855 |
|