-
Couldn't load subscription status.
- Fork 60.9k
add: model gpt-5 #6599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: model gpt-5 #6599
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -200,6 +200,7 @@ export class ChatGPTApi implements LLMApi { | |||||||||||||||||||||
| options.config.model.startsWith("o1") || | ||||||||||||||||||||||
| options.config.model.startsWith("o3") || | ||||||||||||||||||||||
| options.config.model.startsWith("o4-mini"); | ||||||||||||||||||||||
| const isGpt5 = options.config.model.startsWith("gpt-5"); | ||||||||||||||||||||||
| if (isDalle3) { | ||||||||||||||||||||||
| const prompt = getMessageTextContent( | ||||||||||||||||||||||
| options.messages.slice(-1)?.pop() as any, | ||||||||||||||||||||||
|
|
@@ -230,15 +231,21 @@ export class ChatGPTApi implements LLMApi { | |||||||||||||||||||||
| messages, | ||||||||||||||||||||||
| stream: options.config.stream, | ||||||||||||||||||||||
| model: modelConfig.model, | ||||||||||||||||||||||
| temperature: !isO1OrO3 ? modelConfig.temperature : 1, | ||||||||||||||||||||||
| temperature: (!isO1OrO3 && !isGpt5) ? modelConfig.temperature : 1, | ||||||||||||||||||||||
| presence_penalty: !isO1OrO3 ? modelConfig.presence_penalty : 0, | ||||||||||||||||||||||
| frequency_penalty: !isO1OrO3 ? modelConfig.frequency_penalty : 0, | ||||||||||||||||||||||
| top_p: !isO1OrO3 ? modelConfig.top_p : 1, | ||||||||||||||||||||||
| // max_tokens: Math.max(modelConfig.max_tokens, 1024), | ||||||||||||||||||||||
| // Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore. | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (isO1OrO3) { | ||||||||||||||||||||||
| if (isGpt5) { | ||||||||||||||||||||||
| // Remove max_tokens if present | ||||||||||||||||||||||
| delete requestPayload.max_tokens; | ||||||||||||||||||||||
| // Add max_completion_tokens (or max_completion_tokens if that's what you meant) | ||||||||||||||||||||||
| requestPayload["max_completion_tokens"] = modelConfig.max_tokens; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+242
to
+247
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion TS safety and clarity: avoid deleting from a union-typed payload; set max_completion_tokens via a narrowed alias delete on a union (RequestPayload | DalleRequestPayload) can trip TS checks. Also the comment repeats “max_completion_tokens”. Apply: - if (isGpt5) {
- // Remove max_tokens if present
- delete requestPayload.max_tokens;
- // Add max_completion_tokens (or max_completion_tokens if that's what you meant)
- requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
- } else if (isO1OrO3) {
+ if (isGpt5) {
+ // GPT‑5 uses max_completion_tokens
+ const payload = requestPayload as RequestPayload;
+ payload.max_completion_tokens = modelConfig.max_tokens;
+ } else if (isO1OrO3) {This avoids delete on a union and fixes the comment. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| } else if (isO1OrO3) { | ||||||||||||||||||||||
| // by default the o1/o3 models will not attempt to produce output that includes markdown formatting | ||||||||||||||||||||||
| // manually add "Formatting re-enabled" developer message to encourage markdown inclusion in model responses | ||||||||||||||||||||||
| // (https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/reasoning?tabs=python-secure#markdown-output) | ||||||||||||||||||||||
|
|
@@ -251,8 +258,9 @@ export class ChatGPTApi implements LLMApi { | |||||||||||||||||||||
| requestPayload["max_completion_tokens"] = modelConfig.max_tokens; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // add max_tokens to vision model | ||||||||||||||||||||||
| if (visionModel && !isO1OrO3) { | ||||||||||||||||||||||
| if (visionModel && !isO1OrO3 && ! isGpt5) { | ||||||||||||||||||||||
| requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -493,6 +493,7 @@ export const VISION_MODEL_REGEXES = [ | |||||||||||||
| /o3/, | ||||||||||||||
| /o4-mini/, | ||||||||||||||
| /grok-4/i, | ||||||||||||||
| /gpt-5/ | ||||||||||||||
| ]; | ||||||||||||||
|
Comment on lines
+496
to
497
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainAvoid blanket vision classification for all GPT‑5 variants Using /gpt-5/ will flag nano/mini variants as vision-capable, which may cause image payloads to be sent to text-only models. Narrow the regex. Apply: - /grok-4/i,
- /gpt-5/
+ /grok-4/i,
+ /gpt-5(?!-(nano|mini))/If specific GPT‑5 vision SKUs differ, switch to an explicit allowlist instead of a broad regex. Please verify GPT‑5 nano/mini image-input support in current docs. 🌐 Web query: 💡 Result: GPT-5 Full supports image (vision) inputs via the chat/completions API, but gpt-5-mini and gpt-5-nano are either limited or do not have native support for image (image_url) content as input. Details and evidence:
Conclusion: Citations:
Narrow GPT-5 Regex to Exclude Non-Vision Variants Please update the regex in - /grok-4/i,
- /gpt-5/
+ /grok-4/i,
+ /gpt-5(?!-(nano|mini))/If OpenAI introduces new GPT-5 SKUs with vision support in the future, switch to an explicit allowlist for better precision. 🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/]; | ||||||||||||||
|
|
@@ -517,6 +518,11 @@ const openaiModels = [ | |||||||||||||
| "gpt-4.1-nano-2025-04-14", | ||||||||||||||
| "gpt-4.5-preview", | ||||||||||||||
| "gpt-4.5-preview-2025-02-27", | ||||||||||||||
| "gpt-5-chat", | ||||||||||||||
| "gpt-5-mini", | ||||||||||||||
| "gpt-5-nano", | ||||||||||||||
| "gpt-5", | ||||||||||||||
| "gpt-5-chat-2025-01-01-preview", | ||||||||||||||
| "gpt-4o", | ||||||||||||||
| "gpt-4o-2024-05-13", | ||||||||||||||
| "gpt-4o-2024-08-06", | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Confirm intent: forcing temperature=1 for GPT‑5
You’re forcing temperature=1 for GPT‑5 (similar to o1/o3/o4-mini) but leaving other sampling params (top_p, penalties) unchanged. Verify this matches GPT‑5 API semantics.
Optionally, extract a single guard to clarify intent:
🌐 Web query:
💡 Result:
Yes, OpenAI's GPT-5 model supports the
temperature,top_p,presence_penalty, andfrequency_penaltyparameters in its chat/completions API, similar to previous GPT models. These parameters allow you to control various aspects of the model's output:temperature: Controls the randomness of the model's responses. Lower values (e.g., 0.2) make the output more deterministic, while higher values (e.g., 0.8) increase randomness and creativity. (medium.com)top_p: Also known as nucleus sampling, this parameter determines the cumulative probability threshold for token selection. A value of 0.9 means the model considers the smallest set of tokens whose cumulative probability is at least 90%. (medium.com)presence_penalty: Encourages the model to introduce new topics by penalizing tokens that have already appeared in the text. Positive values increase the likelihood of discussing new topics. (notes.kodekloud.com)frequency_penalty: Reduces the model's tendency to repeat the same tokens by penalizing tokens based on their existing frequency in the text. Positive values decrease the likelihood of repetition. (notes.kodekloud.com)These parameters are designed to be flexible and can be adjusted to suit your specific application needs. For example, setting
temperatureto 0.0 andtop_pto 0.0 can produce deterministic outputs, while higher values can generate more diverse and creative responses. (notes.kodekloud.com)It's important to note that while these parameters are supported in GPT-5, the optimal settings may vary depending on your specific use case and desired output characteristics.
Citations:
Remove GPT-5 special-case for temperature
GPT-5 supports
temperature,top_p,presence_penalty, andfrequency_penaltyjust like other GPT models. We shouldn’t forcetemperature = 1only for GPT-5—let it usemodelConfig.temperatureunless we have a clear reason to pin it. Please update inapp/client/platforms/openai.tsaround lines 234–238:This removes the
isGpt5check so GPT-5 calls remain configurable.📝 Committable suggestion
🤖 Prompt for AI Agents