hch-dev commited on
Commit
ad12f34
·
verified ·
1 Parent(s): 79f8ec5

Update Version_5/src/orchestrator.py

Browse files
Files changed (1) hide show
  1. Version_5/src/orchestrator.py +38 -37
Version_5/src/orchestrator.py CHANGED
@@ -1,38 +1,39 @@
1
- import os
2
- from groq import Groq
3
- from typing import Dict
4
- from .schemas import AgentReport, JudgeVerdict
5
-
6
- client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
7
-
8
- def evaluate_consensus(reports: Dict[str, AgentReport]) -> bool:
9
- claims = [r.claim for r in reports.values()]
10
- confidences = [r.confidence for r in reports.values()]
11
-
12
- all_same = len(set(claims)) == 1
13
- high_conf = all(c >= 0.85 for c in confidences)
14
-
15
- return all_same and high_conf
16
-
17
- def run_judge(reports_summary: str, raw_data: str) -> JudgeVerdict:
18
- system_prompt = (
19
- "You are the presiding Judge Magistrate in an Enterprise Cybersecurity Matrix.\n"
20
- "Your subordinate agents have provided split panel reports.\n"
21
- "Respond strictly in valid JSON matching this schema:\n"
22
- "{\"final_verdict\": \"CRITICAL_THREAT\"|\"SAFE\"|\"MANUAL_REVIEW_REQUIRED\", \"risk_score\": float, \"verdict_justification\": string}\n\n"
23
- "DECISION ARCHITECTURE RULES:\n"
24
- "1. If ANY analyst engine raises a 'PHISHING' claim with confidence >= 0.85, force 'CRITICAL_THREAT'.\n"
25
- "2. Avoid label contradictions: Never set final_verdict to SAFE if your textual argument implies a threat pattern."
26
- )
27
-
28
- # We leverage the powerful 70B cloud model for premium reasoning accuracy
29
- response = client.chat.completions.create(
30
- model="llama-3.3-70b-versatile",
31
- messages=[
32
- {"role": "system", "content": system_prompt},
33
- {"role": "user", "content": f"RAW INPUTS:\n{raw_data}\n\nREPORTS:\n{reports_summary}"}
34
- ],
35
- response_format={"type": "json_object"},
36
- temperature=0.0
37
- )
 
38
  return JudgeVerdict.model_validate_json(response.choices[0].message.content)
 
1
+ import os
2
+ from groq import Groq
3
+ from typing import Dict
4
+ from .schemas import AgentReport, JudgeVerdict
5
+
6
+ client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
7
+
8
+ def evaluate_consensus(reports: Dict[str, AgentReport]) -> bool:
9
+ claims = [r.claim for r in reports.values()]
10
+ confidences = [r.confidence for r in reports.values()]
11
+
12
+ all_same = len(set(claims)) == 1
13
+ high_conf = all(c >= 0.85 for c in confidences)
14
+
15
+ return all_same and high_conf
16
+
17
+ def run_judge(reports_summary: str, raw_data: str) -> JudgeVerdict:
18
+ system_prompt = (
19
+ "You are the presiding Judge Magistrate in an Enterprise Cybersecurity Matrix.\n"
20
+ "Your subordinate agents have provided split panel reports.\n"
21
+ "Respond strictly in valid JSON matching this schema:\n"
22
+ "{\"final_verdict\": \"CRITICAL_THREAT\"|\"SAFE\"|\"MANUAL_REVIEW_REQUIRED\", \"risk_score\": float, \"verdict_justification\": string}\n\n"
23
+ "DECISION ARCHITECTURE RULES:\n"
24
+ "1. If ANY analyst engine raises a 'PHISHING' claim with confidence >= 0.85, force 'CRITICAL_THREAT'.\n"
25
+ "2. Avoid label contradictions: Never set final_verdict to SAFE if your textual argument implies a threat pattern.\n"
26
+ "3. SUPREME VETO RULE: If the Target URL belongs to a verified, universally trusted root domain (e.g., 'github.com', 'google.com', 'microsoft.com') and shows no signs of typosquatting, you MUST overrule paranoid sub-agents, ignore Rule 1, and force a 'SAFE' verdict with a low risk score. Standard authentication portals on official domains are inherently safe."
27
+ )
28
+
29
+ # We leverage the powerful 70B cloud model for premium reasoning accuracy
30
+ response = client.chat.completions.create(
31
+ model="llama-3.3-70b-versatile",
32
+ messages=[
33
+ {"role": "system", "content": system_prompt},
34
+ {"role": "user", "content": f"RAW INPUTS:\n{raw_data}\n\nREPORTS SUMMARY:\n{reports_summary}"}
35
+ ],
36
+ response_format={"type": "json_object"},
37
+ temperature=0.0
38
+ )
39
  return JudgeVerdict.model_validate_json(response.choices[0].message.content)