AJAY KASU commited on
Commit
e2d0a40
·
1 Parent(s): 911b780

Fix: Add support for Bytez API response schema to resolve raw JSON output

Browse files
Files changed (1) hide show
  1. ai/ai_reporter.py +6 -2
ai/ai_reporter.py CHANGED
@@ -52,8 +52,12 @@ class AIReporter:
52
 
53
  result = response.json()
54
  # Handle different common response formats
55
- if isinstance(result, dict) and "choices" in result:
56
- return result["choices"][0]["message"]["content"]
 
 
 
 
57
  elif isinstance(result, str):
58
  return result
59
  else:
 
52
 
53
  result = response.json()
54
  # Handle different common response formats
55
+ if isinstance(result, dict):
56
+ if "choices" in result: # Standard OpenAI format
57
+ return result["choices"][0]["message"]["content"]
58
+ if "output" in result and isinstance(result["output"], dict) and "content" in result["output"]: # Bytez format
59
+ return result["output"]["content"]
60
+ return str(result)
61
  elif isinstance(result, str):
62
  return result
63
  else: