Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -917,15 +917,15 @@ def create_gradio_app():
|
|
| 917 |
:root {
|
| 918 |
--primary-color: #FF000C;
|
| 919 |
--secondary-color: #212832;
|
| 920 |
-
--background-color:
|
| 921 |
-
--card-color:
|
| 922 |
--text-color: var(--body-text-color);
|
| 923 |
--border-radius: 12px;
|
| 924 |
--shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
| 925 |
}
|
| 926 |
|
| 927 |
.app-header {
|
| 928 |
-
background-color:
|
| 929 |
padding: 20px;
|
| 930 |
border-radius: var(--border-radius);
|
| 931 |
margin-bottom: 20px;
|
|
@@ -940,14 +940,14 @@ def create_gradio_app():
|
|
| 940 |
}
|
| 941 |
|
| 942 |
.app-title {
|
| 943 |
-
color:
|
| 944 |
margin: 0;
|
| 945 |
font-size: 24px;
|
| 946 |
font-weight: 600;
|
| 947 |
}
|
| 948 |
|
| 949 |
.status-card, .catalog-card, .chat-card {
|
| 950 |
-
background-color:
|
| 951 |
border-radius: var(--border-radius);
|
| 952 |
padding: 15px;
|
| 953 |
margin-bottom: 20px;
|
|
@@ -972,9 +972,10 @@ def create_gradio_app():
|
|
| 972 |
}
|
| 973 |
|
| 974 |
.bot-message {
|
| 975 |
-
background-color:
|
| 976 |
color: var(--text-color);
|
| 977 |
margin-right: auto;
|
|
|
|
| 978 |
}
|
| 979 |
|
| 980 |
.footer {
|
|
@@ -997,14 +998,60 @@ def create_gradio_app():
|
|
| 997 |
.action-button:hover {
|
| 998 |
opacity: 0.9;
|
| 999 |
}
|
| 1000 |
-
|
| 1001 |
.product-recommendation {
|
| 1002 |
-
background-color:
|
| 1003 |
border-left: 4px solid var(--primary-color);
|
| 1004 |
padding: 15px;
|
| 1005 |
margin-top: 20px;
|
| 1006 |
border-radius: 8px;
|
| 1007 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1008 |
"""
|
| 1009 |
|
| 1010 |
# Create Gradio interface
|
|
@@ -1024,49 +1071,62 @@ def create_gradio_app():
|
|
| 1024 |
# Chat Tab
|
| 1025 |
with gr.Tab("Chat"):
|
| 1026 |
with gr.Row():
|
| 1027 |
-
with gr.Column(scale=
|
| 1028 |
-
#
|
| 1029 |
-
gr.HTML(
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
| 1036 |
-
|
| 1037 |
-
|
| 1038 |
-
|
| 1039 |
-
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
-
|
| 1043 |
-
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
<
|
| 1064 |
-
|
| 1065 |
-
<
|
| 1066 |
-
<
|
| 1067 |
-
|
| 1068 |
-
|
| 1069 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1070 |
|
| 1071 |
# Admin settings
|
| 1072 |
with gr.Accordion("Admin Settings", open=False):
|
|
@@ -1091,14 +1151,41 @@ def create_gradio_app():
|
|
| 1091 |
process_url_btn = gr.Button("Process PDF from URL", elem_classes="action-button")
|
| 1092 |
result_text = gr.Textbox(label="Processing Result")
|
| 1093 |
|
| 1094 |
-
# Analytics
|
| 1095 |
with gr.Accordion("Analytics Dashboard", open=False):
|
| 1096 |
# Product query distribution chart
|
| 1097 |
product_chart = gr.Plot(label="Product Query Distribution")
|
| 1098 |
-
|
| 1099 |
# Daily query trend chart
|
| 1100 |
trend_chart = gr.Plot(label="Daily Query Trend")
|
| 1101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1102 |
# Guided Product Discovery Tab
|
| 1103 |
with gr.Tab("Guided Product Discovery"):
|
| 1104 |
with gr.Row():
|
|
|
|
| 917 |
:root {
|
| 918 |
--primary-color: #FF000C;
|
| 919 |
--secondary-color: #212832;
|
| 920 |
+
--background-color: white;
|
| 921 |
+
--card-color: white;
|
| 922 |
--text-color: var(--body-text-color);
|
| 923 |
--border-radius: 12px;
|
| 924 |
--shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
| 925 |
}
|
| 926 |
|
| 927 |
.app-header {
|
| 928 |
+
background-color: white;
|
| 929 |
padding: 20px;
|
| 930 |
border-radius: var(--border-radius);
|
| 931 |
margin-bottom: 20px;
|
|
|
|
| 940 |
}
|
| 941 |
|
| 942 |
.app-title {
|
| 943 |
+
color: var(--primary-color);
|
| 944 |
margin: 0;
|
| 945 |
font-size: 24px;
|
| 946 |
font-weight: 600;
|
| 947 |
}
|
| 948 |
|
| 949 |
.status-card, .catalog-card, .chat-card {
|
| 950 |
+
background-color: white;
|
| 951 |
border-radius: var(--border-radius);
|
| 952 |
padding: 15px;
|
| 953 |
margin-bottom: 20px;
|
|
|
|
| 972 |
}
|
| 973 |
|
| 974 |
.bot-message {
|
| 975 |
+
background-color: white;
|
| 976 |
color: var(--text-color);
|
| 977 |
margin-right: auto;
|
| 978 |
+
border: 1px solid #e0e0e0;
|
| 979 |
}
|
| 980 |
|
| 981 |
.footer {
|
|
|
|
| 998 |
.action-button:hover {
|
| 999 |
opacity: 0.9;
|
| 1000 |
}
|
| 1001 |
+
|
| 1002 |
.product-recommendation {
|
| 1003 |
+
background-color: white;
|
| 1004 |
border-left: 4px solid var(--primary-color);
|
| 1005 |
padding: 15px;
|
| 1006 |
margin-top: 20px;
|
| 1007 |
border-radius: 8px;
|
| 1008 |
}
|
| 1009 |
+
|
| 1010 |
+
.quick-tips {
|
| 1011 |
+
margin-bottom: 30px;
|
| 1012 |
+
}
|
| 1013 |
+
|
| 1014 |
+
.quick-tips h2 {
|
| 1015 |
+
font-size: 20px;
|
| 1016 |
+
margin-bottom: 16px;
|
| 1017 |
+
border-bottom: 1px solid #e0e0e0;
|
| 1018 |
+
padding-bottom: 8px;
|
| 1019 |
+
}
|
| 1020 |
+
|
| 1021 |
+
.tip-card {
|
| 1022 |
+
background-color: white;
|
| 1023 |
+
border: 1px solid #e0e0e0;
|
| 1024 |
+
border-radius: var(--border-radius);
|
| 1025 |
+
margin-bottom: 12px;
|
| 1026 |
+
padding: 16px;
|
| 1027 |
+
display: flex;
|
| 1028 |
+
align-items: flex-start;
|
| 1029 |
+
}
|
| 1030 |
+
|
| 1031 |
+
.tip-icon {
|
| 1032 |
+
flex-shrink: 0;
|
| 1033 |
+
margin-right: 16px;
|
| 1034 |
+
width: 24px;
|
| 1035 |
+
height: 24px;
|
| 1036 |
+
}
|
| 1037 |
+
|
| 1038 |
+
.tip-content h3 {
|
| 1039 |
+
margin: 0 0 8px 0;
|
| 1040 |
+
font-size: 16px;
|
| 1041 |
+
color: #212832;
|
| 1042 |
+
}
|
| 1043 |
+
|
| 1044 |
+
.tip-content p {
|
| 1045 |
+
margin: 0;
|
| 1046 |
+
font-size: 14px;
|
| 1047 |
+
color: #666;
|
| 1048 |
+
line-height: 1.5;
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
/* Added to ensure the sidebar is placed correctly */
|
| 1052 |
+
.sidebar {
|
| 1053 |
+
height: 100%;
|
| 1054 |
+
}
|
| 1055 |
"""
|
| 1056 |
|
| 1057 |
# Create Gradio interface
|
|
|
|
| 1071 |
# Chat Tab
|
| 1072 |
with gr.Tab("Chat"):
|
| 1073 |
with gr.Row():
|
| 1074 |
+
with gr.Column(scale=1, elem_classes="sidebar"):
|
| 1075 |
+
# Quick Tips
|
| 1076 |
+
gr.HTML("""
|
| 1077 |
+
<div class="quick-tips">
|
| 1078 |
+
<h2>Quick Tips</h2>
|
| 1079 |
+
<div class="tip-card">
|
| 1080 |
+
<div class="tip-icon search-icon">
|
| 1081 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" stroke="#FF000C" stroke-width="2" d="M15 15l6 6M10 17a7 7 0 100-14 7 7 0 000 14z"></path></svg>
|
| 1082 |
+
</div>
|
| 1083 |
+
<div class="tip-content">
|
| 1084 |
+
<h3>Product Search</h3>
|
| 1085 |
+
<p>Ask about specific products like "Tell me about circuit breakers" or "What are the specifications of motor starters?"</p>
|
| 1086 |
+
</div>
|
| 1087 |
+
</div>
|
| 1088 |
+
|
| 1089 |
+
<div class="tip-card">
|
| 1090 |
+
<div class="tip-icon warning-icon">
|
| 1091 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" stroke="#FF000C" stroke-width="2" d="M12 9v4M12 17.5v.5M6.6 18h10.8a1 1 0 00.9-1.45L13.2 6.55a1 1 0 00-1.8 0L6.3 16.55A1 1 0 006.6 18z"></path></svg>
|
| 1092 |
+
</div>
|
| 1093 |
+
<div class="tip-content">
|
| 1094 |
+
<h3>Troubleshooting</h3>
|
| 1095 |
+
<p>Get help with issues: "How do I troubleshoot a circuit breaker that keeps tripping?" or "Common problems with contactors"</p>
|
| 1096 |
+
</div>
|
| 1097 |
+
</div>
|
| 1098 |
+
|
| 1099 |
+
<div class="tip-card">
|
| 1100 |
+
<div class="tip-icon doc-icon">
|
| 1101 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" stroke="#FF000C" stroke-width="2" d="M14 3v4h4M9 3h8l4 4v12a2 2 0 01-2 2H9a2 2 0 01-2-2V5a2 2 0 012-2zm1 8h6m-6 4h6"></path></svg>
|
| 1102 |
+
</div>
|
| 1103 |
+
<div class="tip-content">
|
| 1104 |
+
<h3>Documentation</h3>
|
| 1105 |
+
<p>Find documentation: "Where can I find the manual for X product?" or "Show me installation instructions for Y"</p>
|
| 1106 |
+
</div>
|
| 1107 |
+
</div>
|
| 1108 |
+
|
| 1109 |
+
<div class="tip-card">
|
| 1110 |
+
<div class="tip-icon image-icon">
|
| 1111 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" stroke="#FF000C" stroke-width="2" d="M5 3h14a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2zm0 16l4-4 2 2 4-4 4 4M8 10a2 2 0 100-4 2 2 0 000 4z"></path></svg>
|
| 1112 |
+
</div>
|
| 1113 |
+
<div class="tip-content">
|
| 1114 |
+
<h3>Images</h3>
|
| 1115 |
+
<p>Ask to see product images: "Show me images of circuit breakers" or "What does product X look like?"</p>
|
| 1116 |
+
</div>
|
| 1117 |
+
</div>
|
| 1118 |
+
|
| 1119 |
+
<div class="tip-card">
|
| 1120 |
+
<div class="tip-icon settings-icon">
|
| 1121 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" stroke="#FF000C" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><circle cx="12" cy="12" r="3" stroke="#FF000C" stroke-width="2" fill="none"></circle></svg>
|
| 1122 |
+
</div>
|
| 1123 |
+
<div class="tip-content">
|
| 1124 |
+
<h3>Settings</h3>
|
| 1125 |
+
<p>Visit the Settings page to configure your API credentials, database settings, and image folder path.</p>
|
| 1126 |
+
</div>
|
| 1127 |
+
</div>
|
| 1128 |
+
</div>
|
| 1129 |
+
""")
|
| 1130 |
|
| 1131 |
# Admin settings
|
| 1132 |
with gr.Accordion("Admin Settings", open=False):
|
|
|
|
| 1151 |
process_url_btn = gr.Button("Process PDF from URL", elem_classes="action-button")
|
| 1152 |
result_text = gr.Textbox(label="Processing Result")
|
| 1153 |
|
| 1154 |
+
# Analytics dashboard
|
| 1155 |
with gr.Accordion("Analytics Dashboard", open=False):
|
| 1156 |
# Product query distribution chart
|
| 1157 |
product_chart = gr.Plot(label="Product Query Distribution")
|
|
|
|
| 1158 |
# Daily query trend chart
|
| 1159 |
trend_chart = gr.Plot(label="Daily Query Trend")
|
| 1160 |
+
|
| 1161 |
+
with gr.Column(scale=3):
|
| 1162 |
+
# Chat interface with custom styling
|
| 1163 |
+
gr.HTML('<div class="content-card">')
|
| 1164 |
+
|
| 1165 |
+
chatbot = gr.Chatbot(
|
| 1166 |
+
value=[],
|
| 1167 |
+
elem_id="chatbot",
|
| 1168 |
+
height=500,
|
| 1169 |
+
show_copy_button=True,
|
| 1170 |
+
avatar_images=[
|
| 1171 |
+
"https://ui-avatars.com/api/?name=You&background=0D8ABC&color=fff",
|
| 1172 |
+
"https://ui-avatars.com/api/?name=Ginnie&background=FF000C&color=fff"
|
| 1173 |
+
]
|
| 1174 |
+
)
|
| 1175 |
+
|
| 1176 |
+
with gr.Row():
|
| 1177 |
+
msg = gr.Textbox(
|
| 1178 |
+
placeholder="Ask about ABB products...",
|
| 1179 |
+
scale=8,
|
| 1180 |
+
show_label=False
|
| 1181 |
+
)
|
| 1182 |
+
send_btn = gr.Button("Send", elem_classes="action-button", scale=1)
|
| 1183 |
+
clear_btn = gr.Button("Clear", elem_classes="action-button", scale=1)
|
| 1184 |
+
|
| 1185 |
+
product_gallery = gr.HTML()
|
| 1186 |
+
|
| 1187 |
+
gr.HTML('</div>')
|
| 1188 |
+
|
| 1189 |
# Guided Product Discovery Tab
|
| 1190 |
with gr.Tab("Guided Product Discovery"):
|
| 1191 |
with gr.Row():
|