-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
73 lines (60 loc) · 1.92 KB
/
run.py
File metadata and controls
73 lines (60 loc) · 1.92 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""CLI entrypoint for Paradox Machine MVP."""
from __future__ import annotations
import argparse
import json
from src.apis import APIConfigError
from src.agents import AgentAPIError, ParadoxDetector, format_report
def _build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description="Paradox Machine (solution v0.1.0) with YAML model config."
)
parser.add_argument(
"statement",
nargs="*",
help="Input statement/scenario to inspect for paradoxes.",
)
parser.add_argument(
"--lang",
default="Chinese",
help="Output language requested from the agent. Default: Chinese",
)
parser.add_argument(
"--config",
default=None,
help=(
"Model YAML config name or path, e.g. deepseek-chat or "
"assets/models/deepseek-chat.yaml."
),
)
parser.add_argument(
"--json",
action="store_true",
help="Print structured JSON report instead of formatted text.",
)
return parser
def _read_statement(parts: list[str]) -> str:
if parts:
return " ".join(parts).strip()
return input("Please enter the viewpoint or proposal to be examined.: ").strip()
def main() -> int:
parser = _build_parser()
args = parser.parse_args()
statement = _read_statement(args.statement)
if not statement:
parser.error("Input statement cannot be empty.")
try:
detector = ParadoxDetector.from_default(
output_language=args.lang,
model_config=args.config,
)
report = detector.analyze(statement)
except (APIConfigError, AgentAPIError, ValueError) as exc:
print(f"[ERROR] {exc}")
return 1
if args.json:
print(json.dumps(report, ensure_ascii=False, indent=2))
else:
print(format_report(report))
return 0
if __name__ == "__main__":
raise SystemExit(main())