mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-06 02:47:56 +00:00
feat: add GPT-5 model support
- Added GPT-5 models (gpt-5-2025-08-07, gpt-5-mini-2025-08-07, gpt-5-nano-2025-08-07) - Added nectarine-alpha-new-reasoning-effort-2025-07-25 experimental model - Set gpt-5-2025-08-07 as default OpenAI Native model - Implemented GPT-5 specific handling with streaming and reasoning effort support
This commit is contained in:
parent
7ea1ae570a
commit
0e7abee715
3 changed files with 70 additions and 1 deletions
11
.changeset/gpt5-support.md
Normal file
11
.changeset/gpt5-support.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
"@roo-code/types": minor
|
||||
"roo-cline": minor
|
||||
---
|
||||
|
||||
Add GPT-5 model support
|
||||
|
||||
- Added GPT-5 models (gpt-5-2025-08-07, gpt-5-mini-2025-08-07, gpt-5-nano-2025-08-07) to OpenAI Native provider
|
||||
- Added nectarine-alpha-new-reasoning-effort-2025-07-25 experimental model
|
||||
- Set gpt-5-2025-08-07 as the new default OpenAI Native model
|
||||
- Implemented GPT-5 specific handling with streaming and reasoning effort support
|
||||
|
|
@ -3,9 +3,45 @@ import type { ModelInfo } from "../model.js"
|
|||
// https://openai.com/api/pricing/
|
||||
export type OpenAiNativeModelId = keyof typeof openAiNativeModels
|
||||
|
||||
export const openAiNativeDefaultModelId: OpenAiNativeModelId = "gpt-4.1"
|
||||
export const openAiNativeDefaultModelId: OpenAiNativeModelId = "gpt-5-2025-08-07"
|
||||
|
||||
export const openAiNativeModels = {
|
||||
"gpt-5-2025-08-07": {
|
||||
maxTokens: 128000,
|
||||
contextWindow: 256000,
|
||||
supportsImages: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 1.25,
|
||||
outputPrice: 10.0,
|
||||
cacheReadsPrice: 0.125,
|
||||
},
|
||||
"gpt-5-mini-2025-08-07": {
|
||||
maxTokens: 128000,
|
||||
contextWindow: 256000,
|
||||
supportsImages: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 0.25,
|
||||
outputPrice: 2.0,
|
||||
cacheReadsPrice: 0.025,
|
||||
},
|
||||
"gpt-5-nano-2025-08-07": {
|
||||
maxTokens: 128000,
|
||||
contextWindow: 256000,
|
||||
supportsImages: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 0.05,
|
||||
outputPrice: 0.4,
|
||||
cacheReadsPrice: 0.005,
|
||||
},
|
||||
"nectarine-alpha-new-reasoning-effort-2025-07-25": {
|
||||
maxTokens: 128000,
|
||||
contextWindow: 256000,
|
||||
supportsImages: true,
|
||||
supportsPromptCache: true,
|
||||
inputPrice: 0,
|
||||
outputPrice: 0,
|
||||
cacheReadsPrice: 0,
|
||||
},
|
||||
"gpt-4.1": {
|
||||
maxTokens: 32_768,
|
||||
contextWindow: 1_047_576,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
|
|||
yield* this.handleReasonerMessage(model, id, systemPrompt, messages)
|
||||
} else if (model.id.startsWith("o1")) {
|
||||
yield* this.handleO1FamilyMessage(model, systemPrompt, messages)
|
||||
} else if (this.isGPT5Model(model.id)) {
|
||||
yield* this.handleGPT5Message(model, systemPrompt, messages)
|
||||
} else {
|
||||
yield* this.handleDefaultModelMessage(model, systemPrompt, messages)
|
||||
}
|
||||
|
|
@ -123,6 +125,26 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
|
|||
yield* this.handleStreamResponse(stream, model)
|
||||
}
|
||||
|
||||
private async *handleGPT5Message(
|
||||
model: OpenAiNativeModel,
|
||||
systemPrompt: string,
|
||||
messages: Anthropic.Messages.MessageParam[],
|
||||
): ApiStream {
|
||||
const stream = await this.client.chat.completions.create({
|
||||
model: model.id,
|
||||
temperature: 1,
|
||||
messages: [{ role: "developer", content: systemPrompt }, ...convertToOpenAiMessages(messages)],
|
||||
stream: true,
|
||||
stream_options: { include_usage: true },
|
||||
})
|
||||
|
||||
yield* this.handleStreamResponse(stream, model)
|
||||
}
|
||||
|
||||
private isGPT5Model(modelId: string): boolean {
|
||||
return modelId.includes("gpt-5") || modelId.includes("gpt5") || modelId.includes("nectarine")
|
||||
}
|
||||
|
||||
private async *handleStreamResponse(
|
||||
stream: AsyncIterable<OpenAI.Chat.Completions.ChatCompletionChunk>,
|
||||
model: OpenAiNativeModel,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue