Skip to content

Commit cea42f5

Browse files
authored
improvement(gpt-5): added reasoning level and verbosity to gpt-5 models (#1058)
1 parent 6fd6f92 commit cea42f5

7 files changed

Lines changed: 187 additions & 0 deletions

File tree

apps/sim/blocks/blocks/agent.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import {
99
getProviderIcon,
1010
MODELS_TEMP_RANGE_0_1,
1111
MODELS_TEMP_RANGE_0_2,
12+
MODELS_WITH_REASONING_EFFORT,
1213
MODELS_WITH_TEMPERATURE_SUPPORT,
14+
MODELS_WITH_VERBOSITY,
1315
providers,
1416
} from '@/providers/utils'
1517

@@ -210,6 +212,36 @@ Create a system prompt appropriately detailed for the request, using clear langu
210212
},
211213
},
212214
},
215+
{
216+
id: 'reasoningEffort',
217+
title: 'Reasoning Effort',
218+
type: 'combobox',
219+
layout: 'half',
220+
placeholder: 'Select reasoning effort...',
221+
options: () => {
222+
return [
223+
{ label: 'low', id: 'low' },
224+
{ label: 'medium', id: 'medium' },
225+
{ label: 'high', id: 'high' },
226+
]
227+
},
228+
condition: {
229+
field: 'model',
230+
value: MODELS_WITH_REASONING_EFFORT,
231+
},
232+
},
233+
{
234+
id: 'verbosity',
235+
title: 'Verbosity',
236+
type: 'slider',
237+
layout: 'half',
238+
min: 0,
239+
max: 2,
240+
condition: {
241+
field: 'model',
242+
value: MODELS_WITH_VERBOSITY,
243+
},
244+
},
213245
{
214246
id: 'apiKey',
215247
title: 'API Key',
@@ -485,6 +517,8 @@ Example 3 (Array Input):
485517
},
486518
},
487519
temperature: { type: 'number', description: 'Response randomness level' },
520+
reasoningEffort: { type: 'string', description: 'Reasoning effort level for GPT-5 models' },
521+
verbosity: { type: 'number', description: 'Verbosity level for GPT-5 models' },
488522
tools: { type: 'json', description: 'Available tools configuration' },
489523
},
490524
outputs: {

apps/sim/providers/azure-openai/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ export const azureOpenAIProvider: ProviderConfig = {
144144
if (request.temperature !== undefined) payload.temperature = request.temperature
145145
if (request.maxTokens !== undefined) payload.max_tokens = request.maxTokens
146146

147+
// Add GPT-5 specific parameters
148+
if (request.reasoningEffort !== undefined) payload.reasoning_effort = request.reasoningEffort
149+
if (request.verbosity !== undefined) payload.verbosity = request.verbosity
150+
147151
// Add response format for structured output if specified
148152
if (request.responseFormat) {
149153
// Use Azure OpenAI's JSON schema format

apps/sim/providers/models.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ export interface ModelCapabilities {
3434
}
3535
toolUsageControl?: boolean
3636
computerUse?: boolean
37+
reasoningEffort?: {
38+
min: string
39+
max: string
40+
values: string[]
41+
}
42+
verbosity?: {
43+
min: number
44+
max: number
45+
}
3746
}
3847

3948
export interface ModelDefinition {
@@ -87,6 +96,12 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
8796
},
8897
capabilities: {
8998
toolUsageControl: true,
99+
reasoningEffort: {
100+
min: 'low',
101+
max: 'high',
102+
values: ['low', 'medium', 'high'],
103+
},
104+
verbosity: { min: 0, max: 2 },
90105
},
91106
},
92107
{
@@ -99,6 +114,12 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
99114
},
100115
capabilities: {
101116
toolUsageControl: true,
117+
reasoningEffort: {
118+
min: 'low',
119+
max: 'high',
120+
values: ['low', 'medium', 'high'],
121+
},
122+
verbosity: { min: 0, max: 2 },
102123
},
103124
},
104125
{
@@ -111,6 +132,12 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
111132
},
112133
capabilities: {
113134
toolUsageControl: true,
135+
reasoningEffort: {
136+
min: 'low',
137+
max: 'high',
138+
values: ['low', 'medium', 'high'],
139+
},
140+
verbosity: { min: 0, max: 2 },
114141
},
115142
},
116143
{
@@ -233,6 +260,12 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
233260
},
234261
capabilities: {
235262
toolUsageControl: true,
263+
reasoningEffort: {
264+
min: 'low',
265+
max: 'high',
266+
values: ['low', 'medium', 'high'],
267+
},
268+
verbosity: { min: 0, max: 2 },
236269
},
237270
},
238271
{
@@ -245,6 +278,12 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
245278
},
246279
capabilities: {
247280
toolUsageControl: true,
281+
reasoningEffort: {
282+
min: 'low',
283+
max: 'high',
284+
values: ['low', 'medium', 'high'],
285+
},
286+
verbosity: { min: 0, max: 2 },
248287
},
249288
},
250289
{
@@ -257,6 +296,12 @@ export const PROVIDER_DEFINITIONS: Record<string, ProviderDefinition> = {
257296
},
258297
capabilities: {
259298
toolUsageControl: true,
299+
reasoningEffort: {
300+
min: 'low',
301+
max: 'high',
302+
values: ['low', 'medium', 'high'],
303+
},
304+
verbosity: { min: 0, max: 2 },
260305
},
261306
},
262307
{
@@ -844,3 +889,33 @@ export const EMBEDDING_MODEL_PRICING: Record<string, ModelPricing> = {
844889
export function getEmbeddingModelPricing(modelId: string): ModelPricing | null {
845890
return EMBEDDING_MODEL_PRICING[modelId] || null
846891
}
892+
893+
/**
894+
* Get all models that support reasoning effort
895+
*/
896+
export function getModelsWithReasoningEffort(): string[] {
897+
const models: string[] = []
898+
for (const provider of Object.values(PROVIDER_DEFINITIONS)) {
899+
for (const model of provider.models) {
900+
if (model.capabilities.reasoningEffort) {
901+
models.push(model.id)
902+
}
903+
}
904+
}
905+
return models
906+
}
907+
908+
/**
909+
* Get all models that support verbosity
910+
*/
911+
export function getModelsWithVerbosity(): string[] {
912+
const models: string[] = []
913+
for (const provider of Object.values(PROVIDER_DEFINITIONS)) {
914+
for (const model of provider.models) {
915+
if (model.capabilities.verbosity) {
916+
models.push(model.id)
917+
}
918+
}
919+
}
920+
return models
921+
}

apps/sim/providers/openai/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ export const openaiProvider: ProviderConfig = {
130130
if (request.temperature !== undefined) payload.temperature = request.temperature
131131
if (request.maxTokens !== undefined) payload.max_tokens = request.maxTokens
132132

133+
// Add GPT-5 specific parameters
134+
if (request.reasoningEffort !== undefined) payload.reasoning_effort = request.reasoningEffort
135+
if (request.verbosity !== undefined) payload.verbosity = request.verbosity
136+
133137
// Add response format for structured output if specified
134138
if (request.responseFormat) {
135139
// Use OpenAI's JSON schema format

apps/sim/providers/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ export interface ProviderRequest {
156156
// Azure OpenAI specific parameters
157157
azureEndpoint?: string
158158
azureApiVersion?: string
159+
// GPT-5 specific parameters
160+
reasoningEffort?: string
161+
verbosity?: number
159162
}
160163

161164
// Map of provider IDs to their configurations

apps/sim/providers/utils.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import {
1919
getProviderModels,
2020
MODELS_TEMP_RANGE_0_1,
2121
MODELS_TEMP_RANGE_0_2,
22+
MODELS_WITH_REASONING_EFFORT,
2223
MODELS_WITH_TEMPERATURE_SUPPORT,
24+
MODELS_WITH_VERBOSITY,
2325
PROVIDERS_WITH_TOOL_USAGE_CONTROL,
2426
prepareToolsWithUsageControl,
2527
supportsTemperature,
@@ -144,6 +146,15 @@ describe('Model Capabilities', () => {
144146
'deepseek-chat',
145147
'azure/gpt-4.1',
146148
'azure/model-router',
149+
// GPT-5 models don't support temperature (removed in our implementation)
150+
'gpt-5',
151+
'gpt-5-mini',
152+
'gpt-5-nano',
153+
'gpt-5-chat-latest',
154+
'azure/gpt-5',
155+
'azure/gpt-5-mini',
156+
'azure/gpt-5-nano',
157+
'azure/gpt-5-chat-latest',
147158
]
148159

149160
for (const model of unsupportedModels) {
@@ -198,6 +209,15 @@ describe('Model Capabilities', () => {
198209
expect(getMaxTemperature('azure/o3')).toBeUndefined()
199210
expect(getMaxTemperature('azure/o4-mini')).toBeUndefined()
200211
expect(getMaxTemperature('deepseek-r1')).toBeUndefined()
212+
// GPT-5 models don't support temperature (removed in our implementation)
213+
expect(getMaxTemperature('gpt-5')).toBeUndefined()
214+
expect(getMaxTemperature('gpt-5-mini')).toBeUndefined()
215+
expect(getMaxTemperature('gpt-5-nano')).toBeUndefined()
216+
expect(getMaxTemperature('gpt-5-chat-latest')).toBeUndefined()
217+
expect(getMaxTemperature('azure/gpt-5')).toBeUndefined()
218+
expect(getMaxTemperature('azure/gpt-5-mini')).toBeUndefined()
219+
expect(getMaxTemperature('azure/gpt-5-nano')).toBeUndefined()
220+
expect(getMaxTemperature('azure/gpt-5-chat-latest')).toBeUndefined()
201221
})
202222

203223
it.concurrent('should be case insensitive', () => {
@@ -266,6 +286,49 @@ describe('Model Capabilities', () => {
266286
expect(MODELS_WITH_TEMPERATURE_SUPPORT).toContain('claude-sonnet-4-0') // From 0-1 range
267287
}
268288
)
289+
290+
it.concurrent('should have correct models in MODELS_WITH_REASONING_EFFORT', () => {
291+
// Should contain GPT-5 models that support reasoning effort
292+
expect(MODELS_WITH_REASONING_EFFORT).toContain('gpt-5')
293+
expect(MODELS_WITH_REASONING_EFFORT).toContain('gpt-5-mini')
294+
expect(MODELS_WITH_REASONING_EFFORT).toContain('gpt-5-nano')
295+
expect(MODELS_WITH_REASONING_EFFORT).toContain('azure/gpt-5')
296+
expect(MODELS_WITH_REASONING_EFFORT).toContain('azure/gpt-5-mini')
297+
expect(MODELS_WITH_REASONING_EFFORT).toContain('azure/gpt-5-nano')
298+
299+
// Should NOT contain non-reasoning GPT-5 models
300+
expect(MODELS_WITH_REASONING_EFFORT).not.toContain('gpt-5-chat-latest')
301+
expect(MODELS_WITH_REASONING_EFFORT).not.toContain('azure/gpt-5-chat-latest')
302+
303+
// Should NOT contain other models
304+
expect(MODELS_WITH_REASONING_EFFORT).not.toContain('gpt-4o')
305+
expect(MODELS_WITH_REASONING_EFFORT).not.toContain('claude-sonnet-4-0')
306+
expect(MODELS_WITH_REASONING_EFFORT).not.toContain('o1')
307+
})
308+
309+
it.concurrent('should have correct models in MODELS_WITH_VERBOSITY', () => {
310+
// Should contain GPT-5 models that support verbosity
311+
expect(MODELS_WITH_VERBOSITY).toContain('gpt-5')
312+
expect(MODELS_WITH_VERBOSITY).toContain('gpt-5-mini')
313+
expect(MODELS_WITH_VERBOSITY).toContain('gpt-5-nano')
314+
expect(MODELS_WITH_VERBOSITY).toContain('azure/gpt-5')
315+
expect(MODELS_WITH_VERBOSITY).toContain('azure/gpt-5-mini')
316+
expect(MODELS_WITH_VERBOSITY).toContain('azure/gpt-5-nano')
317+
318+
// Should NOT contain non-reasoning GPT-5 models
319+
expect(MODELS_WITH_VERBOSITY).not.toContain('gpt-5-chat-latest')
320+
expect(MODELS_WITH_VERBOSITY).not.toContain('azure/gpt-5-chat-latest')
321+
322+
// Should NOT contain other models
323+
expect(MODELS_WITH_VERBOSITY).not.toContain('gpt-4o')
324+
expect(MODELS_WITH_VERBOSITY).not.toContain('claude-sonnet-4-0')
325+
expect(MODELS_WITH_VERBOSITY).not.toContain('o1')
326+
})
327+
328+
it.concurrent('should have same models in both reasoning effort and verbosity arrays', () => {
329+
// GPT-5 models that support reasoning effort should also support verbosity and vice versa
330+
expect(MODELS_WITH_REASONING_EFFORT.sort()).toEqual(MODELS_WITH_VERBOSITY.sort())
331+
})
269332
})
270333
})
271334

apps/sim/providers/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import {
1212
getHostedModels as getHostedModelsFromDefinitions,
1313
getMaxTemperature as getMaxTempFromDefinitions,
1414
getModelPricing as getModelPricingFromDefinitions,
15+
getModelsWithReasoningEffort,
1516
getModelsWithTemperatureSupport,
1617
getModelsWithTempRange01,
1718
getModelsWithTempRange02,
19+
getModelsWithVerbosity,
1820
getProviderModels as getProviderModelsFromDefinitions,
1921
getProvidersWithToolUsageControl,
2022
PROVIDER_DEFINITIONS,
@@ -878,6 +880,8 @@ export function trackForcedToolUsage(
878880
export const MODELS_TEMP_RANGE_0_2 = getModelsWithTempRange02()
879881
export const MODELS_TEMP_RANGE_0_1 = getModelsWithTempRange01()
880882
export const MODELS_WITH_TEMPERATURE_SUPPORT = getModelsWithTemperatureSupport()
883+
export const MODELS_WITH_REASONING_EFFORT = getModelsWithReasoningEffort()
884+
export const MODELS_WITH_VERBOSITY = getModelsWithVerbosity()
881885
export const PROVIDERS_WITH_TOOL_USAGE_CONTROL = getProvidersWithToolUsageControl()
882886

883887
/**

0 commit comments

Comments
 (0)