-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
69 lines (58 loc) · 1.93 KB
/
Copy pathcli.py
File metadata and controls
69 lines (58 loc) · 1.93 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
"""Interactive CLI with conversation memory.
Run:
python cli.py # interactive session (memory persists across tasks)
python cli.py "your task here" # one-shot (no memory)
"""
import sys
import uuid
from src.config import ConfigError, get_settings
from src.graph.workflow import run_task
def _display(result: dict) -> None:
print(result.get("final_answer", ""))
plan = result.get("plan", [])
code_runs = result.get("code_runs", [])
verdict = result.get("verdict", "")
critique = result.get("critique", "")
fix_attempts = result.get("fix_attempts", 0)
if plan:
print(
f"\n[plan: {len(plan)} steps | "
f"runs: {len(code_runs)} | "
f"critic: {verdict} ({critique[:80]}) | "
f"fixes: {fix_attempts}]"
)
def main() -> None:
try:
settings = get_settings()
except ConfigError as exc:
sys.exit(f"ERROR: {exc}")
if len(sys.argv) > 1:
_display(run_task(" ".join(sys.argv[1:])))
return
# Interactive mode: one thread_id for the whole session = memory persists
thread_id = str(uuid.uuid4())
print(
f"Coding Assistant ready (model: {settings.groq_model}). "
f"Session: {thread_id[:8]}…\n"
f"Memory ON — follow-ups like 'now make it recursive' work.\n"
f"Type 'exit' to quit, 'new' to start a fresh session.\n"
)
while True:
try:
task = input("you> ").strip()
except (EOFError, KeyboardInterrupt):
print()
break
if task.lower() in {"exit", "quit", "q"}:
break
if task.lower() == "new":
thread_id = str(uuid.uuid4())
print(f"New session started: {thread_id[:8]}…\n")
continue
if not task:
continue
print()
_display(run_task(task, thread_id=thread_id))
print()
if __name__ == "__main__":
main()