Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,9 +25,7 @@ def summarize_logs(df):
|
|
| 25 |
prompt = (f"Summarize maintenance and usage logs. There were {total_devices} devices. The most used device was {most_used}.")
|
| 26 |
summary = summarizer(prompt, max_length=200, do_sample=False)[0]["generated_text"]
|
| 27 |
logging.info("Summary generated successfully")
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
return summary
|
| 31 |
except Exception as e:
|
| 32 |
logging.error(f"Summary generation failed: {str(e)}")
|
| 33 |
return "Failed to generate summary."
|
|
@@ -150,10 +148,7 @@ def process_logs(file_obj):
|
|
| 150 |
|
| 151 |
try:
|
| 152 |
logging.info("Initializing Gradio Blocks interface...")
|
| 153 |
-
with gr.Blocks(css=""".dashboard-container {border: 1px solid #e0e0e0; padding: 10px; border-radius: 5px; background-color: #
|
| 154 |
-
.dashboard-title {font-size: 24px; font-weight: bold; margin-bottom: 10px;}
|
| 155 |
-
.dashboard-section {margin-bottom: 15px;}
|
| 156 |
-
.dashboard-section h3 {font-size: 18px; margin-bottom: 5px;}""") as iface:
|
| 157 |
gr.Markdown("<h1>LabOps Log Analyzer Dashboard (Hugging Face AI)</h1>")
|
| 158 |
gr.Markdown("Upload a CSV file containing lab equipment logs to analyze usage.")
|
| 159 |
with gr.Row():
|
|
@@ -172,7 +167,6 @@ try:
|
|
| 172 |
with gr.Group(elem_classes="dashboard-section"):
|
| 173 |
gr.Markdown("### Step 3: Usage Chart")
|
| 174 |
chart_output = gr.Plot()
|
| 175 |
-
with gr.Group(elem_classes="dashboard Middlebury formatting applied.
|
| 176 |
with gr.Group(elem_classes="dashboard-section"):
|
| 177 |
gr.Markdown("### Step 4: Anomaly Detection")
|
| 178 |
anomaly_output = gr.Markdown()
|
|
@@ -183,7 +177,7 @@ try:
|
|
| 183 |
gr.Markdown("### Step 6: Dashboard Insights (AI)")
|
| 184 |
insights_output = gr.Markdown()
|
| 185 |
submit_button.click(fn=process_logs, inputs=[file_input],
|
| 186 |
-
|
| 187 |
logging.info("Gradio interface initialized successfully")
|
| 188 |
except Exception as e:
|
| 189 |
logging.error(f"Failed to initialize Gradio interface: {str(e)}")
|
|
|
|
| 25 |
prompt = (f"Summarize maintenance and usage logs. There were {total_devices} devices. The most used device was {most_used}.")
|
| 26 |
summary = summarizer(prompt, max_length=200, do_sample=False)[0]["generated_text"]
|
| 27 |
logging.info("Summary generated successfully")
|
| 28 |
+
return summary
|
|
|
|
|
|
|
| 29 |
except Exception as e:
|
| 30 |
logging.error(f"Summary generation failed: {str(e)}")
|
| 31 |
return "Failed to generate summary."
|
|
|
|
| 148 |
|
| 149 |
try:
|
| 150 |
logging.info("Initializing Gradio Blocks interface...")
|
| 151 |
+
with gr.Blocks(css=""".dashboard-container {border: 1px solid #e0e0e0; padding: 10px; border-radius: 5px; background-color: #f9fburn: none; .dashboard-title {font-size: 24px; font-weight: bold; margin-bottom: 10px;} .dashboard-section {margin-bottom: 15px;} .dashboard-section h3 {font-size: 18px; margin-bottom: 5px;}""") as iface:
|
|
|
|
|
|
|
|
|
|
| 152 |
gr.Markdown("<h1>LabOps Log Analyzer Dashboard (Hugging Face AI)</h1>")
|
| 153 |
gr.Markdown("Upload a CSV file containing lab equipment logs to analyze usage.")
|
| 154 |
with gr.Row():
|
|
|
|
| 167 |
with gr.Group(elem_classes="dashboard-section"):
|
| 168 |
gr.Markdown("### Step 3: Usage Chart")
|
| 169 |
chart_output = gr.Plot()
|
|
|
|
| 170 |
with gr.Group(elem_classes="dashboard-section"):
|
| 171 |
gr.Markdown("### Step 4: Anomaly Detection")
|
| 172 |
anomaly_output = gr.Markdown()
|
|
|
|
| 177 |
gr.Markdown("### Step 6: Dashboard Insights (AI)")
|
| 178 |
insights_output = gr.Markdown()
|
| 179 |
submit_button.click(fn=process_logs, inputs=[file_input],
|
| 180 |
+
outputs=[summary_output, preview_output, chart_output, anomaly_output, amc_output, insights_output])
|
| 181 |
logging.info("Gradio interface initialized successfully")
|
| 182 |
except Exception as e:
|
| 183 |
logging.error(f"Failed to initialize Gradio interface: {str(e)}")
|