Verbose per-call LLM logging, raw request/response dumps, and end-of-log cost summary.
- [LLM] line per call: stage, model, prompt size, output size, cost, parsed item counts - LLM_RAW_DUMP: full prompt/response JSON per call under outputs/<job>/llm_raw/ - Cost block at tail of job.log (per-stage, per-model, cached vs live) - Agent mode: reset llm cost counters per job; review finalization now teed into job.log + dumps
This commit is contained in:
+15
-2
@@ -20,7 +20,7 @@ from fastapi.responses import HTMLResponse, JSONResponse, Response
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
import backend.jobs
|
||||
from backend import config
|
||||
from backend import config, llm
|
||||
from backend.jobs import PIPELINE_MODES, create_job, get_job, _set
|
||||
from backend.pipeline.pdf_processor import render_page_jpeg
|
||||
from backend.review.feedback import decision_to_label, write_label
|
||||
@@ -186,7 +186,20 @@ def save_review_decisions(job_id: str, payload: dict):
|
||||
def _finalize_job(job_id: str, out_dir: str) -> None:
|
||||
"""Background finalization: the ONE place the final report email may fire."""
|
||||
try:
|
||||
report = finalize_review(job_id, out_dir)
|
||||
# Re-open the job's log tee + raw dump dir so the finalization LLM
|
||||
# calls (clarification reruns, RFI drafting) land in job.log / llm_raw.
|
||||
with backend.jobs.capture_job_output(job_id, out_dir):
|
||||
print("\n=== Review finalization ===")
|
||||
llm.reset_cost() # finalization-only cost attribution
|
||||
report = finalize_review(job_id, out_dir)
|
||||
cost = llm.get_cost()
|
||||
backend.jobs._log_cost_summary({
|
||||
"cost_usd": round(cost["usd"], 4),
|
||||
"llm_calls": cost["calls"],
|
||||
"cached_calls": cost.get("cached", 0),
|
||||
"cost_by_stage": cost.get("by_stage", {}),
|
||||
"models_used": cost.get("models", {}),
|
||||
}, label="finalization")
|
||||
except Exception as e:
|
||||
try:
|
||||
_set(job_id, status="finalization_error", error=str(e),
|
||||
|
||||
Reference in New Issue
Block a user