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).
This commit is contained in:
parent
6400a5eacb
commit
31fc7946a0
1 changed files with 8 additions and 2 deletions
10
app.py
10
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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue