mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
Fix: Add better API error handling and logging
This commit is contained in:
@@ -28,6 +28,10 @@ const apiCall = async (prompt, model, temp, effort) => {
|
|||||||
},
|
},
|
||||||
{ headers: { Authorization: `Bearer ${process.env.OPENROUTER_KEY}` } }
|
{ headers: { Authorization: `Bearer ${process.env.OPENROUTER_KEY}` } }
|
||||||
);
|
);
|
||||||
|
if (!res.data.choices || !res.data.choices[0]) {
|
||||||
|
console.error('API Response:', JSON.stringify(res.data, null, 2));
|
||||||
|
throw new Error('Invalid API response structure');
|
||||||
|
}
|
||||||
return res.data.choices[0].message.content;
|
return res.data.choices[0].message.content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user