Sandeep120205 commited on
Commit
ced477d
·
verified ·
1 Parent(s): c907c75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,8 +1,10 @@
1
  import gradio as gr
2
  import requests
3
  import datetime
 
4
 
5
  API_URL = "https://agent-shield-chbxh2hkhxgucgax.eastasia-01.azurewebsites.net/v1/check"
 
6
 
7
  css = """
8
  body { background-color: #000000 !important; }
@@ -46,10 +48,13 @@ footer { display: none !important; }
46
 
47
  def check_prompt(prompt):
48
  try:
49
- response = requests.post(API_URL, json={"prompt": prompt})
 
 
 
 
50
  result = response.json()
51
 
52
- # Format the output for the UI
53
  verdict = result.get("verdict", "UNKNOWN")
54
  layer = result.get("layer_hit", "N/A")
55
  conf = result.get("confidence", 0)
@@ -62,7 +67,6 @@ def check_prompt(prompt):
62
  f"--- RAW METADATA ---\n"
63
  f"{result.get('details', 'No details available')}")
64
 
65
- # LOGGING: Append every test to a local file for your portfolio
66
  with open("security_audit.log", "a") as f:
67
  f.write(f"[{datetime.datetime.now()}] Input: {prompt} | Verdict: {verdict} | Layer: {layer}\n")
68
 
 
1
  import gradio as gr
2
  import requests
3
  import datetime
4
+ import os
5
 
6
  API_URL = "https://agent-shield-chbxh2hkhxgucgax.eastasia-01.azurewebsites.net/v1/check"
7
+ API_KEY = os.environ.get("AGENT_SHIELD_API_KEY", "")
8
 
9
  css = """
10
  body { background-color: #000000 !important; }
 
48
 
49
  def check_prompt(prompt):
50
  try:
51
+ response = requests.post(
52
+ API_URL,
53
+ json={"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)
 
67
  f"--- RAW METADATA ---\n"
68
  f"{result.get('details', 'No details available')}")
69
 
 
70
  with open("security_audit.log", "a") as f:
71
  f.write(f"[{datetime.datetime.now()}] Input: {prompt} | Verdict: {verdict} | Layer: {layer}\n")
72