feat(stream): thinking + run log for CLI (GAP-13 CLI part)
RunStreams: run.log always (flushed, tail -f-able) with full technical detail; thinking stream to screen under --verbose (flushed, [T] lines, > depth prefixes). Machine hooks on INIT/MISSING/ROUTE/EXPERT/ANSWER + budget ticks; child runs share the parent's stream; engine emits its raw output. Verified live: 8-call train run inline, fresh-question run 69.6s (proxy caches identical temp-0 prompts; noted).
This commit is contained in:
+23
-9
@@ -1,10 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run the floop draft on a question.
|
||||
|
||||
.venv/bin/python run_app.py "Per què el cel és blau?"
|
||||
.venv/bin/python run_app.py "Per què el cel és blau?" # log only
|
||||
.venv/bin/python run_app.py --verbose "Per què el cel és blau?" # + thinking on screen
|
||||
FLOOP_LM=ollama-cloud .venv/bin/python run_app.py "..."
|
||||
|
||||
Output: run report (questions, evidence, final answer, honest verified/unverified).
|
||||
Always: runs/<ts>-<slug>/run.log written with flush -> `tail -f` it from another
|
||||
terminal. With --verbose, the "thinking" stream (the future floop-as-LLM thinking
|
||||
output — a subset of the log) also prints to the screen, flushed.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -15,25 +18,35 @@ import yaml
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
from floop.llm import configure_lm # noqa: E402
|
||||
from floop.llm import configure_lm # noqa: E402
|
||||
from floop.machine import FloopRun, RunReport # noqa: E402
|
||||
from floop.state import Budget # noqa: E402
|
||||
from floop.state import Budget # noqa: E402
|
||||
from floop.stream import RunStreams # noqa: E402
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) < 2:
|
||||
args = sys.argv[1:]
|
||||
verbose = "--verbose" in args
|
||||
args = [a for a in args if a != "--verbose"]
|
||||
if not args:
|
||||
print(__doc__)
|
||||
sys.exit(1)
|
||||
question = " ".join(sys.argv[1:])
|
||||
question = " ".join(args)
|
||||
|
||||
cfg = yaml.safe_load((Path(__file__).resolve().parent / "config.yaml").read_text())
|
||||
code_dir = Path(__file__).resolve().parent
|
||||
cfg = yaml.safe_load((code_dir / "config.yaml").read_text())
|
||||
b = cfg["budget"]
|
||||
budget = Budget(max_llm_calls=b["max_llm_calls"], max_depth=b["max_depth"],
|
||||
max_retries=b["max_retries"], missing_extensions=b["missing_extensions"],
|
||||
min_child_budget=b["min_child_budget"])
|
||||
|
||||
lm_info = configure_lm()
|
||||
report: RunReport = FloopRun(question, budget).run()
|
||||
streams = RunStreams(question, verbose=verbose, runs_dir=code_dir / "runs")
|
||||
streams.log(f"lm={lm_info['provider']}/{lm_info['model']} verbose={verbose}")
|
||||
try:
|
||||
report: RunReport = FloopRun(question, budget, streams=streams).run()
|
||||
finally:
|
||||
streams.close()
|
||||
|
||||
print(f"goal: {report.goal}")
|
||||
print(f"lm: {lm_info['provider']} / {lm_info['model']} | llm_calls={report.llm_calls} "
|
||||
@@ -47,7 +60,8 @@ def main() -> None:
|
||||
for line in report.evidence_rows:
|
||||
print(f" {line}")
|
||||
print(f"\nfinal answer [{'VERIFIED' if report.verified else 'UNVERIFIED'}]:")
|
||||
print(answer_block := (report.final_answer or "(no answer produced)"))
|
||||
print(report.final_answer or "(no answer produced)")
|
||||
print(f"\nrun log: {streams.run_dir / 'run.log'} (tail -f it next time)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user