Show OpenAI API error details for LLM failures
This commit is contained in:
+8
-1
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user