Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,59 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
)
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
placeholder="
|
25 |
-
)
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
)
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from modules import analysis # Correct import
|
3 |
+
|
4 |
+
# Create the Gradio Blocks UI
|
5 |
+
with gr.Blocks(title="Log Intelligence Assistant") as demo:
|
6 |
+
gr.Markdown("## 🔍 Interactive Network Log Assistant")
|
7 |
+
|
8 |
+
with gr.Tab("Inputs 🔽"):
|
9 |
+
with gr.Row():
|
10 |
+
uploaded_files = gr.File(
|
11 |
+
file_types=[".pdf", ".log", ".txt"],
|
12 |
+
file_count="multiple",
|
13 |
+
label="📁 Upload Log Files"
|
14 |
+
)
|
15 |
+
text_input = gr.Textbox(
|
16 |
+
label="Paste Logs Here",
|
17 |
+
lines=15,
|
18 |
+
placeholder="2023-10-05 14:22:11 [Firewall] BLOCKED: 192.168.1.5..."
|
19 |
+
)
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
query_input = gr.Textbox(
|
23 |
+
label="Ask About Logs",
|
24 |
+
placeholder="Find failed login attempts from 192.168.1.5"
|
25 |
+
)
|
26 |
+
quick_query = gr.Dropdown(
|
27 |
+
choices=["", "Detect anomalies", "Show blocked IPs", "Generate summary"],
|
28 |
+
label="Quick Actions"
|
29 |
+
)
|
30 |
+
|
31 |
+
with gr.Accordion("⚙️ Configuration Controls", open=False):
|
32 |
+
temperature = gr.Slider(minimum=0.1, maximum=1.0, value=0.7, label="Creativity (Temperature)")
|
33 |
+
start_time = gr.DateTime(label="Start Time")
|
34 |
+
end_time = gr.DateTime(label="End Time")
|
35 |
+
|
36 |
+
with gr.Tab("Outputs 🔼"):
|
37 |
+
analysis_result = gr.Textbox(label="Analysis Results", lines=10, interactive=False)
|
38 |
+
bar_plot = gr.BarPlot(label="Event Frequency by Hour", x="Hour", y="Count", interactive=False)
|
39 |
+
pie_chart = gr.PieChart(label="Event Type Distribution", interactive=False)
|
40 |
+
alert_feed = gr.HighlightedText(label="Security Alerts", color_map={
|
41 |
+
"CRITICAL": "red",
|
42 |
+
"WARNING": "orange",
|
43 |
+
"INFO": "blue"
|
44 |
+
})
|
45 |
+
|
46 |
+
with gr.Tab("Export 📤"):
|
47 |
+
export_csv = gr.Button("Save as CSV")
|
48 |
+
export_pdf = gr.Button("Export PDF Report")
|
49 |
+
|
50 |
+
run_button = gr.Button("🔎 Analyze Logs")
|
51 |
+
|
52 |
+
# ✅ Fixed the typo here: analysis not analys
|
53 |
+
run_button.click(
|
54 |
+
fn=analysis.run_analysis,
|
55 |
+
inputs=[uploaded_files, text_input, query_input, quick_query, temperature, start_time, end_time],
|
56 |
+
outputs=[analysis_result, bar_plot, pie_chart, alert_feed]
|
57 |
+
)
|
58 |
+
|
59 |
+
demo.launch()
|