rahimizadeh's picture
Upload 2 files
bb3ca4a verified
raw
history blame
1.98 kB
# Import Gradio for UI and your backend analysis module
import gradio as gr
from modules import analysis # assumes parser.py, vectorizer.py, analysis.py are in a "modules" folder
# Define the Gradio app using Blocks layout for full customization
with gr.Blocks(title="Log Intelligence Assistant") as demo:
# Header title
gr.Markdown("## 🔍 Interactive Network Log Assistant")
# -------- INPUTS TAB --------
with gr.Tab("Inputs 🔽"):
# File upload and raw text input
with gr.Row():
uploaded_files = gr.File(
file_types=[".pdf", ".log", ".txt"],
file_count="multiple", # allow multiple file uploads
label="📁 Upload Log Files"
)
text_input = gr.Textbox(
label="Paste Logs Here",
lines=15, # height of textbox
placeholder="2023-10-05 14:22:11 [Firewall] BLOCKED: 192.168.1.5..."
)
# Natural language query and quick predefined actions
with gr.Row():
query_input = gr.Textbox(
label="Ask About Logs",
placeholder="Find failed login attempts from 192.168.1.5"
)
quick_query = gr.Dropdown(
choices=["", "Detect anomalies", "Show blocked IPs", "Generate summary"],
label="Quick Actions"
)
# Optional model and filter configurations
with gr.Accordion("⚙️ Configuration Controls", open=False):
temperature = gr.Slider(
minimum=0.1, maximum=1.0, value=0.7,
label="Creativity (Temperature)"
)
start_time = gr.DateTime(label="Start Time")
end_time = gr.DateTime(label="End Time")
# -------- OUTPUTS TAB --------
with gr.Tab("Outputs 🔼"):
# Text output for log analysis result
analys