import gradio as gr import spaces # Function to mock the VLLM interpretation and return structured HTML @spaces.GPU def diagnose_router(image): # Structured diagnosis and solution result = { "Issue_Description": "Internet connectivity problem - The Internet LED is blinking amber.", "Root_Cause_Analysis": { "LED_Analysis": { "Color": "Amber", "Pattern": "Blinking", "Indicates": "The router is unable to establish a connection with the ISP." }, "Error_Code": "WAN PPPoE Timeout", "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." }, "Step_by_Step_Troubleshooting": { "Step_1": { "Action": "Verify Ethernet Cable Connection", "Details": "Ensure that the Ethernet cable is securely plugged into the modem's LAN port and the router's WAN port.", "Expected Outcome": "Ethernet cable is securely connected, and the LED light remains stable." }, "Step_2": { "Action": "Restart Both Modem and Router", "Details": "Unplug both the modem and router from their power sources, wait for 30 seconds, then plug them back in starting with the modem.", "Expected Outcome": "The router should reattempt to establish a connection with the ISP." }, "Step_3": { "Action": "Verify ISP Login Credentials", "Details": "Access the router settings through its web interface and check the PPPoE login credentials (username and password) provided by your ISP.", "Expected Outcome": "Correct credentials should resolve the authentication issue." }, "Step_4": { "Action": "Contact ISP Support", "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.", "Expected Outcome": "ISP support will help resolve server authentication issues or provide further guidance." } }, "Recommended_Actions": { "Immediate_Action": "Reconnect cables and restart devices.", "If_Unresolved": "Check ISP login credentials and contact ISP if needed.", "Preventative_Measure": "Ensure router firmware is up-to-date to prevent known issues." } } # Generate HTML content for structured display html_output = f"""

Router Diagnosis

Issue Description

{result['Issue_Description']}

Root Cause Analysis

Step-by-Step Troubleshooting

    """ # Loop through each step in the troubleshooting process for step_key, step_data in result["Step_by_Step_Troubleshooting"].items(): html_output += f"""
  1. {step_data['Action']}: {step_data['Details']}
    Expected Outcome: {step_data['Expected Outcome']}
  2. """ html_output += f"""

    Recommended Actions

    """ return html_output # Gradio UI interface = gr.Interface( fn=diagnose_router, inputs=gr.Image(type="pil", label="Upload an image of the faulty router"), outputs=gr.HTML(), title="Structured Router Diagnosis", description="Upload a photo of your router to receive a professional diagnosis and troubleshooting steps displayed in a structured, easy-to-read format." ) # Launch the UI interface.launch()