Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,10 +8,6 @@ from intelligence_pipeline import (
|
|
| 8 |
from safety_classifier import safety_check
|
| 9 |
|
| 10 |
|
| 11 |
-
# ---------------------------------------------------------------------------
|
| 12 |
-
# Mode Handlers
|
| 13 |
-
# ---------------------------------------------------------------------------
|
| 14 |
-
|
| 15 |
def handle_threat_intel(message, files):
|
| 16 |
base = analyze_threat(message or "")
|
| 17 |
if files:
|
|
@@ -46,14 +42,9 @@ MODE_ROUTER = {
|
|
| 46 |
}
|
| 47 |
|
| 48 |
|
| 49 |
-
# ---------------------------------------------------------------------------
|
| 50 |
-
# Core message processor (with safety pre-check)
|
| 51 |
-
# ---------------------------------------------------------------------------
|
| 52 |
-
|
| 53 |
def process_message(message, files, history, mode):
|
| 54 |
text = message or ""
|
| 55 |
|
| 56 |
-
# ---- SAFETY CHECK (blocks malicious or unsafe input) ----
|
| 57 |
safety = safety_check(text)
|
| 58 |
if safety["blocked"]:
|
| 59 |
response = "⚠️ Safety Block: " + safety["reason"]
|
|
@@ -87,10 +78,6 @@ def download_chat(history):
|
|
| 87 |
return tmp.name
|
| 88 |
|
| 89 |
|
| 90 |
-
# ---------------------------------------------------------------------------
|
| 91 |
-
# UI
|
| 92 |
-
# ---------------------------------------------------------------------------
|
| 93 |
-
|
| 94 |
with gr.Blocks(title="Threat Landscape Intelligence Console") as demo:
|
| 95 |
gr.Markdown("## 🛰 APJ Threat Intelligence Console")
|
| 96 |
|
|
@@ -120,14 +107,12 @@ with gr.Blocks(title="Threat Landscape Intelligence Console") as demo:
|
|
| 120 |
)
|
| 121 |
send_btn = gr.Button("Send", variant="primary", scale=1)
|
| 122 |
|
| 123 |
-
# Button event
|
| 124 |
send_btn.click(
|
| 125 |
fn=process_message,
|
| 126 |
inputs=[user_input, file_input, chat_state, mode],
|
| 127 |
outputs=[chat, chat_state],
|
| 128 |
).then(lambda: "", None, user_input)
|
| 129 |
|
| 130 |
-
# Enter-key event
|
| 131 |
user_input.submit(
|
| 132 |
fn=process_message,
|
| 133 |
inputs=[user_input, file_input, chat_state, mode],
|
|
@@ -137,5 +122,6 @@ with gr.Blocks(title="Threat Landscape Intelligence Console") as demo:
|
|
| 137 |
clear_btn.click(fn=clear_chat, outputs=[chat, chat_state])
|
| 138 |
download_btn.click(fn=download_chat, inputs=chat_state, outputs=download_file)
|
| 139 |
|
|
|
|
| 140 |
if __name__ == "__main__":
|
| 141 |
demo.launch()
|
|
|
|
| 8 |
from safety_classifier import safety_check
|
| 9 |
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def handle_threat_intel(message, files):
|
| 12 |
base = analyze_threat(message or "")
|
| 13 |
if files:
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
def process_message(message, files, history, mode):
|
| 46 |
text = message or ""
|
| 47 |
|
|
|
|
| 48 |
safety = safety_check(text)
|
| 49 |
if safety["blocked"]:
|
| 50 |
response = "⚠️ Safety Block: " + safety["reason"]
|
|
|
|
| 78 |
return tmp.name
|
| 79 |
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
with gr.Blocks(title="Threat Landscape Intelligence Console") as demo:
|
| 82 |
gr.Markdown("## 🛰 APJ Threat Intelligence Console")
|
| 83 |
|
|
|
|
| 107 |
)
|
| 108 |
send_btn = gr.Button("Send", variant="primary", scale=1)
|
| 109 |
|
|
|
|
| 110 |
send_btn.click(
|
| 111 |
fn=process_message,
|
| 112 |
inputs=[user_input, file_input, chat_state, mode],
|
| 113 |
outputs=[chat, chat_state],
|
| 114 |
).then(lambda: "", None, user_input)
|
| 115 |
|
|
|
|
| 116 |
user_input.submit(
|
| 117 |
fn=process_message,
|
| 118 |
inputs=[user_input, file_input, chat_state, mode],
|
|
|
|
| 122 |
clear_btn.click(fn=clear_chat, outputs=[chat, chat_state])
|
| 123 |
download_btn.click(fn=download_chat, inputs=chat_state, outputs=download_file)
|
| 124 |
|
| 125 |
+
|
| 126 |
if __name__ == "__main__":
|
| 127 |
demo.launch()
|