floop v0.1: design docs + executable dspy draft
Root: README, PIPELINE, ALGORITHM, GAPS, RUNLOG (design + first executable runs). code/: v0.1 draft on dspy 3.4 (INIT/ROUTE/EXPERT/MISSING/ANSWER as dspy calls, machine as fixed code, stub engines — honest Unverified). knowledge/: DESIGN.md for the KG-first knowledge expert (pre-implementation).
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run the floop draft on a question.
|
||||
|
||||
.venv/bin/python run_app.py "Per què el cel és blau?"
|
||||
FLOOP_LM=ollama-cloud .venv/bin/python run_app.py "..."
|
||||
|
||||
Output: run report (questions, evidence, final answer, honest verified/unverified).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
from floop.llm import configure_lm # noqa: E402
|
||||
from floop.machine import FloopRun, RunReport # noqa: E402
|
||||
from floop.state import Budget # noqa: E402
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) < 2:
|
||||
print(__doc__)
|
||||
sys.exit(1)
|
||||
question = " ".join(sys.argv[1:])
|
||||
|
||||
cfg = yaml.safe_load((Path(__file__).resolve().parent / "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()
|
||||
|
||||
print(f"goal: {report.goal}")
|
||||
print(f"lm: {lm_info['provider']} / {lm_info['model']} | llm_calls={report.llm_calls} "
|
||||
f"engines={report.engine_calls} depth={report.depth} time={report.elapsed_s}s")
|
||||
if report.notes:
|
||||
print("notes: " + "; ".join(report.notes))
|
||||
print("\nquestions:")
|
||||
for qid, status, text in report.questions:
|
||||
print(f" {qid} [{status}] {text}")
|
||||
print("\nevidence:")
|
||||
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)"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user