Update app.py
Browse files
app.py
CHANGED
|
@@ -605,7 +605,7 @@ except Exception as e:
|
|
| 605 |
# --- Gradio UI ---
|
| 606 |
initial_chat = [{"role": "assistant", "content": "Detta är ChargeNode's AI bot. Hur kan jag hjälpa dig idag?"}]
|
| 607 |
|
| 608 |
-
# BEHÅLL DESKTOP LAYOUT -
|
| 609 |
custom_css = """
|
| 610 |
/* DESKTOP LAYOUT - BEHÅLLS EXAKT SOM URSPRUNGLIG */
|
| 611 |
body {background-color: #f7f7f7; font-family: Arial, sans-serif; margin: 0; padding: 0;}
|
|
@@ -629,36 +629,34 @@ footer {display: none !important;}
|
|
| 629 |
.gradio-container .footer {display: none !important;}
|
| 630 |
.gradio-container .gr-footer {display: none !important;}
|
| 631 |
|
| 632 |
-
/* MOBIL-ANPASSNINGAR
|
| 633 |
@media (max-width: 768px) {
|
| 634 |
-
/*
|
| 635 |
html, body {
|
| 636 |
width: 100% !important;
|
| 637 |
height: 100% !important;
|
| 638 |
margin: 0 !important;
|
| 639 |
padding: 0 !important;
|
| 640 |
-
overflow:
|
|
|
|
| 641 |
background-color: #ffffff !important;
|
| 642 |
-webkit-overflow-scrolling: touch !important;
|
| 643 |
}
|
| 644 |
|
| 645 |
-
/* Gradio app
|
| 646 |
.gradio-app {
|
| 647 |
width: 100% !important;
|
| 648 |
-
height:
|
| 649 |
margin: 0 !important;
|
| 650 |
padding: 0 !important;
|
|
|
|
| 651 |
}
|
| 652 |
|
| 653 |
-
/*
|
| 654 |
.gradio-container {
|
| 655 |
-
position:
|
| 656 |
-
top: 0 !important;
|
| 657 |
-
left: 0 !important;
|
| 658 |
-
right: 0 !important;
|
| 659 |
-
bottom: 0 !important;
|
| 660 |
width: 100% !important;
|
| 661 |
-
height:
|
| 662 |
max-width: none !important;
|
| 663 |
margin: 0 !important;
|
| 664 |
padding: 8px !important;
|
|
@@ -670,46 +668,52 @@ footer {display: none !important;}
|
|
| 670 |
box-sizing: border-box !important;
|
| 671 |
}
|
| 672 |
|
| 673 |
-
/*
|
| 674 |
.gradio-container > .gr-markdown:first-child {
|
| 675 |
flex-shrink: 0 !important;
|
| 676 |
-
font-size:
|
| 677 |
-
line-height: 1.
|
| 678 |
-
margin: 0 0
|
| 679 |
-
padding: 8px !important;
|
| 680 |
background-color: #f8f9fa !important;
|
| 681 |
-
border-radius:
|
| 682 |
text-align: center !important;
|
| 683 |
}
|
| 684 |
|
| 685 |
-
/*
|
| 686 |
.gradio-container > .gr-group {
|
| 687 |
flex: 1 !important;
|
| 688 |
display: flex !important;
|
| 689 |
flex-direction: column !important;
|
| 690 |
-
overflow: hidden !important;
|
| 691 |
margin: 0 !important;
|
| 692 |
padding: 0 !important;
|
|
|
|
| 693 |
}
|
| 694 |
|
| 695 |
-
/*
|
| 696 |
#chatbot_conversation {
|
| 697 |
flex: 1 !important;
|
| 698 |
-
min-height:
|
| 699 |
-
max-height:
|
| 700 |
-
margin: 0 0
|
| 701 |
-
padding:
|
| 702 |
overflow-y: auto !important;
|
| 703 |
border: 1px solid #e9ecef !important;
|
| 704 |
-
border-radius:
|
| 705 |
background-color: #ffffff !important;
|
| 706 |
-webkit-overflow-scrolling: touch !important;
|
| 707 |
}
|
| 708 |
|
| 709 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 710 |
.gradio-container .gr-row {
|
| 711 |
flex-shrink: 0 !important;
|
| 712 |
-
margin:
|
| 713 |
}
|
| 714 |
|
| 715 |
/* Textbox för mobil */
|
|
@@ -719,12 +723,13 @@ footer {display: none !important;}
|
|
| 719 |
|
| 720 |
.gr-textbox textarea {
|
| 721 |
font-size: 16px !important;
|
| 722 |
-
padding:
|
| 723 |
-
border:
|
| 724 |
-
border-radius:
|
| 725 |
resize: none !important;
|
| 726 |
width: 100% !important;
|
| 727 |
box-sizing: border-box !important;
|
|
|
|
| 728 |
}
|
| 729 |
|
| 730 |
.gr-textbox textarea:focus {
|
|
@@ -732,66 +737,66 @@ footer {display: none !important;}
|
|
| 732 |
outline: none !important;
|
| 733 |
}
|
| 734 |
|
| 735 |
-
/*
|
| 736 |
.gr-button {
|
| 737 |
width: 100% !important;
|
| 738 |
-
padding:
|
| 739 |
-
margin:
|
| 740 |
-
font-size:
|
| 741 |
-
min-height:
|
| 742 |
-
border-radius:
|
| 743 |
box-sizing: border-box !important;
|
| 744 |
white-space: nowrap !important;
|
| 745 |
overflow: hidden !important;
|
| 746 |
text-overflow: ellipsis !important;
|
| 747 |
}
|
| 748 |
|
| 749 |
-
/* Knapp-
|
| 750 |
.gradio-container .gr-column {
|
| 751 |
width: 100% !important;
|
| 752 |
margin: 0 !important;
|
| 753 |
-
padding: 0
|
| 754 |
}
|
| 755 |
|
| 756 |
-
/*
|
| 757 |
.gr-form {
|
| 758 |
-
padding:
|
| 759 |
-
margin:
|
| 760 |
-
border-radius:
|
| 761 |
background-color: #f8f9fa !important;
|
| 762 |
}
|
| 763 |
|
| 764 |
.gr-form .gr-textbox {
|
| 765 |
-
margin:
|
| 766 |
}
|
| 767 |
|
| 768 |
.gr-form .gr-textbox input,
|
| 769 |
.gr-form .gr-textbox textarea {
|
| 770 |
font-size: 16px !important;
|
| 771 |
-
padding:
|
| 772 |
border-radius: 4px !important;
|
| 773 |
}
|
| 774 |
|
| 775 |
-
/*
|
| 776 |
.chat-preview {
|
| 777 |
-
max-height:
|
| 778 |
-
font-size:
|
| 779 |
-
padding:
|
| 780 |
-
margin:
|
| 781 |
border-radius: 4px !important;
|
| 782 |
background-color: #f1f3f4 !important;
|
| 783 |
overflow-y: auto !important;
|
| 784 |
-webkit-overflow-scrolling: touch !important;
|
| 785 |
}
|
| 786 |
|
| 787 |
-
/*
|
| 788 |
.success-message {
|
| 789 |
-
font-size:
|
| 790 |
-
padding:
|
| 791 |
text-align: center !important;
|
| 792 |
-
margin:
|
| 793 |
background-color: #d1e7dd !important;
|
| 794 |
-
border-radius:
|
| 795 |
color: #0f5132 !important;
|
| 796 |
}
|
| 797 |
|
|
@@ -799,32 +804,48 @@ footer {display: none !important;}
|
|
| 799 |
input, textarea, select {
|
| 800 |
font-size: 16px !important;
|
| 801 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 802 |
}
|
| 803 |
|
| 804 |
-
/* Extra
|
| 805 |
@media (max-width: 480px) {
|
| 806 |
.gradio-container {
|
| 807 |
-
padding:
|
| 808 |
}
|
| 809 |
|
| 810 |
.gradio-container > .gr-markdown:first-child {
|
| 811 |
-
font-size:
|
| 812 |
-
padding: 6px !important;
|
|
|
|
| 813 |
}
|
| 814 |
|
| 815 |
#chatbot_conversation {
|
| 816 |
-
padding:
|
|
|
|
| 817 |
}
|
| 818 |
|
| 819 |
.gr-button {
|
| 820 |
-
padding:
|
| 821 |
-
font-size:
|
| 822 |
-
min-height:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
}
|
| 824 |
}
|
| 825 |
"""
|
| 826 |
|
| 827 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 828 |
gr.Markdown("Ställ din fråga om ChargeNodes produkter och tjänster nedan. Om du inte gillar botten, så ring oss gärna på 010 – 205 10 55")
|
| 829 |
|
| 830 |
# Chat interface
|
|
|
|
| 605 |
# --- Gradio UI ---
|
| 606 |
initial_chat = [{"role": "assistant", "content": "Detta är ChargeNode's AI bot. Hur kan jag hjälpa dig idag?"}]
|
| 607 |
|
| 608 |
+
# BEHÅLL DESKTOP LAYOUT - FIXA MOBIL-SCROLLING OCH LAYOUT
|
| 609 |
custom_css = """
|
| 610 |
/* DESKTOP LAYOUT - BEHÅLLS EXAKT SOM URSPRUNGLIG */
|
| 611 |
body {background-color: #f7f7f7; font-family: Arial, sans-serif; margin: 0; padding: 0;}
|
|
|
|
| 629 |
.gradio-container .footer {display: none !important;}
|
| 630 |
.gradio-container .gr-footer {display: none !important;}
|
| 631 |
|
| 632 |
+
/* MOBIL-ANPASSNINGAR - FOKUS PÅ SCROLLNING OCH KOMPAKT LAYOUT */
|
| 633 |
@media (max-width: 768px) {
|
| 634 |
+
/* Tillåt scrollning på mobil */
|
| 635 |
html, body {
|
| 636 |
width: 100% !important;
|
| 637 |
height: 100% !important;
|
| 638 |
margin: 0 !important;
|
| 639 |
padding: 0 !important;
|
| 640 |
+
overflow-y: auto !important; /* Viktigt: tillåt vertikal scrollning */
|
| 641 |
+
overflow-x: hidden !important;
|
| 642 |
background-color: #ffffff !important;
|
| 643 |
-webkit-overflow-scrolling: touch !important;
|
| 644 |
}
|
| 645 |
|
| 646 |
+
/* Gradio app ska tillåta scrollning */
|
| 647 |
.gradio-app {
|
| 648 |
width: 100% !important;
|
| 649 |
+
min-height: 100vh !important; /* min-height istället för height */
|
| 650 |
margin: 0 !important;
|
| 651 |
padding: 0 !important;
|
| 652 |
+
overflow-y: auto !important;
|
| 653 |
}
|
| 654 |
|
| 655 |
+
/* Container för mobil - scrollbar layout */
|
| 656 |
.gradio-container {
|
| 657 |
+
position: relative !important; /* Inte absolute - tillåt naturlig scroll */
|
|
|
|
|
|
|
|
|
|
|
|
|
| 658 |
width: 100% !important;
|
| 659 |
+
min-height: 100vh !important; /* min-height för att tillåta längre innehåll */
|
| 660 |
max-width: none !important;
|
| 661 |
margin: 0 !important;
|
| 662 |
padding: 8px !important;
|
|
|
|
| 668 |
box-sizing: border-box !important;
|
| 669 |
}
|
| 670 |
|
| 671 |
+
/* Minimera header-utrymme */
|
| 672 |
.gradio-container > .gr-markdown:first-child {
|
| 673 |
flex-shrink: 0 !important;
|
| 674 |
+
font-size: 12px !important;
|
| 675 |
+
line-height: 1.2 !important;
|
| 676 |
+
margin: 0 0 4px 0 !important; /* Mycket mindre margin */
|
| 677 |
+
padding: 4px 8px !important; /* Mindre padding */
|
| 678 |
background-color: #f8f9fa !important;
|
| 679 |
+
border-radius: 4px !important;
|
| 680 |
text-align: center !important;
|
| 681 |
}
|
| 682 |
|
| 683 |
+
/* Chat-gruppar kan sträcka sig */
|
| 684 |
.gradio-container > .gr-group {
|
| 685 |
flex: 1 !important;
|
| 686 |
display: flex !important;
|
| 687 |
flex-direction: column !important;
|
|
|
|
| 688 |
margin: 0 !important;
|
| 689 |
padding: 0 !important;
|
| 690 |
+
min-height: 0 !important;
|
| 691 |
}
|
| 692 |
|
| 693 |
+
/* Kompakt chatbot med mer innehåll synligt */
|
| 694 |
#chatbot_conversation {
|
| 695 |
flex: 1 !important;
|
| 696 |
+
min-height: 280px !important; /* Större min-höjd så första meddelandet syns bättre */
|
| 697 |
+
max-height: 400px !important; /* Begränsa så input syns */
|
| 698 |
+
margin: 0 0 4px 0 !important; /* Minimal margin */
|
| 699 |
+
padding: 6px !important; /* Mindre padding */
|
| 700 |
overflow-y: auto !important;
|
| 701 |
border: 1px solid #e9ecef !important;
|
| 702 |
+
border-radius: 4px !important;
|
| 703 |
background-color: #ffffff !important;
|
| 704 |
-webkit-overflow-scrolling: touch !important;
|
| 705 |
}
|
| 706 |
|
| 707 |
+
/* Minska utrymme i chatbot-meddelanden */
|
| 708 |
+
#chatbot_conversation .message {
|
| 709 |
+
margin: 2px 0 !important;
|
| 710 |
+
padding: 4px !important;
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
/* Input och knappar - kompakta */
|
| 714 |
.gradio-container .gr-row {
|
| 715 |
flex-shrink: 0 !important;
|
| 716 |
+
margin: 2px 0 !important; /* Mindre margins */
|
| 717 |
}
|
| 718 |
|
| 719 |
/* Textbox för mobil */
|
|
|
|
| 723 |
|
| 724 |
.gr-textbox textarea {
|
| 725 |
font-size: 16px !important;
|
| 726 |
+
padding: 8px !important; /* Mindre padding */
|
| 727 |
+
border: 1px solid #e9ecef !important;
|
| 728 |
+
border-radius: 4px !important;
|
| 729 |
resize: none !important;
|
| 730 |
width: 100% !important;
|
| 731 |
box-sizing: border-box !important;
|
| 732 |
+
min-height: 38px !important; /* Mindre höjd */
|
| 733 |
}
|
| 734 |
|
| 735 |
.gr-textbox textarea:focus {
|
|
|
|
| 737 |
outline: none !important;
|
| 738 |
}
|
| 739 |
|
| 740 |
+
/* Kompakta knappar */
|
| 741 |
.gr-button {
|
| 742 |
width: 100% !important;
|
| 743 |
+
padding: 10px 12px !important; /* Mindre padding */
|
| 744 |
+
margin: 2px 0 !important; /* Mindre margin */
|
| 745 |
+
font-size: 14px !important;
|
| 746 |
+
min-height: 40px !important; /* Mindre höjd */
|
| 747 |
+
border-radius: 4px !important;
|
| 748 |
box-sizing: border-box !important;
|
| 749 |
white-space: nowrap !important;
|
| 750 |
overflow: hidden !important;
|
| 751 |
text-overflow: ellipsis !important;
|
| 752 |
}
|
| 753 |
|
| 754 |
+
/* Knapp-kolumner */
|
| 755 |
.gradio-container .gr-column {
|
| 756 |
width: 100% !important;
|
| 757 |
margin: 0 !important;
|
| 758 |
+
padding: 0 1px !important;
|
| 759 |
}
|
| 760 |
|
| 761 |
+
/* Kompakt support-formulär */
|
| 762 |
.gr-form {
|
| 763 |
+
padding: 6px !important;
|
| 764 |
+
margin: 2px 0 !important;
|
| 765 |
+
border-radius: 4px !important;
|
| 766 |
background-color: #f8f9fa !important;
|
| 767 |
}
|
| 768 |
|
| 769 |
.gr-form .gr-textbox {
|
| 770 |
+
margin: 2px 0 !important;
|
| 771 |
}
|
| 772 |
|
| 773 |
.gr-form .gr-textbox input,
|
| 774 |
.gr-form .gr-textbox textarea {
|
| 775 |
font-size: 16px !important;
|
| 776 |
+
padding: 8px !important;
|
| 777 |
border-radius: 4px !important;
|
| 778 |
}
|
| 779 |
|
| 780 |
+
/* Kompakt chat preview */
|
| 781 |
.chat-preview {
|
| 782 |
+
max-height: 80px !important;
|
| 783 |
+
font-size: 11px !important;
|
| 784 |
+
padding: 6px !important;
|
| 785 |
+
margin: 4px 0 !important;
|
| 786 |
border-radius: 4px !important;
|
| 787 |
background-color: #f1f3f4 !important;
|
| 788 |
overflow-y: auto !important;
|
| 789 |
-webkit-overflow-scrolling: touch !important;
|
| 790 |
}
|
| 791 |
|
| 792 |
+
/* Kompakt success message */
|
| 793 |
.success-message {
|
| 794 |
+
font-size: 14px !important;
|
| 795 |
+
padding: 8px !important;
|
| 796 |
text-align: center !important;
|
| 797 |
+
margin: 8px 0 !important;
|
| 798 |
background-color: #d1e7dd !important;
|
| 799 |
+
border-radius: 4px !important;
|
| 800 |
color: #0f5132 !important;
|
| 801 |
}
|
| 802 |
|
|
|
|
| 804 |
input, textarea, select {
|
| 805 |
font-size: 16px !important;
|
| 806 |
}
|
| 807 |
+
|
| 808 |
+
/* Se till att support-vyn börjar från toppen */
|
| 809 |
+
.gradio-container > .gr-group[style*="visible: true"] {
|
| 810 |
+
scroll-margin-top: 0 !important;
|
| 811 |
+
}
|
| 812 |
}
|
| 813 |
|
| 814 |
+
/* Extra kompakt för mycket små skärmar */
|
| 815 |
@media (max-width: 480px) {
|
| 816 |
.gradio-container {
|
| 817 |
+
padding: 4px !important;
|
| 818 |
}
|
| 819 |
|
| 820 |
.gradio-container > .gr-markdown:first-child {
|
| 821 |
+
font-size: 11px !important;
|
| 822 |
+
padding: 3px 6px !important;
|
| 823 |
+
margin: 0 0 3px 0 !important;
|
| 824 |
}
|
| 825 |
|
| 826 |
#chatbot_conversation {
|
| 827 |
+
padding: 4px !important;
|
| 828 |
+
min-height: 250px !important;
|
| 829 |
}
|
| 830 |
|
| 831 |
.gr-button {
|
| 832 |
+
padding: 8px 10px !important;
|
| 833 |
+
font-size: 13px !important;
|
| 834 |
+
min-height: 36px !important;
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
.gr-textbox textarea {
|
| 838 |
+
padding: 6px !important;
|
| 839 |
+
min-height: 32px !important;
|
| 840 |
}
|
| 841 |
}
|
| 842 |
"""
|
| 843 |
|
| 844 |
+
with gr.Blocks(
|
| 845 |
+
css=custom_css,
|
| 846 |
+
title="ChargeNode Kundtjänst",
|
| 847 |
+
head='<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">'
|
| 848 |
+
) as app:
|
| 849 |
gr.Markdown("Ställ din fråga om ChargeNodes produkter och tjänster nedan. Om du inte gillar botten, så ring oss gärna på 010 – 205 10 55")
|
| 850 |
|
| 851 |
# Chat interface
|