Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Function to mock the VLLM interpretation and return structured HTML
|
| 4 |
+
def diagnose_router(image):
|
| 5 |
+
# Structured diagnosis and solution
|
| 6 |
+
result = {
|
| 7 |
+
"Issue_Description": "Internet connectivity problem - The Internet LED is blinking amber.",
|
| 8 |
+
"Root_Cause_Analysis": {
|
| 9 |
+
"LED_Analysis": {
|
| 10 |
+
"Color": "Amber",
|
| 11 |
+
"Pattern": "Blinking",
|
| 12 |
+
"Indicates": "The router is unable to establish a connection with the ISP."
|
| 13 |
+
},
|
| 14 |
+
"Error_Code": "WAN PPPoE Timeout",
|
| 15 |
+
"Possible_Cause": "This error suggests the router cannot authenticate with the ISP's server, likely due to incorrect login credentials or an ISP-side issue."
|
| 16 |
+
},
|
| 17 |
+
"Step_by_Step_Troubleshooting": {
|
| 18 |
+
"Step_1": {
|
| 19 |
+
"Action": "Verify Ethernet Cable Connection",
|
| 20 |
+
"Details": "Ensure that the Ethernet cable is securely plugged into the modem's LAN port and the router's WAN port.",
|
| 21 |
+
"Expected Outcome": "Ethernet cable is securely connected, and the LED light remains stable."
|
| 22 |
+
},
|
| 23 |
+
"Step_2": {
|
| 24 |
+
"Action": "Restart Both Modem and Router",
|
| 25 |
+
"Details": "Unplug both the modem and router from their power sources, wait for 30 seconds, then plug them back in starting with the modem.",
|
| 26 |
+
"Expected Outcome": "The router should reattempt to establish a connection with the ISP."
|
| 27 |
+
},
|
| 28 |
+
"Step_3": {
|
| 29 |
+
"Action": "Verify ISP Login Credentials",
|
| 30 |
+
"Details": "Access the router settings through its web interface and check the PPPoE login credentials (username and password) provided by your ISP.",
|
| 31 |
+
"Expected Outcome": "Correct credentials should resolve the authentication issue."
|
| 32 |
+
},
|
| 33 |
+
"Step_4": {
|
| 34 |
+
"Action": "Contact ISP Support",
|
| 35 |
+
"Details": "If the above steps don't work, contact your ISP to check for any issues on their end such as outages or account problems.",
|
| 36 |
+
"Expected Outcome": "ISP support will help resolve server authentication issues or provide further guidance."
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"Recommended_Actions": {
|
| 40 |
+
"Immediate_Action": "Reconnect cables and restart devices.",
|
| 41 |
+
"If_Unresolved": "Check ISP login credentials and contact ISP if needed.",
|
| 42 |
+
"Preventative_Measure": "Ensure router firmware is up-to-date to prevent known issues."
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
# Generate HTML content for structured display
|
| 47 |
+
html_output = f"""
|
| 48 |
+
<div style="font-family: Arial, sans-serif; color: #333;">
|
| 49 |
+
<h2>Router Diagnosis</h2>
|
| 50 |
+
<h3>Issue Description</h3>
|
| 51 |
+
<p><strong>{result['Issue_Description']}</strong></p>
|
| 52 |
+
|
| 53 |
+
<h3>Root Cause Analysis</h3>
|
| 54 |
+
<ul>
|
| 55 |
+
<li><strong>LED Color:</strong> {result['Root_Cause_Analysis']['LED_Analysis']['Color']}</li>
|
| 56 |
+
<li><strong>LED Pattern:</strong> {result['Root_Cause_Analysis']['LED_Analysis']['Pattern']}</li>
|
| 57 |
+
<li><strong>Indicates:</strong> {result['Root_Cause_Analysis']['LED_Analysis']['Indicates']}</li>
|
| 58 |
+
<li><strong>Error Code:</strong> {result['Root_Cause_Analysis']['Error_Code']}</li>
|
| 59 |
+
<li><strong>Possible Cause:</strong> {result['Root_Cause_Analysis']['Possible_Cause']}</li>
|
| 60 |
+
</ul>
|
| 61 |
+
|
| 62 |
+
<h3>Step-by-Step Troubleshooting</h3>
|
| 63 |
+
<ol>
|
| 64 |
+
"""
|
| 65 |
+
|
| 66 |
+
# Loop through each step in the troubleshooting process
|
| 67 |
+
for step_key, step_data in result["Step_by_Step_Troubleshooting"].items():
|
| 68 |
+
html_output += f"""
|
| 69 |
+
<li><strong>{step_data['Action']}</strong>: {step_data['Details']}<br/>
|
| 70 |
+
<em>Expected Outcome:</em> {step_data['Expected Outcome']}</li>
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
html_output += """
|
| 74 |
+
</ol>
|
| 75 |
+
|
| 76 |
+
<h3>Recommended Actions</h3>
|
| 77 |
+
<ul>
|
| 78 |
+
<li><strong>Immediate Action:</strong> {result['Recommended_Actions']['Immediate_Action']}</li>
|
| 79 |
+
<li><strong>If Unresolved:</strong> {result['Recommended_Actions']['If_Unresolved']}</li>
|
| 80 |
+
<li><strong>Preventative Measure:</strong> {result['Recommended_Actions']['Preventative_Measure']}</li>
|
| 81 |
+
</ul>
|
| 82 |
+
</div>
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
return html_output
|
| 86 |
+
|
| 87 |
+
# Gradio UI
|
| 88 |
+
interface = gr.Interface(
|
| 89 |
+
fn=diagnose_router,
|
| 90 |
+
inputs=gr.Image(type="pil", label="Upload an image of the faulty router"),
|
| 91 |
+
outputs=gr.HTML(),
|
| 92 |
+
title="Structured Router Diagnosis",
|
| 93 |
+
description="Upload a photo of your router to receive a professional diagnosis and troubleshooting steps displayed in a structured, easy-to-read format."
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
# Launch the UI
|
| 97 |
+
interface.launch()
|