mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
ci(issue-triage): use responses API for gpt-5; auto-select endpoint per model; keep fallback to gpt-4o-mini (no push)
This commit is contained in:
@@ -180,10 +180,9 @@ jobs:
|
||||
core.setOutput('reason', 'Missing OPENAI_API_KEY for safety screening.');
|
||||
core.notice('Safety: block (no OPENAI_API_KEY)');
|
||||
} else {
|
||||
async function callModel(model) {
|
||||
const payload = {
|
||||
model,
|
||||
messages: [
|
||||
async function callModelAuto(model) {
|
||||
const isResponses = model && model.startsWith('gpt-5');
|
||||
const common = [
|
||||
{
|
||||
role: 'system',
|
||||
content: [
|
||||
@@ -203,25 +202,29 @@ jobs:
|
||||
actor: context.actor
|
||||
})
|
||||
}
|
||||
],
|
||||
temperature: 0.1,
|
||||
response_format: { type: 'json_object' }
|
||||
};
|
||||
const res = await fetch('https://api.openai.com/v1/chat/completions', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
return res;
|
||||
];
|
||||
if (isResponses) {
|
||||
const payload = { model, input: common, temperature: 0.1, response_format: { type: 'json_object' } };
|
||||
return fetch('https://api.openai.com/v1/responses', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
} else {
|
||||
const payload = { model, messages: common, temperature: 0.1, response_format: { type: 'json_object' } };
|
||||
return fetch('https://api.openai.com/v1/chat/completions', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Try requested model first, then fall back on 400 to a known-good
|
||||
let res = await callModel('gpt-5');
|
||||
// Prefer gpt-5 via responses; on failure fall back to gpt-4o-mini via chat
|
||||
let res = await callModelAuto('gpt-5');
|
||||
if (!res.ok) {
|
||||
if (res.status === 400) {
|
||||
core.notice('Safety: gpt-5 returned 400; falling back to gpt-4o-mini');
|
||||
res = await callModel('gpt-4o-mini');
|
||||
}
|
||||
core.notice(`Safety: gpt-5 API ${res.status} ${res.statusText}; falling back to gpt-4o-mini`);
|
||||
res = await callModelAuto('gpt-4o-mini');
|
||||
}
|
||||
if (!res.ok) {
|
||||
core.setOutput('decision', 'comment_only');
|
||||
|
||||
Reference in New Issue
Block a user