Spaces:
Sleeping
Sleeping
Update ui/gradio_interface.py
Browse files- ui/gradio_interface.py +27 -23
ui/gradio_interface.py
CHANGED
|
@@ -43,7 +43,8 @@ class DebugGenieUI:
|
|
| 43 |
# Validate inputs
|
| 44 |
if not error_text and screenshot is None:
|
| 45 |
return (
|
| 46 |
-
[
|
|
|
|
| 47 |
"<div>No analysis performed.</div>",
|
| 48 |
"<div>No visualization available.</div>",
|
| 49 |
None,
|
|
@@ -149,7 +150,8 @@ class DebugGenieUI:
|
|
| 149 |
except Exception as e:
|
| 150 |
logger.error(f"Analysis failed: {e}")
|
| 151 |
return (
|
| 152 |
-
[
|
|
|
|
| 153 |
f"<div class='error'>Error: {str(e)}</div>",
|
| 154 |
"<div>Visualization unavailable</div>",
|
| 155 |
None,
|
|
@@ -193,24 +195,8 @@ def create_interface(backend: DebugBackend):
|
|
| 193 |
"""Create the main Gradio interface."""
|
| 194 |
ui = DebugGenieUI(backend)
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
theme=gr.themes.Soft(
|
| 199 |
-
primary_hue="blue",
|
| 200 |
-
secondary_hue="purple"
|
| 201 |
-
),
|
| 202 |
-
css="""
|
| 203 |
-
.gradio-container {
|
| 204 |
-
font-family: 'Inter', sans-serif;
|
| 205 |
-
}
|
| 206 |
-
.error {
|
| 207 |
-
color: red;
|
| 208 |
-
padding: 16px;
|
| 209 |
-
background: #fee;
|
| 210 |
-
border-radius: 8px;
|
| 211 |
-
}
|
| 212 |
-
"""
|
| 213 |
-
) as demo:
|
| 214 |
|
| 215 |
gr.Markdown(
|
| 216 |
"""
|
|
@@ -265,6 +251,7 @@ def create_interface(backend: DebugBackend):
|
|
| 265 |
|
| 266 |
with gr.Tabs():
|
| 267 |
with gr.Tab("π¬ Chat"):
|
|
|
|
| 268 |
chatbot = gr.Chatbot(
|
| 269 |
height=500,
|
| 270 |
type="messages",
|
|
@@ -296,7 +283,7 @@ def create_interface(backend: DebugBackend):
|
|
| 296 |
autoplay=False
|
| 297 |
)
|
| 298 |
|
| 299 |
-
# Examples
|
| 300 |
gr.Examples(
|
| 301 |
examples=[
|
| 302 |
[
|
|
@@ -334,9 +321,26 @@ if __name__ == "__main__":
|
|
| 334 |
# Default to local backend for direct execution
|
| 335 |
backend = LocalBackend()
|
| 336 |
demo = create_interface(backend)
|
|
|
|
|
|
|
| 337 |
demo.launch(
|
| 338 |
server_name="127.0.0.1",
|
| 339 |
server_port=7860,
|
| 340 |
share=False,
|
| 341 |
-
show_error=True
|
| 342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Validate inputs
|
| 44 |
if not error_text and screenshot is None:
|
| 45 |
return (
|
| 46 |
+
[{"role": "user", "content": "Analyze error"},
|
| 47 |
+
{"role": "assistant", "content": "β Error: Please provide either an error message or a screenshot."}],
|
| 48 |
"<div>No analysis performed.</div>",
|
| 49 |
"<div>No visualization available.</div>",
|
| 50 |
None,
|
|
|
|
| 150 |
except Exception as e:
|
| 151 |
logger.error(f"Analysis failed: {e}")
|
| 152 |
return (
|
| 153 |
+
[{"role": "user", "content": "Analyze error"},
|
| 154 |
+
{"role": "assistant", "content": f"β Error: Analysis failed: {str(e)}"}],
|
| 155 |
f"<div class='error'>Error: {str(e)}</div>",
|
| 156 |
"<div>Visualization unavailable</div>",
|
| 157 |
None,
|
|
|
|
| 195 |
"""Create the main Gradio interface."""
|
| 196 |
ui = DebugGenieUI(backend)
|
| 197 |
|
| 198 |
+
# Create Blocks without theme, css parameters (moved to launch)
|
| 199 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
gr.Markdown(
|
| 202 |
"""
|
|
|
|
| 251 |
|
| 252 |
with gr.Tabs():
|
| 253 |
with gr.Tab("π¬ Chat"):
|
| 254 |
+
# Updated to use type="messages" (default in Gradio 6)
|
| 255 |
chatbot = gr.Chatbot(
|
| 256 |
height=500,
|
| 257 |
type="messages",
|
|
|
|
| 283 |
autoplay=False
|
| 284 |
)
|
| 285 |
|
| 286 |
+
# Examples - Updated to use messages format
|
| 287 |
gr.Examples(
|
| 288 |
examples=[
|
| 289 |
[
|
|
|
|
| 321 |
# Default to local backend for direct execution
|
| 322 |
backend = LocalBackend()
|
| 323 |
demo = create_interface(backend)
|
| 324 |
+
|
| 325 |
+
# Launch with theme and css parameters (moved from Blocks constructor)
|
| 326 |
demo.launch(
|
| 327 |
server_name="127.0.0.1",
|
| 328 |
server_port=7860,
|
| 329 |
share=False,
|
| 330 |
+
show_error=True,
|
| 331 |
+
theme=gr.themes.Soft(
|
| 332 |
+
primary_hue="blue",
|
| 333 |
+
secondary_hue="purple"
|
| 334 |
+
),
|
| 335 |
+
css="""
|
| 336 |
+
.gradio-container {
|
| 337 |
+
font-family: 'Inter', sans-serif;
|
| 338 |
+
}
|
| 339 |
+
.error {
|
| 340 |
+
color: red;
|
| 341 |
+
padding: 16px;
|
| 342 |
+
background: #fee;
|
| 343 |
+
border-radius: 8px;
|
| 344 |
+
}
|
| 345 |
+
"""
|
| 346 |
+
)
|