-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
38 lines (28 loc) · 1.15 KB
/
cli.py
File metadata and controls
38 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from colorama import Fore, Style, init
from extractor import extract_claims
from verifier import verify_claim
from scorer import calculate_score
init(autoreset=True)
def run_interactive():
print(f"{Fore.CYAN}=== HalluciScope Terminal Edition ===")
context = input(f"\n{Fore.YELLOW}Enter Context: ")
model_output = input(f"{Fore.YELLOW}Enter AI Output: ")
print(f"\n{Fore.WHITE}Processing...")
claims = extract_claims(model_output)
results = []
for c in claims:
v, r, conf = verify_claim(c, context)
# Change 'conf' to match what scorer.py expects
results.append({"text": c, "verdict": v, "reason": r, "conf": conf})
color = Fore.GREEN if v == "true" else Fore.RED
print(f"[{color}{v.upper()}{Fore.WHITE}] {c[:50]}...")
score = calculate_score(results)
print(f"\n{Fore.CYAN}--- RESULTS ---")
print(f"Hallucination Score: {score}")
if score > 0.5:
print(f"{Fore.RED}⚠️ HIGH RISK: This response is likely hallucinated.")
else:
print(f"{Fore.GREEN}✅ LOW RISK: Response matches context.")
if __name__ == "__main__":
run_interactive()