From 487cb830806dbcd6bba371bc10107f6fcb0dd787 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Tue, 17 Mar 2026 00:54:56 -0400 Subject: [PATCH] Show OpenAI API error details for LLM failures --- engine_llm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine_llm.py b/engine_llm.py index b8b7eaf..4a8804b 100644 --- a/engine_llm.py +++ b/engine_llm.py @@ -16,6 +16,7 @@ import argparse import multiprocessing import os import re +import json import requests from collections import deque @@ -102,7 +103,13 @@ def run_llm_processor(in_queue, out_queue, args): headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}, timeout=getattr(args, "post_correct_llm_timeout", 8.0), ) - response.raise_for_status() + if response.status_code >= 400: + try: + payload = response.json() + detail = json.dumps(payload, ensure_ascii=True) + except Exception: + detail = response.text.strip() + raise RuntimeError(f"OpenAI API error {response.status_code}: {detail}") return response.json()["choices"][0]["message"]["content"].strip() def call_ollama(prompt, temperature):