OpenAI: Add gpt-5.5, gpt-5.4-mini/nano, gpt-image-2 (#5529)
* feat: gpt-image-2 for OpenAI image generation * gpt-5.5 Co-authored-by: Copilot <copilot@github.com> * fix: adjust reasoning effort mapping Co-authored-by: Copilot <copilot@github.com> * fix: html format --------- Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -54,7 +54,14 @@
|
||||
<option data-type="cohere" value="c4ai-aya-vision-8b">c4ai-aya-vision-8b</option>
|
||||
<option data-type="cohere" value="c4ai-aya-vision-32b">c4ai-aya-vision-32b</option>
|
||||
<option data-type="cohere" value="command-a-vision-07-2025">command-a-vision-07-2025</option>
|
||||
<option data-type="openai" value="gpt-5.5">gpt-5.5</option>
|
||||
<option data-type="openai" value="gpt-5.5-2026-04-23">gpt-5.5-2026-04-23</option>
|
||||
<option data-type="openai" value="gpt-5.4">gpt-5.4</option>
|
||||
<option data-type="openai" value="gpt-5.4-2026-03-05">gpt-5.4-2026-03-05</option>
|
||||
<option data-type="openai" value="gpt-5.4-mini">gpt-5.4-mini</option>
|
||||
<option data-type="openai" value="gpt-5.4-mini-2026-03-17">gpt-5.4-mini-2026-03-17</option>
|
||||
<option data-type="openai" value="gpt-5.4-nano">gpt-5.4-nano</option>
|
||||
<option data-type="openai" value="gpt-5.4-nano-2026-03-17">gpt-5.4-nano-2026-03-17</option>
|
||||
<option data-type="openai" value="gpt-5.3-chat-latest">gpt-5.3-chat-latest</option>
|
||||
<option data-type="openai" value="gpt-5.2">gpt-5.2</option>
|
||||
<option data-type="openai" value="gpt-5.2-2025-12-11">gpt-5.2-2025-12-11</option>
|
||||
|
||||
@@ -2382,6 +2382,8 @@ async function loadDrawthingsModels() {
|
||||
|
||||
async function loadOpenAiModels() {
|
||||
return [
|
||||
{ value: 'gpt-image-2', text: 'gpt-image-2' },
|
||||
{ value: 'gpt-image-2-2026-04-21', text: 'gpt-image-2-2026-04-21' },
|
||||
{ value: 'gpt-image-1.5', text: 'gpt-image-1.5' },
|
||||
{ value: 'gpt-image-1-mini', text: 'gpt-image-1-mini' },
|
||||
{ value: 'gpt-image-1', text: 'gpt-image-1' },
|
||||
@@ -4075,7 +4077,7 @@ async function generateOpenAiImage(prompt, signal) {
|
||||
|
||||
const isDalle2 = /dall-e-2/.test(extension_settings.sd.model);
|
||||
const isDalle3 = /dall-e-3/.test(extension_settings.sd.model);
|
||||
const isGptImg = /gpt-image-(1|latest)/.test(extension_settings.sd.model);
|
||||
const isGptImg = /gpt-image-(1|2|latest)/.test(extension_settings.sd.model);
|
||||
const isSora2 = /sora-2/.test(extension_settings.sd.model);
|
||||
|
||||
if (isDalle2 && prompt.length > dalle2PromptLimit) {
|
||||
|
||||
+44
-35
@@ -2530,9 +2530,16 @@ function getReasoningEffort(settings = null, model = null) {
|
||||
return 'none';
|
||||
}
|
||||
|
||||
return [chat_completion_sources.OPENAI, chat_completion_sources.AZURE_OPENAI].includes(settings.chat_completion_source) && /^gpt-5/.test(model)
|
||||
? reasoning_effort_types.min
|
||||
: reasoning_effort_types.low;
|
||||
if ([chat_completion_sources.OPENAI, chat_completion_sources.AZURE_OPENAI].includes(settings.chat_completion_source)) {
|
||||
if (/^gpt-5\.(4|5)/.test(model)) {
|
||||
return 'none';
|
||||
}
|
||||
if (/^gpt-5/.test(model)) {
|
||||
return reasoning_effort_types.min;
|
||||
}
|
||||
}
|
||||
|
||||
return reasoning_effort_types.low;
|
||||
case reasoning_effort_types.max:
|
||||
return reasoning_effort_types.high;
|
||||
default:
|
||||
@@ -2945,7 +2952,7 @@ export async function createGenerationParameters(settings, model, type, messages
|
||||
if (/gpt-5-chat-latest/.test(model)) {
|
||||
delete generate_data.tools;
|
||||
delete generate_data.tool_choice;
|
||||
} else if (/gpt-5\.(1|2|3|4)/.test(model) && !/chat-latest/.test(model)) {
|
||||
} else if (/gpt-5\.(1|2|3|4)/.test(model) && !/chat-latest/.test(model) && !generate_data.reasoning_effort) {
|
||||
delete generate_data.frequency_penalty;
|
||||
delete generate_data.presence_penalty;
|
||||
delete generate_data.logit_bias;
|
||||
@@ -4887,41 +4894,43 @@ function onSettingsPresetChange() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum context size for the OpenAI model
|
||||
* @param {string} value Model identifier
|
||||
* @returns {number} Maximum context size in tokens
|
||||
*/
|
||||
function getMaxContextOpenAI(value) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
return unlocked_max;
|
||||
} else if (value.startsWith('gpt-5.4')) {
|
||||
return max_1mil;
|
||||
} else if (value.startsWith('gpt-5')) {
|
||||
return max_400k;
|
||||
} else if (value.includes('gpt-4.1')) {
|
||||
return max_1mil;
|
||||
} else if (value.includes('gpt-audio')) {
|
||||
return max_128k;
|
||||
} else if (value.startsWith('o1')) {
|
||||
return max_128k;
|
||||
} else if (value.startsWith('o4') || value.startsWith('o3')) {
|
||||
return max_200k;
|
||||
} else if (value.includes('chatgpt-4o-latest') || value.includes('gpt-4-turbo') || value.includes('gpt-4o') || value.includes('gpt-4-1106') || value.includes('gpt-4-0125') || value.includes('gpt-4-vision')) {
|
||||
return max_128k;
|
||||
} else if (value.includes('gpt-3.5-turbo-1106')) {
|
||||
return max_16k;
|
||||
} else if (['gpt-4', 'gpt-4-0314', 'gpt-4-0613'].includes(value)) {
|
||||
return max_8k;
|
||||
} else if (['gpt-4-32k', 'gpt-4-32k-0314', 'gpt-4-32k-0613'].includes(value)) {
|
||||
return max_32k;
|
||||
} else if (value.includes('gpt-realtime')) {
|
||||
return max_32k;
|
||||
} else if (['gpt-3.5-turbo-16k', 'gpt-3.5-turbo-16k-0613'].includes(value)) {
|
||||
return max_16k;
|
||||
} else if (value == 'code-davinci-002') {
|
||||
return max_8k;
|
||||
} else if (['text-curie-001', 'text-babbage-001', 'text-ada-001'].includes(value)) {
|
||||
return max_2k;
|
||||
} else {
|
||||
// default to gpt-3 (4095 tokens)
|
||||
return max_4k;
|
||||
}
|
||||
|
||||
/** @type {[RegExp, number][]} */
|
||||
const contextMap = [
|
||||
[/^gpt-5\.[45]/, max_1mil],
|
||||
[/^gpt-5/, max_400k],
|
||||
[/gpt-4\.1/, max_1mil],
|
||||
[/gpt-audio/, max_128k],
|
||||
[/^o1/, max_128k],
|
||||
[/^o[34]/, max_200k],
|
||||
[/chatgpt-4o-latest|gpt-4-turbo|gpt-4o|gpt-4-1106|gpt-4-0125|gpt-4-vision/, max_128k],
|
||||
[/gpt-3\.5-turbo-1106/, max_16k],
|
||||
[/^(gpt-4|gpt-4-0314|gpt-4-0613)$/, max_8k],
|
||||
[/^(gpt-4-32k|gpt-4-32k-0314|gpt-4-32k-0613)$/, max_32k],
|
||||
[/gpt-realtime/, max_32k],
|
||||
[/^(gpt-3\.5-turbo-16k|gpt-3\.5-turbo-16k-0613)$/, max_16k],
|
||||
[/^code-davinci-002$/, max_8k],
|
||||
[/^(text-curie-001|text-babbage-001|text-ada-001)$/, max_2k],
|
||||
[/gpt-3/, max_4k],
|
||||
];
|
||||
|
||||
for (const [regex, max] of contextMap) {
|
||||
if (regex.test(value)) {
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
||||
// Safe default for most modern models
|
||||
return max_128k;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user