Spaces:
Runtime error
Runtime error
fix round 1
Browse files- inference.py +10 -9
inference.py
CHANGED
|
@@ -28,7 +28,7 @@ def choose_action(client, state):
|
|
| 28 |
messages=[
|
| 29 |
{
|
| 30 |
"role": "system",
|
| 31 |
-
"content": "You are a cybersecurity
|
| 32 |
},
|
| 33 |
{
|
| 34 |
"role": "user",
|
|
@@ -79,13 +79,14 @@ def run_task(task_name):
|
|
| 79 |
except Exception:
|
| 80 |
pass
|
| 81 |
|
| 82 |
-
#
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
| 89 |
if action not in env.action_space():
|
| 90 |
action = "detect_attack"
|
| 91 |
|
|
@@ -105,7 +106,7 @@ def run_task(task_name):
|
|
| 105 |
|
| 106 |
steps = len(rewards)
|
| 107 |
|
| 108 |
-
#
|
| 109 |
if task_name == "easy":
|
| 110 |
score = easy_grade(rewards)
|
| 111 |
elif task_name == "medium":
|
|
|
|
| 28 |
messages=[
|
| 29 |
{
|
| 30 |
"role": "system",
|
| 31 |
+
"content": "You are a cybersecurity deception agent. Choose one action from: detect_attack, deploy_honeypot, fake_database, block_ip"
|
| 32 |
},
|
| 33 |
{
|
| 34 |
"role": "user",
|
|
|
|
| 79 |
except Exception:
|
| 80 |
pass
|
| 81 |
|
| 82 |
+
# AI chooses action
|
| 83 |
+
action = choose_action(client, state)
|
| 84 |
+
|
| 85 |
+
# exploration
|
| 86 |
+
if random.random() < 0.2:
|
| 87 |
+
action = random.choice(env.action_space())
|
| 88 |
+
|
| 89 |
+
# fallback
|
| 90 |
if action not in env.action_space():
|
| 91 |
action = "detect_attack"
|
| 92 |
|
|
|
|
| 106 |
|
| 107 |
steps = len(rewards)
|
| 108 |
|
| 109 |
+
# grading
|
| 110 |
if task_name == "easy":
|
| 111 |
score = easy_grade(rewards)
|
| 112 |
elif task_name == "medium":
|