Update app.py
Browse files
app.py
CHANGED
@@ -141,7 +141,7 @@ def plot_metrics(metrics):
|
|
141 |
plt.close()
|
142 |
return 'rag_plot.png'
|
143 |
|
144 |
-
# Gradio interface with buttons
|
145 |
def chat_interface(query):
|
146 |
try:
|
147 |
response, retrieved_faqs, metrics = rag_process(query)
|
@@ -161,23 +161,65 @@ def chat_interface(query):
|
|
161 |
except Exception as e:
|
162 |
return f"Error: {str(e)}", "", "", None
|
163 |
|
164 |
-
# Dark theme CSS
|
165 |
custom_css = """
|
166 |
-
body {
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
"""
|
171 |
|
172 |
# Get unique questions for buttons (after cleanup)
|
173 |
unique_questions = faq_data['question'].tolist()
|
174 |
|
175 |
with gr.Blocks(css=custom_css) as demo:
|
176 |
-
gr.Markdown("# Customer Experience Bot Demo")
|
177 |
-
gr.Markdown("Select a question to see the bot's response, retrieved FAQs, and call center data cleanup stats.")
|
178 |
|
179 |
-
#
|
180 |
-
with gr.Row():
|
181 |
for question in unique_questions:
|
182 |
gr.Button(question).click(
|
183 |
fn=chat_interface,
|
@@ -190,9 +232,11 @@ with gr.Blocks(css=custom_css) as demo:
|
|
190 |
]
|
191 |
)
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
197 |
|
198 |
demo.launch()
|
|
|
141 |
plt.close()
|
142 |
return 'rag_plot.png'
|
143 |
|
144 |
+
# Gradio interface with buttons and single output panel
|
145 |
def chat_interface(query):
|
146 |
try:
|
147 |
response, retrieved_faqs, metrics = rag_process(query)
|
|
|
161 |
except Exception as e:
|
162 |
return f"Error: {str(e)}", "", "", None
|
163 |
|
164 |
+
# Dark theme CSS with improved styling
|
165 |
custom_css = """
|
166 |
+
body {
|
167 |
+
background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
|
168 |
+
color: #e0e0e0;
|
169 |
+
font-family: 'Arial', sans-serif;
|
170 |
+
}
|
171 |
+
.gr-box {
|
172 |
+
background: #3a3a3a;
|
173 |
+
border: 1px solid #4a4a4a;
|
174 |
+
border-radius: 8px;
|
175 |
+
padding: 15px;
|
176 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
177 |
+
}
|
178 |
+
.gr-button {
|
179 |
+
background: #1e90ff;
|
180 |
+
color: white;
|
181 |
+
border-radius: 5px;
|
182 |
+
padding: 10px 20px;
|
183 |
+
margin: 5px;
|
184 |
+
transition: background 0.3s ease;
|
185 |
+
}
|
186 |
+
.gr-button:hover {
|
187 |
+
background: #1c86ee;
|
188 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
189 |
+
}
|
190 |
+
.gr-textbox {
|
191 |
+
background: #2f2f2f;
|
192 |
+
color: #e0e0e0;
|
193 |
+
border: 1px solid #4a4a4a;
|
194 |
+
border-radius: 5px;
|
195 |
+
}
|
196 |
+
#button-container {
|
197 |
+
display: flex;
|
198 |
+
flex-wrap: wrap;
|
199 |
+
gap: 10px;
|
200 |
+
justify-content: center;
|
201 |
+
padding: 20px;
|
202 |
+
background: #252525;
|
203 |
+
border-radius: 8px;
|
204 |
+
margin-bottom: 20px;
|
205 |
+
}
|
206 |
+
#output-container {
|
207 |
+
background: #303030;
|
208 |
+
padding: 20px;
|
209 |
+
border-radius: 8px;
|
210 |
+
margin: 10px 0;
|
211 |
+
}
|
212 |
"""
|
213 |
|
214 |
# Get unique questions for buttons (after cleanup)
|
215 |
unique_questions = faq_data['question'].tolist()
|
216 |
|
217 |
with gr.Blocks(css=custom_css) as demo:
|
218 |
+
gr.Markdown("# Customer Experience Bot Demo", elem_classes="text-center")
|
219 |
+
gr.Markdown("Select a question to see the bot's response, retrieved FAQs, and call center data cleanup stats.", elem_classes="text-center")
|
220 |
|
221 |
+
# Button container for questions
|
222 |
+
with gr.Row(elem_id="button-container"):
|
223 |
for question in unique_questions:
|
224 |
gr.Button(question).click(
|
225 |
fn=chat_interface,
|
|
|
232 |
]
|
233 |
)
|
234 |
|
235 |
+
# Single output panel
|
236 |
+
with gr.Column(elem_id="output-container"):
|
237 |
+
response_output = gr.Textbox(label="Bot Response")
|
238 |
+
faq_output = gr.Textbox(label="Retrieved FAQs")
|
239 |
+
cleanup_output = gr.Textbox(label="Data Cleanup Stats")
|
240 |
+
plot_output = gr.Image(label="RAG Pipeline Metrics")
|
241 |
|
242 |
demo.launch()
|