Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ textarea, input {
|
|
| 25 |
}
|
| 26 |
button {
|
| 27 |
background-color: #111111 !important;
|
| 28 |
-
color #ffffff !important;
|
| 29 |
border: 1px solid #444444 !important;
|
| 30 |
font-family: 'Courier New', monospace !important;
|
| 31 |
}
|
|
@@ -44,7 +44,6 @@ label, p, span {
|
|
| 44 |
}
|
| 45 |
footer { display: none !important; }
|
| 46 |
.examples { display: none !important; }
|
| 47 |
-
.center-img { display: flex; justify-content: center; margin-bottom: 20px; }
|
| 48 |
"""
|
| 49 |
|
| 50 |
def check_prompt(prompt):
|
|
@@ -55,57 +54,44 @@ def check_prompt(prompt):
|
|
| 55 |
headers={"X-API-Key": API_KEY}
|
| 56 |
)
|
| 57 |
result = response.json()
|
| 58 |
-
|
| 59 |
verdict = result.get("verdict", "UNKNOWN")
|
| 60 |
layer = result.get("layer_hit", "N/A")
|
| 61 |
conf = result.get("confidence", 0)
|
| 62 |
lat = result.get("latency_ms", 0)
|
| 63 |
-
|
| 64 |
display = (f"VERDICT: {verdict}\n"
|
| 65 |
f"LAYER : {layer}\n"
|
| 66 |
f"CONF : {conf:.2f}\n"
|
| 67 |
f"LATENCY: {lat:.1f}ms")
|
| 68 |
-
|
| 69 |
with open("security_audit.log", "a") as f:
|
| 70 |
f.write(f"[{datetime.datetime.now()}] Input: {prompt} | Verdict: {verdict} | Layer: {layer}\n")
|
| 71 |
-
|
| 72 |
return display
|
| 73 |
except Exception as e:
|
| 74 |
return f"[SYSTEM ERROR]\n{str(e)}"
|
| 75 |
|
| 76 |
-
|
| 77 |
with gr.Blocks(css=css, title="Agent Shield") as demo:
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
gr.Image(
|
| 85 |
-
value="banner.png",
|
| 86 |
-
show_label=False,
|
| 87 |
-
container=False
|
| 88 |
-
)
|
| 89 |
-
with gr.Column(scale=1):
|
| 90 |
-
pass
|
| 91 |
-
|
| 92 |
-
# Input / Output boxes
|
| 93 |
-
with gr.Row():
|
| 94 |
-
with gr.Column():
|
| 95 |
-
prompt_input = gr.Textbox(
|
| 96 |
-
lines=4,
|
| 97 |
-
placeholder="$ enter prompt...",
|
| 98 |
-
label="INPUT"
|
| 99 |
-
)
|
| 100 |
-
check_btn = gr.Button("[ SCAN ]", variant="primary")
|
| 101 |
-
|
| 102 |
-
with gr.Column():
|
| 103 |
-
output_box = gr.Textbox(
|
| 104 |
-
label="OUTPUT",
|
| 105 |
-
lines=5,
|
| 106 |
-
interactive=False
|
| 107 |
-
)
|
| 108 |
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
demo.launch()
|
|
|
|
| 25 |
}
|
| 26 |
button {
|
| 27 |
background-color: #111111 !important;
|
| 28 |
+
color: #ffffff !important;
|
| 29 |
border: 1px solid #444444 !important;
|
| 30 |
font-family: 'Courier New', monospace !important;
|
| 31 |
}
|
|
|
|
| 44 |
}
|
| 45 |
footer { display: none !important; }
|
| 46 |
.examples { display: none !important; }
|
|
|
|
| 47 |
"""
|
| 48 |
|
| 49 |
def check_prompt(prompt):
|
|
|
|
| 54 |
headers={"X-API-Key": API_KEY}
|
| 55 |
)
|
| 56 |
result = response.json()
|
| 57 |
+
|
| 58 |
verdict = result.get("verdict", "UNKNOWN")
|
| 59 |
layer = result.get("layer_hit", "N/A")
|
| 60 |
conf = result.get("confidence", 0)
|
| 61 |
lat = result.get("latency_ms", 0)
|
| 62 |
+
|
| 63 |
display = (f"VERDICT: {verdict}\n"
|
| 64 |
f"LAYER : {layer}\n"
|
| 65 |
f"CONF : {conf:.2f}\n"
|
| 66 |
f"LATENCY: {lat:.1f}ms")
|
| 67 |
+
|
| 68 |
with open("security_audit.log", "a") as f:
|
| 69 |
f.write(f"[{datetime.datetime.now()}] Input: {prompt} | Verdict: {verdict} | Layer: {layer}\n")
|
| 70 |
+
|
| 71 |
return display
|
| 72 |
except Exception as e:
|
| 73 |
return f"[SYSTEM ERROR]\n{str(e)}"
|
| 74 |
|
|
|
|
| 75 |
with gr.Blocks(css=css, title="Agent Shield") as demo:
|
| 76 |
|
| 77 |
+
gr.Image(
|
| 78 |
+
value="banner.png",
|
| 79 |
+
show_label=False,
|
| 80 |
+
container=False
|
| 81 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
+
gr.Interface(
|
| 84 |
+
fn=check_prompt,
|
| 85 |
+
inputs=gr.Textbox(
|
| 86 |
+
lines=4,
|
| 87 |
+
placeholder="$ enter prompt...",
|
| 88 |
+
label="INPUT"
|
| 89 |
+
),
|
| 90 |
+
outputs=gr.Textbox(
|
| 91 |
+
label="OUTPUT",
|
| 92 |
+
lines=5
|
| 93 |
+
),
|
| 94 |
+
description="Protects your AI",
|
| 95 |
+
)
|
| 96 |
|
| 97 |
demo.launch()
|