Spaces:
Sleeping
Sleeping
Update app.py
Browse files125 unmodified lines126127128129130131132238 unmodified lines3713723733743753763773783793803813823833843853863873883891 unmodified line391392393394395396397398399400125 unmodified linesThe label MUST start with `filename:`. Do not output partial files or diffs.If a fix is minor (typo, one-liner), just describe it β don't re-output the whole file.Only re-output files that have real bugs or missing pieces.""",}# ββ Provider / model catalogue ββββββββββββββββββββββββββββββββββββββββββββββββ238 unmodified linesyield (f"β Builder Agent failed: {e}", s_out, d_out, b_out, r_out, None)return# Stage 4 β Reviewtry:t0 = time.time()res = run_agent_with_fallback(reviewer_cfg,f"Original request:\n{prompt}\n\n--- Code to Review ---\n{b_out}","reviewer",)r_out = res["content"]except Exception as e:yield (f"β Code Review Agent failed: {e}", s_out, d_out, b_out, r_out, None)return# Packagetry:zip_path = build_zip({"strategy": s_out, "design": d_out}, b_out, r_out)1 unmodified linezip_path = Nonecode_files = {f["filename"] for f in extract_code_files(b_out) + extract_code_files(r_out)}yield (f"π **Pipeline complete!** {len(code_files)} file(s) generated. "f"Click **Download Project** to get your ZIP.",s_out, d_out, b_out, r_out, zip_path,)125 unmodified lines126127128129130131132133134135136137138139140141142143144145146147148149150151238 unmodified lines3903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734741 unmodified line476477478479480481482483484485486487125 unmodified linesThe label MUST start with `filename:`. Do not output partial files or diffs.If a fix is minor (typo, one-liner), just describe it β don't re-output the whole file.Only re-output files that have real bugs or missing pieces.REQUIRED β end every review with this structured block (no exceptions):## VERDICTVERDICT: SHIP_IT(Replace SHIP_IT with MINOR_FIXES if only cosmetic/edge-case issues exist,or MAJOR_REWORK if any core feature is broken, missing, or non-functional.)CHECKLIST (score each item against the original request):- UI renders correctly on first load (no blank canvas, no layout breaks): PASS/FAIL- Core feature 1 [name it]: PASS/FAIL- Core feature 2 [name it]: PASS/FAIL- Core feature 3 [name it]: PASS/FAIL- Progressive disclosure (interactive sections hidden until needed): PASS/FAIL- Works immediately without a server / with stated run command: PASS/FAILUse MAJOR_REWORK if ANY core feature is FAIL.List specific failure reasons so the builder knows exactly what to fix.""",}# ββ Provider / model catalogue ββββββββββββββββββββββββββββββββββββββββββββββββ238 unmodified linesyield (f"β Builder Agent failed: {e}", s_out, d_out, b_out, r_out, None)return# Stage 4 β Review + iteration loop (up to MAX_FIX_ROUNDS fix passes)MAX_FIX_ROUNDS = 2def _run_reviewer(b_text):res = run_agent_with_fallback(reviewer_cfg,f"Original request:\n{prompt}\n\n--- Code to Review ---\n{b_text}","reviewer",)return resdef _verdict(r_text):if "MAJOR_REWORK" in r_text:return "MAJOR_REWORK"if "MINOR_FIXES" in r_text:return "MINOR_FIXES"return "SHIP_IT"try:t0 = time.time()res = _run_reviewer(b_out)r_out = res["content"]yield (f"β Review done ({res['input_tokens']+res['output_tokens']:,} tok, {round(time.time()-t0,1)}s) "f"β verdict: **{_verdict(r_out)}**",s_out, d_out, b_out, r_out, None,)except Exception as e:yield (f"β Code Review Agent failed: {e}", s_out, d_out, b_out, r_out, None)return# Fix iteration loopfor fix_round in range(MAX_FIX_ROUNDS):if _verdict(r_out) != "MAJOR_REWORK":breakyield (f"π **Fix round {fix_round + 1}/{MAX_FIX_ROUNDS}** β Builder re-running with reviewer feedbackβ¦",s_out, d_out, b_out, r_out, None,)try:t0 = time.time()res = run_agent_with_fallback(builder_cfg,(f"ORIGINAL REQUEST:\n{prompt}\n\n"f"--- Strategy ---\n{s_out}\n\n"f"--- Design Spec ---\n{d_out}\n\n"f"--- Your previous build (fix this) ---\n{b_out}\n\n"f"--- Code review failures to fix ---\n{r_out}\n\n""Fix EVERY item marked FAIL in the checklist above. ""Output complete corrected files using the filename: format. ""Do not change anything already marked PASS. ""Zero placeholders. Zero truncation."),"builder",)b_out = res["content"]yield (f"β Fix round {fix_round + 1} build done ({res['input_tokens']+res['output_tokens']:,} tok, {round(time.time()-t0,1)}s) "f"β used **{res['model']}**\nπ Re-reviewingβ¦",s_out, d_out, b_out, r_out, None,)except Exception as e:yield (f"β Fix round {fix_round + 1} failed: {e}", s_out, d_out, b_out, r_out, None)breaktry:t0 = time.time()res = _run_reviewer(b_out)r_out = res["content"]yield (f"β Re-review done ({res['input_tokens']+res['output_tokens']:,} tok, {round(time.time()-t0,1)}s) "f"β verdict: **{_verdict(r_out)}**",s_out, d_out, b_out, r_out, None,)except Exception as e:yield (f"β Re-review failed: {e}", s_out, d_out, b_out, r_out, None)break# Packagetry:zip_path = build_zip({"strategy": s_out, "design": d_out}, b_out, r_out)1 unmodified linezip_path = Nonecode_files = {f["filename"] for f in extract_code_files(b_out) + extract_code_files(r_out)}final_verdict = _verdict(r_out)verdict_emoji = "π" if final_verdict == "SHIP_IT" else "β οΈ" if final_verdict == "MINOR_FIXES" else "π§"yield (f"{verdict_emoji} **Pipeline complete!** {len(code_files)} file(s) generated. "f"Final verdict: **{final_verdict}**. Click **Download Project** to get your ZIP.",s_out, d_out, b_out, r_out, zip_path,)
app.py+94-7