Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -504,52 +504,129 @@ def download_link(content, filename):
|
|
| 504 |
|
| 505 |
|
| 506 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
def side():
|
| 508 |
with st.sidebar:
|
| 509 |
|
| 510 |
with st.sidebar.expander("TrustLogic®", expanded=False):
|
| 511 |
st.image("Trust Logic_Wheel_RGB_Standard.png")
|
| 512 |
-
|
| 513 |
-
st.markdown(
|
| 514 |
-
"Our minds assess trust through Six Buckets of Trust® and determine their importance and order in a given situation. We then evaluate why we can or can’t trust someone in these Buckets. Trustifier.ai®, trained on 20 years of TrustLogic® application, helps you identify reasons why your audience can trust you in each Bucket and create trust-optimised solutions. It’s copy AI with substance."
|
| 515 |
-
)
|
| 516 |
st.markdown(
|
| 517 |
"""
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
<h3 class="relationship">Relationship Trust:</h3>
|
| 534 |
-
<p>What appealing relationship qualities can I trust you for?</p>
|
| 535 |
-
|
| 536 |
-
<h3 class="benefit">Benefit Trust:</h3>
|
| 537 |
-
<p>What benefits can I trust you for?</p>
|
| 538 |
-
|
| 539 |
-
<h3 class="vision">Vision Trust:</h3>
|
| 540 |
-
<p>What Vision and Values can I trust you for?</p>
|
| 541 |
-
|
| 542 |
-
<h3 class="competence">Competence Trust:</h3>
|
| 543 |
-
<p>What competencies can I trust you for?</p>
|
| 544 |
-
""", unsafe_allow_html=True
|
| 545 |
)
|
| 546 |
st.markdown("For detailed descriptions, visit [Academy](https://www.trustifier.ai/account/academy)")
|
|
|
|
| 547 |
|
| 548 |
st.image("Trust Logic_Wheel_RGB_Standard.png")
|
| 549 |
|
| 550 |
st.sidebar.markdown('<hr style="border: 2px solid rgb(255, 153, 0); width: 80%; margin: 20px auto;">', unsafe_allow_html=True)
|
| 551 |
|
| 552 |
with st.sidebar.expander("Trust Buckets® and Trust Builders®", expanded=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
st.markdown(
|
| 554 |
"Our minds assess trust through Six Buckets of Trust® and determine their importance and order in a given situation. We then evaluate why we can or can’t trust someone in these Buckets. Trustifier.ai®, trained on 20 years of TrustLogic® application, helps you identify reasons why your audience can trust you in each Bucket and create trust-optimised solutions. It’s copy AI with substance."
|
| 555 |
)
|
|
@@ -585,101 +662,100 @@ def side():
|
|
| 585 |
)
|
| 586 |
st.markdown("For detailed descriptions, visit [Academy](https://www.trustifier.ai/account/academy)")
|
| 587 |
|
| 588 |
-
st.image("Trust Logic_Wheel_RGB_Standard.png")
|
| 589 |
|
| 590 |
|
| 591 |
# Image paths and labels (pre-resized images in your folder)
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
|
| 601 |
-
#
|
| 602 |
-
st.markdown(
|
| 603 |
"""
|
| 604 |
<style>
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
position: relative;
|
| 613 |
-
}
|
| 614 |
-
.image-wrapper img {
|
| 615 |
-
width: 100px;
|
| 616 |
-
transition: transform 0.3s;
|
| 617 |
-
}
|
| 618 |
-
.image-wrapper img:hover {
|
| 619 |
-
transform: scale(1.1);
|
| 620 |
-
}
|
| 621 |
-
.hover-text {
|
| 622 |
-
position: absolute;
|
| 623 |
-
top: 110%;
|
| 624 |
-
left: 50%;
|
| 625 |
-
transform: translateX(-50%);
|
| 626 |
-
opacity: 0;
|
| 627 |
-
transition: opacity 0.3s;
|
| 628 |
-
font-size: 14px;
|
| 629 |
-
font-weight: bold;
|
| 630 |
-
}
|
| 631 |
-
.image-wrapper:hover .hover-text {
|
| 632 |
-
opacity: 1;
|
| 633 |
-
}
|
| 634 |
</style>
|
| 635 |
""",
|
| 636 |
-
unsafe_allow_html=True
|
| 637 |
)
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
with cols[idx]:
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
submit_button = st.form_submit_button("Upload")
|
| 663 |
-
|
| 664 |
-
if submit_button and uploaded_files:
|
| 665 |
-
md_contents = [convert_file_to_md(file) for file in uploaded_files if convert_file_to_md(file)]
|
| 666 |
-
if md_contents:
|
| 667 |
-
merged_md = merge_markdown_contents(md_contents)
|
| 668 |
-
upload_url = upload_to_firebase(st.session_state["wix_user_id"], merged_md)
|
| 669 |
-
if upload_url:
|
| 670 |
-
st.success("Files uploaded and processed successfully!")
|
| 671 |
-
st.markdown(f"[View your uploaded knowledge base here]({upload_url})", unsafe_allow_html=True)
|
| 672 |
-
refresh_faiss_index()
|
| 673 |
-
# Save Custom Content section
|
| 674 |
-
st.header("Save Custom Content")
|
| 675 |
-
custom_content = st.text_area("Enter content to save")
|
| 676 |
-
if st.button("Save as Brand Tonality"):
|
| 677 |
-
save_content(st.session_state["wix_user_id"], custom_content, "brandtonality")
|
| 678 |
-
if st.button("Save as TrustBuilder"):
|
| 679 |
-
save_content(st.session_state["wix_user_id"], custom_content, "trustbuilder")
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
|
| 684 |
|
| 685 |
side()
|
|
|
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
# Function to delete a document from Firebase
|
| 514 |
+
def delete_document(user_id, doc_id):
|
| 515 |
+
"""
|
| 516 |
+
Deletes a document from Firebase.
|
| 517 |
+
"""
|
| 518 |
+
try:
|
| 519 |
+
db.child("users").child(user_id).child("KnowledgeBase").child(doc_id).remove()
|
| 520 |
+
st.success("Document deleted successfully!")
|
| 521 |
+
st.experimental_rerun() # Refresh the list after deletion
|
| 522 |
+
except Exception as e:
|
| 523 |
+
st.error(f"Error deleting document: {e}")
|
| 524 |
+
|
| 525 |
+
# Fetch documents from Firebase
|
| 526 |
+
def fetch_documents(user_id):
|
| 527 |
+
"""
|
| 528 |
+
Fetches all saved documents from Firebase.
|
| 529 |
+
"""
|
| 530 |
+
try:
|
| 531 |
+
docs = db.child("users").child(user_id).child("KnowledgeBase").get().val()
|
| 532 |
+
return docs if docs else {}
|
| 533 |
+
except Exception as e:
|
| 534 |
+
st.error(f"Error fetching documents: {e}")
|
| 535 |
+
return {}
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
|
| 539 |
def side():
|
| 540 |
with st.sidebar:
|
| 541 |
|
| 542 |
with st.sidebar.expander("TrustLogic®", expanded=False):
|
| 543 |
st.image("Trust Logic_Wheel_RGB_Standard.png")
|
| 544 |
+
|
|
|
|
|
|
|
|
|
|
| 545 |
st.markdown(
|
| 546 |
"""
|
| 547 |
+
**TrustLogic®** is a proven, scientific method for building trust, showing how our minds process trust.
|
| 548 |
+
Remember:
|
| 549 |
+
|
| 550 |
+
You can’t trust in general – only for specific reasons.
|
| 551 |
+
|
| 552 |
+
Our mind organizes these reasons into six types of trust:
|
| 553 |
+
**Stability**, **Development**, **Relationship**, **Benefit**, **Vision**, and **Competence**.
|
| 554 |
+
Together, they form your **trust score**. Every bit more trust counts and can be nudged up in each interaction.
|
| 555 |
+
|
| 556 |
+
Think of these as the **Six Buckets of Trust®** – the fuller each bucket, the greater the trust.
|
| 557 |
+
|
| 558 |
+
To build trust, understand what makes you more trustworthy in each **Trust Bucket®** and convey these **Trust Builders®** – because what I don’t know about you, I can’t trust.
|
| 559 |
+
|
| 560 |
+
**Stability + Development + Relationship + Benefit + Vision + Competence Trust = Your Trust.**
|
| 561 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
)
|
| 563 |
st.markdown("For detailed descriptions, visit [Academy](https://www.trustifier.ai/account/academy)")
|
| 564 |
+
|
| 565 |
|
| 566 |
st.image("Trust Logic_Wheel_RGB_Standard.png")
|
| 567 |
|
| 568 |
st.sidebar.markdown('<hr style="border: 2px solid rgb(255, 153, 0); width: 80%; margin: 20px auto;">', unsafe_allow_html=True)
|
| 569 |
|
| 570 |
with st.sidebar.expander("Trust Buckets® and Trust Builders®", expanded=False):
|
| 571 |
+
image_files = [
|
| 572 |
+
("Bucket_STABILITY.png"),
|
| 573 |
+
("Bucket_DEVELOPMENT.png"),
|
| 574 |
+
("Bucket_RELATIONSHIP.png"),
|
| 575 |
+
("Bucket_BENEFIT.png"),
|
| 576 |
+
("Bucket_VISION.png"),
|
| 577 |
+
("Bucket_COMPETENCE.png"),
|
| 578 |
+
]
|
| 579 |
+
|
| 580 |
+
# CSS for layout and hover effect in Streamlit
|
| 581 |
+
st.markdown(
|
| 582 |
+
"""
|
| 583 |
+
<style>
|
| 584 |
+
.image-container {
|
| 585 |
+
display: flex;
|
| 586 |
+
justify-content: center;
|
| 587 |
+
gap: 20px;
|
| 588 |
+
}
|
| 589 |
+
.image-wrapper {
|
| 590 |
+
text-align: center;
|
| 591 |
+
position: relative;
|
| 592 |
+
}
|
| 593 |
+
.image-wrapper img {
|
| 594 |
+
width: 100px;
|
| 595 |
+
transition: transform 0.3s;
|
| 596 |
+
}
|
| 597 |
+
.image-wrapper img:hover {
|
| 598 |
+
transform: scale(1.1);
|
| 599 |
+
}
|
| 600 |
+
.hover-text {
|
| 601 |
+
position: absolute;
|
| 602 |
+
top: 110%;
|
| 603 |
+
left: 50%;
|
| 604 |
+
transform: translateX(-50%);
|
| 605 |
+
opacity: 0;
|
| 606 |
+
transition: opacity 0.3s;
|
| 607 |
+
font-size: 14px;
|
| 608 |
+
font-weight: bold;
|
| 609 |
+
}
|
| 610 |
+
.image-wrapper:hover .hover-text {
|
| 611 |
+
opacity: 1;
|
| 612 |
+
}
|
| 613 |
+
</style>
|
| 614 |
+
""",
|
| 615 |
+
unsafe_allow_html=True,
|
| 616 |
+
)
|
| 617 |
+
|
| 618 |
+
# Create a horizontal layout using Streamlit's columns
|
| 619 |
+
cols = st.columns(len(image_files))
|
| 620 |
+
|
| 621 |
+
# Display each image in its respective column
|
| 622 |
+
for idx, (img_path) in enumerate(image_files):
|
| 623 |
+
with cols[idx]:
|
| 624 |
+
# Open the image (assuming it's pre-resized)
|
| 625 |
+
img = Image.open(img_path)
|
| 626 |
+
|
| 627 |
+
# Display the image with caption and hover effect using use_container_width=True
|
| 628 |
+
st.image(img,use_container_width=True)
|
| 629 |
+
|
| 630 |
st.markdown(
|
| 631 |
"Our minds assess trust through Six Buckets of Trust® and determine their importance and order in a given situation. We then evaluate why we can or can’t trust someone in these Buckets. Trustifier.ai®, trained on 20 years of TrustLogic® application, helps you identify reasons why your audience can trust you in each Bucket and create trust-optimised solutions. It’s copy AI with substance."
|
| 632 |
)
|
|
|
|
| 662 |
)
|
| 663 |
st.markdown("For detailed descriptions, visit [Academy](https://www.trustifier.ai/account/academy)")
|
| 664 |
|
|
|
|
| 665 |
|
| 666 |
|
| 667 |
# Image paths and labels (pre-resized images in your folder)
|
| 668 |
+
st.sidebar.header("TrustVault®")
|
| 669 |
+
|
| 670 |
+
# Saved Documents Section
|
| 671 |
+
st.sidebar.subheader("Saved documents")
|
| 672 |
+
st.sidebar.text_area("Save documents like your brand tonality, key phrases, or segments here", height=80, disabled=True)
|
| 673 |
+
|
| 674 |
+
col1, col2 = st.sidebar.columns([0.5, 0.5])
|
| 675 |
+
with col1:
|
| 676 |
+
if st.button("Upload"):
|
| 677 |
+
uploaded_files = st.file_uploader("Upload PDF, DOCX, or TXT files", type=["pdf", "docx", "txt"], accept_multiple_files=True)
|
| 678 |
+
if uploaded_files:
|
| 679 |
+
md_contents = [convert_file_to_md(file) for file in uploaded_files if convert_file_to_md(file)]
|
| 680 |
+
if md_contents:
|
| 681 |
+
merged_md_content = merge_markdown_contents(md_contents)
|
| 682 |
+
upload_url = upload_to_firebase(user_id, merged_md_content)
|
| 683 |
+
if upload_url:
|
| 684 |
+
st.sidebar.success("Files uploaded successfully!")
|
| 685 |
+
st.sidebar.markdown(f"[View your knowledge base here]({upload_url})", unsafe_allow_html=True)
|
| 686 |
+
else:
|
| 687 |
+
st.sidebar.warning("No valid files to upload.")
|
| 688 |
+
with col2:
|
| 689 |
+
if st.button("Delete"):
|
| 690 |
+
st.warning("Select a document to delete from the list below.")
|
| 691 |
|
| 692 |
+
# Display saved documents in a scrollable container
|
| 693 |
+
st.sidebar.markdown(
|
| 694 |
"""
|
| 695 |
<style>
|
| 696 |
+
.scrollable-container {
|
| 697 |
+
height: 200px;
|
| 698 |
+
overflow-y: auto;
|
| 699 |
+
border: 1px solid #ddd;
|
| 700 |
+
padding: 10px;
|
| 701 |
+
background-color: #f5f5f5;
|
| 702 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 703 |
</style>
|
| 704 |
""",
|
| 705 |
+
unsafe_allow_html=True
|
| 706 |
)
|
| 707 |
+
|
| 708 |
+
docs = fetch_documents(user_id)
|
| 709 |
+
st.sidebar.markdown('<div class="scrollable-container">', unsafe_allow_html=True)
|
| 710 |
+
if docs:
|
| 711 |
+
for doc_id, doc_data in docs.items():
|
| 712 |
+
st.sidebar.markdown(f"- {doc_data['content'][:50]}...")
|
| 713 |
+
col1, col2 = st.sidebar.columns([0.5, 0.5])
|
| 714 |
+
with col1:
|
| 715 |
+
if st.button("Delete", key=f"del_{doc_id}"):
|
| 716 |
+
delete_document(user_id, doc_id)
|
| 717 |
+
with col2:
|
| 718 |
+
if st.button("View", key=f"view_{doc_id}"):
|
| 719 |
+
st.sidebar.write(doc_data["content"])
|
| 720 |
+
else:
|
| 721 |
+
st.sidebar.write("No saved documents found.")
|
| 722 |
+
st.sidebar.markdown('</div>', unsafe_allow_html=True)
|
| 723 |
+
|
| 724 |
+
# Show My TrustBuilders Section
|
| 725 |
+
st.sidebar.subheader("Show my TrustBuilders®")
|
| 726 |
+
search_query = st.sidebar.text_input("Search by keyword")
|
| 727 |
+
if search_query:
|
| 728 |
+
search_results = {k: v for k, v in st.session_state.get("TrustBuilder", {}).items() if search_query.lower() in v["message"].lower()}
|
| 729 |
+
for result_id, result_data in search_results.items():
|
| 730 |
+
st.sidebar.write(f"- {result_data['message'][:50]}")
|
| 731 |
+
|
| 732 |
+
st.sidebar.text_input("Brand/Product/Person")
|
| 733 |
+
if st.sidebar.button("Show"):
|
| 734 |
+
st.write("Show clicked")
|
| 735 |
+
|
| 736 |
+
st.sidebar.write("and choose the Trust Bucket®")
|
| 737 |
+
trust_buckets = ["S", "D", "R", "B", "V", "C"]
|
| 738 |
+
bucket_labels = ["Stability", "Development", "Relationship", "Benefit", "Vision", "Competence"]
|
| 739 |
+
cols = st.sidebar.columns(len(trust_buckets))
|
| 740 |
+
for idx, (bucket, label) in enumerate(zip(trust_buckets, bucket_labels)):
|
| 741 |
with cols[idx]:
|
| 742 |
+
if st.button(f"{bucket}", key=f"bucket_{label}"):
|
| 743 |
+
st.write(f"{label} Trust clicked")
|
| 744 |
+
|
| 745 |
+
# Save TrustBuilders Section
|
| 746 |
+
st.sidebar.subheader("Save TrustBuilders®")
|
| 747 |
+
st.sidebar.text_input("Brand/Product/Person")
|
| 748 |
+
trust_builder_text = st.sidebar.text_area("Type/paste Trust Builder®", height=100)
|
| 749 |
+
|
| 750 |
+
# Allocate TrustBuilders to Buckets
|
| 751 |
+
st.sidebar.write("Allocate to")
|
| 752 |
+
for idx, (bucket, label) in enumerate(zip(trust_buckets, bucket_labels)):
|
| 753 |
+
with st.sidebar:
|
| 754 |
+
if st.button(f"{bucket}", key=f"allocate_{label}"):
|
| 755 |
+
save_content(user_id, trust_builder_text, label)
|
| 756 |
+
|
| 757 |
+
if st.sidebar.button("Let AI allocate"):
|
| 758 |
+
st.write("AI allocated the Trust Bucket")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 759 |
|
| 760 |
|
| 761 |
side()
|