Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """CLI for LLM-based case generation.""" | |
| import argparse | |
| import json | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Generate a new Turnabout case using LLM") | |
| parser.add_argument("-t", "--theme", default=None, help="Theme for the case (e.g. 'art heist')") | |
| parser.add_argument("-d", "--difficulty", choices=["easy", "hard"], default="easy") | |
| parser.add_argument("-m", "--model", default="claude-sonnet-4-6") | |
| parser.add_argument("-o", "--output", required=True, help="Output JSON file path") | |
| parser.add_argument("--validate-only", help="Only validate an existing case file") | |
| args = parser.parse_args() | |
| if args.validate_only: | |
| from turnabout.core.schema import CaseData | |
| from turnabout.generation.validator import CaseValidator | |
| with open(args.validate_only) as f: | |
| data = json.load(f) | |
| case = CaseData(**data) | |
| validator = CaseValidator() | |
| report = validator.validate(case) | |
| print(f"Valid: {report.is_valid}") | |
| for e in report.errors: | |
| print(f" ERROR: {e}") | |
| for w in report.warnings: | |
| print(f" WARNING: {w}") | |
| return | |
| try: | |
| from turnabout.generation.generator import CaseGenerator | |
| except ImportError as e: | |
| print(f"Error: {e}") | |
| print("Install with: pip install 'turnabout[generation]'") | |
| sys.exit(1) | |
| generator = CaseGenerator(model=args.model) | |
| print(f"Generating case (theme={args.theme}, difficulty={args.difficulty})...") | |
| case = generator.generate(theme=args.theme, difficulty=args.difficulty) | |
| with open(args.output, "w") as f: | |
| json.dump(case.model_dump(), f, indent=2, ensure_ascii=False) | |
| print(f"Case saved to {args.output}") | |
| print(f"Title: {case.title}") | |
| print(f"Characters: {len(case.characters)}") | |
| print(f"Evidence: {len(case.evidence)}") | |
| if __name__ == "__main__": | |
| main() | |