Changesets · Branches · Tags · Compare
| Changeset | 14054b80f18da577c17d108f74219467028ccd3cbca4fe94d63f630a69155200 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-08-07 13:36 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-08-07 13:36 -07:00 |
| Parents | a62a835baa95 |
7 files changed
modified core/llm/llms/OpenAI.test.ts +16 −16
| @@ -5,30 +5,30 @@ | ||
| 5 | 5 | const openai = new OpenAI({ |
| 6 | 6 | model: "o3-mini", |
| 7 | 7 | }); |
| 8 | - expect(openai.isOSeriesModel("o4-mini")).toBeTruthy(); | |
| 9 | - expect(openai.isOSeriesModel("o3-mini")).toBeTruthy(); | |
| 10 | - expect(openai.isOSeriesModel("o1-mini")).toBeTruthy(); | |
| 11 | - expect(openai.isOSeriesModel("o1")).toBeTruthy(); | |
| 12 | - expect(openai.isOSeriesModel("o3")).toBeTruthy(); | |
| 8 | + expect(openai.isOSeriesOrGpt5Model("o4-mini")).toBeTruthy(); | |
| 9 | + expect(openai.isOSeriesOrGpt5Model("o3-mini")).toBeTruthy(); | |
| 10 | + expect(openai.isOSeriesOrGpt5Model("o1-mini")).toBeTruthy(); | |
| 11 | + expect(openai.isOSeriesOrGpt5Model("o1")).toBeTruthy(); | |
| 12 | + expect(openai.isOSeriesOrGpt5Model("o3")).toBeTruthy(); | |
| 13 | 13 | |
| 14 | 14 | // artificially correct samples for future models |
| 15 | - expect(openai.isOSeriesModel("o5-mini")).toBeTruthy(); | |
| 16 | - expect(openai.isOSeriesModel("o6")).toBeTruthy(); | |
| 17 | - expect(openai.isOSeriesModel("o77")).toBeTruthy(); | |
| 18 | - expect(openai.isOSeriesModel("o54-mini")).toBeTruthy(); | |
| 15 | + expect(openai.isOSeriesOrGpt5Model("o5-mini")).toBeTruthy(); | |
| 16 | + expect(openai.isOSeriesOrGpt5Model("o6")).toBeTruthy(); | |
| 17 | + expect(openai.isOSeriesOrGpt5Model("o77")).toBeTruthy(); | |
| 18 | + expect(openai.isOSeriesOrGpt5Model("o54-mini")).toBeTruthy(); | |
| 19 | 19 | }); |
| 20 | 20 | test("should identify incorrect o-series models", () => { |
| 21 | 21 | const openai = new OpenAI({ |
| 22 | 22 | model: "o3-mini", |
| 23 | 23 | }); |
| 24 | - expect(openai.isOSeriesModel("gpt-o4-mini")).toBeFalsy(); | |
| 25 | - expect(openai.isOSeriesModel("gpt-4.5")).toBeFalsy(); | |
| 26 | - expect(openai.isOSeriesModel("gpt-4.1")).toBeFalsy(); | |
| 24 | + expect(openai.isOSeriesOrGpt5Model("gpt-o4-mini")).toBeFalsy(); | |
| 25 | + expect(openai.isOSeriesOrGpt5Model("gpt-4.5")).toBeFalsy(); | |
| 26 | + expect(openai.isOSeriesOrGpt5Model("gpt-4.1")).toBeFalsy(); | |
| 27 | 27 | |
| 28 | 28 | // artificially wrong samples |
| 29 | - expect(openai.isOSeriesModel("os1")).toBeFalsy(); | |
| 30 | - expect(openai.isOSeriesModel("so1")).toBeFalsy(); | |
| 31 | - expect(openai.isOSeriesModel("ao31")).toBeFalsy(); | |
| 32 | - expect(openai.isOSeriesModel("1os")).toBeFalsy(); | |
| 29 | + expect(openai.isOSeriesOrGpt5Model("os1")).toBeFalsy(); | |
| 30 | + expect(openai.isOSeriesOrGpt5Model("so1")).toBeFalsy(); | |
| 31 | + expect(openai.isOSeriesOrGpt5Model("ao31")).toBeFalsy(); | |
| 32 | + expect(openai.isOSeriesOrGpt5Model("1os")).toBeFalsy(); | |
| 33 | 33 | }); |
| 34 | 34 | }); |
modified core/llm/llms/OpenAI.ts +8 −8
| @@ -36,12 +36,12 @@ | ||
| 36 | 36 | return model.startsWith("gpt") || model.startsWith("o"); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -const formatMessageForO1 = (messages: ChatCompletionMessageParam[]) => { | |
| 39 | +const formatMessageForO1OrGpt5 = (messages: ChatCompletionMessageParam[]) => { | |
| 40 | 40 | return messages?.map((message: any) => { |
| 41 | 41 | if (message?.role === "system") { |
| 42 | 42 | return { |
| 43 | 43 | ...message, |
| 44 | - role: "user", | |
| 44 | + role: "developer", | |
| 45 | 45 | }; |
| 46 | 46 | } |
| 47 | 47 | |
| @@ -77,8 +77,8 @@ | ||
| 77 | 77 | return model; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public isOSeriesModel(model?: string): boolean { | |
| 81 | - return !!model && !!model.match(/^o[0-9]+/); | |
| 80 | + public isOSeriesOrGpt5Model(model?: string): boolean { | |
| 81 | + return !!model && (!!model.match(/^o[0-9]+/) || model.includes("gpt-5")); | |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | private isFireworksAiModel(model?: string): boolean { |
| @@ -139,13 +139,13 @@ | ||
| 139 | 139 | finalOptions.stop = options.stop?.slice(0, this.getMaxStopWords()); |
| 140 | 140 | |
| 141 | 141 | // OpenAI o1-preview and o1-mini or o3-mini: |
| 142 | - if (this.isOSeriesModel(options.model)) { | |
| 142 | + if (this.isOSeriesOrGpt5Model(options.model)) { | |
| 143 | 143 | // a) use max_completion_tokens instead of max_tokens |
| 144 | 144 | finalOptions.max_completion_tokens = options.maxTokens; |
| 145 | 145 | finalOptions.max_tokens = undefined; |
| 146 | 146 | |
| 147 | 147 | // b) don't support system message |
| 148 | - finalOptions.messages = formatMessageForO1(finalOptions.messages); | |
| 148 | + finalOptions.messages = formatMessageForO1OrGpt5(finalOptions.messages); | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | if (options.model === "o1") { |
| @@ -241,13 +241,13 @@ | ||
| 241 | 241 | body.stop = body.stop?.slice(0, this.getMaxStopWords()); |
| 242 | 242 | |
| 243 | 243 | // OpenAI o1-preview and o1-mini or o3-mini: |
| 244 | - if (this.isOSeriesModel(body.model)) { | |
| 244 | + if (this.isOSeriesOrGpt5Model(body.model)) { | |
| 245 | 245 | // a) use max_completion_tokens instead of max_tokens |
| 246 | 246 | body.max_completion_tokens = body.max_tokens; |
| 247 | 247 | body.max_tokens = undefined; |
| 248 | 248 | |
| 249 | 249 | // b) don't support system message |
| 250 | - body.messages = formatMessageForO1(body.messages); | |
| 250 | + body.messages = formatMessageForO1OrGpt5(body.messages); | |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | if (body.model === "o1") { |
modified core/llm/toolSupport.ts +6 −4
| @@ -54,18 +54,20 @@ | ||
| 54 | 54 | return false; |
| 55 | 55 | }, |
| 56 | 56 | openai: (model) => { |
| 57 | + const lower = model.toLowerCase(); | |
| 57 | 58 | // https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling |
| 58 | 59 | if ( |
| 59 | - model.toLowerCase().startsWith("gpt-4") || | |
| 60 | - model.toLowerCase().startsWith("o3") | |
| 60 | + lower.startsWith("gpt-4") || | |
| 61 | + lower.startsWith("gpt-5") || | |
| 62 | + lower.startsWith("o3") | |
| 61 | 63 | ) { |
| 62 | 64 | return true; |
| 63 | 65 | } |
| 64 | - if (model.toLowerCase().includes("gpt-oss")) { | |
| 66 | + if (lower.includes("gpt-oss")) { | |
| 65 | 67 | return true; |
| 66 | 68 | } |
| 67 | 69 | // https://ai.google.dev/gemma/docs/capabilities/function-calling |
| 68 | - if (model.toLowerCase().startsWith("gemma")) { | |
| 70 | + if (lower.startsWith("gemma")) { | |
| 69 | 71 | return true; |
| 70 | 72 | } |
| 71 | 73 | // firworks-ai https://docs.fireworks.ai/guides/function-calling |
modified gui/src/pages/AddNewModel/configs/models.ts +12 −0
| @@ -1095,6 +1095,18 @@ | ||
| 1095 | 1095 | icon: "cohere.png", |
| 1096 | 1096 | isOpenSource: false, |
| 1097 | 1097 | }, |
| 1098 | + gpt5: { | |
| 1099 | + title: "GPT-5", | |
| 1100 | + description: "OpenAI's next-generation, high-intelligence flagship model", | |
| 1101 | + params: { | |
| 1102 | + model: "gpt-5", | |
| 1103 | + contextLength: 400_000, | |
| 1104 | + title: "GPT-5", | |
| 1105 | + }, | |
| 1106 | + providerOptions: ["openai"], | |
| 1107 | + icon: "openai.png", | |
| 1108 | + isOpenSource: false, | |
| 1109 | + }, | |
| 1098 | 1110 | gpt4turbo: { |
| 1099 | 1111 | title: "GPT-4 Turbo", |
| 1100 | 1112 | description: |
modified gui/src/pages/AddNewModel/configs/providers.ts +3 −2
| @@ -52,12 +52,13 @@ | ||
| 52 | 52 | openai: { |
| 53 | 53 | title: "OpenAI", |
| 54 | 54 | provider: "openai", |
| 55 | - description: "Use gpt-4, gpt-3.5-turbo, or any other OpenAI model", | |
| 55 | + description: "Use gpt-5, gpt-4, or any other OpenAI model", | |
| 56 | 56 | longDescription: |
| 57 | - "Use gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.", | |
| 57 | + "Use gpt-5, gpt-4, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.", | |
| 58 | 58 | icon: "openai.png", |
| 59 | 59 | tags: [ModelProviderTags.RequiresApiKey], |
| 60 | 60 | packages: [ |
| 61 | + models.gpt5, | |
| 61 | 62 | models.gpt4o, |
| 62 | 63 | models.gpt4omini, |
| 63 | 64 | models.gpt4turbo, |
modified packages/llm-info/src/providers/openai.ts +9 −0
| @@ -75,6 +75,15 @@ | ||
| 75 | 75 | contextLength: 128000, |
| 76 | 76 | maxCompletionTokens: 4096, |
| 77 | 77 | }, |
| 78 | + // gpt-5 | |
| 79 | + { | |
| 80 | + model: "gpt-5", | |
| 81 | + displayName: "GPT-5", | |
| 82 | + contextLength: 400000, | |
| 83 | + maxCompletionTokens: 128000, | |
| 84 | + regex: /gpt-5/, | |
| 85 | + recommendedFor: ["chat"], | |
| 86 | + }, | |
| 78 | 87 | // gpt-4o |
| 79 | 88 | { |
| 80 | 89 | model: "gpt-4o", |
modified packages/openai-adapters/src/apis/OpenAI.ts +1 −1
| @@ -38,7 +38,7 @@ | ||
| 38 | 38 | // o-series models - only apply for official OpenAI API |
| 39 | 39 | const isOfficialOpenAIAPI = this.apiBase === "https://api.openai.com/v1/"; |
| 40 | 40 | if (isOfficialOpenAIAPI) { |
| 41 | - if (body.model.startsWith("o")) { | |
| 41 | + if (body.model.startsWith("o") || body.model.includes("gpt-5")) { | |
| 42 | 42 | // a) use max_completion_tokens instead of max_tokens |
| 43 | 43 | body.max_completion_tokens = body.max_tokens; |
| 44 | 44 | body.max_tokens = undefined; |