From 31fc7946a0274bbe7263e16a386f57abe7db6756 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sun, 30 Nov 2025 12:04:51 -0500 Subject: [PATCH] Improve code auto-fix: prefer Qwen Coder with Hermes fallback Update /api/fix-code endpoint to try MODEL_3 (Qwen Coder) first for better code generation, with graceful fallback to MODEL_1 (Hermes) if MODEL_3 is unavailable or returns errors. This ensures the auto-fix feature works reliably even when specialized code models are temporarily unavailable (e.g., 502 errors). --- app.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index d9be3c6..6ba8b78 100644 --- a/app.py +++ b/app.py @@ -868,8 +868,14 @@ def fix_code(): if not code or not language: return jsonify({"error": "Code and language are required"}), 400 - # Use MODEL_1 (Hermes) to fix the code - client, model = get_openai_client_and_model("MODEL_1") + # Try MODEL_3 (Qwen Coder) first for better code fixing, fall back to MODEL_1 (Hermes) + try: + client, model = get_openai_client_and_model("MODEL_3") + print(f"[INFO] Using MODEL_3 for code fixing: {model}") + except Exception as e: + print(f"[WARN] MODEL_3 not available, falling back to MODEL_1: {e}") + client, model = get_openai_client_and_model("MODEL_1") + print(f"[INFO] Using MODEL_1 for code fixing: {model}") system_prompt = f"""You are an expert {language} programmer and debugger. Your task is to fix code that has errors.