VED-AGI-1 commited on
Commit
1ffc9f1
·
verified ·
1 Parent(s): 8c7975e

Create main.py

Browse files
Files changed (1) hide show
  1. pipeline/main.py +60 -0
pipeline/main.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Simple CLI runner to:
3
+ 1) Build a new pack from pasted scenario text.
4
+ 2) Run Phase 1 (clarifications).
5
+ 3) Exit with the questions so an operator/UI can answer them.
6
+ 4) After answers are saved to clarifications.json, run Phase 2 to produce final output.
7
+
8
+ Usage (example):
9
+ python -m clarityops.pipeline.main --scenario "My scenario text..." --name "oncology_pilot"
10
+ Then answer questions by editing packs/<slug>/clarifications.json and run:
11
+ python -m clarityops.pipeline.main --pack packs/oncology_pilot --phase2
12
+ """
13
+
14
+ import argparse
15
+ from pathlib import Path
16
+ import json
17
+
18
+ from .pack_builder import build_pack_from_scenario
19
+ from .run_two_phase import run_clarityops, call_model
20
+
21
+ def main():
22
+ parser = argparse.ArgumentParser()
23
+ parser.add_argument("--scenario", type=str, help="Free-form scenario text")
24
+ parser.add_argument("--name", type=str, default="", help="Hint for pack folder name")
25
+ parser.add_argument("--pack", type=str, help="Existing pack to run")
26
+ parser.add_argument("--phase2", action="store_true", help="Run Phase 2 using existing clarifications.json")
27
+ args = parser.parse_args()
28
+
29
+ root = Path(__file__).parents[2]
30
+
31
+ if args.scenario:
32
+ # Build pack from scenario text
33
+ pack_dir = build_pack_from_scenario(root, args.scenario, args.name)
34
+ print(f"[OK] Created pack: {pack_dir}")
35
+ print("Next step: Run Phase 1 to generate clarification questions (the pipeline will request answers).")
36
+
37
+ # Run Phase 1 only by triggering pipeline and capturing questions
38
+ # We let run_clarityops raise for missing clarifications.json answers to surface Phase 1 questions.
39
+ try:
40
+ _output, clarif_raw = run_clarityops(str(pack_dir))
41
+ except RuntimeError as e:
42
+ print("\n[PHASE 1 QUESTIONS]\n")
43
+ # We don't have direct access to clarif_raw here since run_clarityops expects clarifications.json.
44
+ # In a production stack, you'd split run_two_phase to expose a "phase1_only" call that returns questions.
45
+ # For now, instruct the operator to open the logs or integrate your model streaming.
46
+ print("Phase 1 questions have been generated by the model.")
47
+ print("Open your app's model output/log to capture them, then write answers into:")
48
+ print(f" {pack_dir}/clarifications.json")
49
+ print("\nTip: In production, expose a UI to show and record these answers.")
50
+ return
51
+
52
+ elif args.pack and args.phase2:
53
+ output, clarif_questions = run_clarityops(args.pack)
54
+ print("[OK] Phase 2 completed. Final JSON:")
55
+ print(json.dumps(output, ensure_ascii=False, indent=2))
56
+ else:
57
+ parser.print_help()
58
+
59
+ if __name__ == "__main__":
60
+ main()