File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @browserbasehq/stagehand " : patch
3
+ ---
4
+
5
+ Patch GPT-5 new api format
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ export async function extract({
69
69
type MetadataResponse = z . infer < typeof metadataSchema > ;
70
70
71
71
const isUsingAnthropic = llmClient . type === "anthropic" ;
72
+ const isGPT5 = llmClient . modelName . includes ( "gpt-5" ) ; // TODO: remove this as we update support for gpt-5 configuration options
72
73
73
74
const extractCallMessages : ChatMessage [ ] = [
74
75
buildExtractSystemPrompt ( isUsingAnthropic , userProvidedInstructions ) ,
@@ -100,7 +101,7 @@ export async function extract({
100
101
schema,
101
102
name : "Extraction" ,
102
103
} ,
103
- temperature : 0.1 ,
104
+ temperature : isGPT5 ? 1 : 0.1 ,
104
105
top_p : 1 ,
105
106
frequency_penalty : 0 ,
106
107
presence_penalty : 0 ,
@@ -167,7 +168,7 @@ export async function extract({
167
168
name : "Metadata" ,
168
169
schema : metadataSchema ,
169
170
} ,
170
- temperature : 0.1 ,
171
+ temperature : isGPT5 ? 1 : 0.1 ,
171
172
top_p : 1 ,
172
173
frequency_penalty : 0 ,
173
174
presence_penalty : 0 ,
@@ -254,6 +255,8 @@ export async function observe({
254
255
logInferenceToFile ?: boolean ;
255
256
fromAct ?: boolean ;
256
257
} ) {
258
+ const isGPT5 = llmClient . modelName . includes ( "gpt-5" ) ; // TODO: remove this as we update support for gpt-5 configuration options
259
+
257
260
const observeSchema = z . object ( {
258
261
elements : z
259
262
. array (
@@ -321,7 +324,7 @@ export async function observe({
321
324
schema : observeSchema ,
322
325
name : "Observation" ,
323
326
} ,
324
- temperature : 0.1 ,
327
+ temperature : isGPT5 ? 1 : 0.1 ,
325
328
top_p : 1 ,
326
329
frequency_penalty : 0 ,
327
330
presence_penalty : 0 ,
Original file line number Diff line number Diff line change @@ -158,12 +158,22 @@ export class AISdkClient extends LLMClient {
158
158
} ) ;
159
159
160
160
let objectResponse : Awaited < ReturnType < typeof generateObject > > ;
161
+ const isGPT5 = this . model . modelId . includes ( "gpt-5" ) ;
161
162
if ( options . response_model ) {
162
163
try {
163
164
objectResponse = await generateObject ( {
164
165
model : this . model ,
165
166
messages : formattedMessages ,
166
167
schema : options . response_model . schema ,
168
+ temperature : options . temperature ,
169
+ providerOptions : isGPT5
170
+ ? {
171
+ openai : {
172
+ textVerbosity : "low" , // Making these the default for gpt-5 for now
173
+ reasoningEffort : "minimal" ,
174
+ } ,
175
+ }
176
+ : undefined ,
167
177
} ) ;
168
178
} catch ( err ) {
169
179
if ( NoObjectGeneratedError . isInstance ( err ) ) {
@@ -267,6 +277,7 @@ export class AISdkClient extends LLMClient {
267
277
const textResponse = await generateText ( {
268
278
model : this . model ,
269
279
messages : formattedMessages ,
280
+ temperature : options . temperature ,
270
281
tools,
271
282
} ) ;
272
283
You can’t perform that action at this time.
0 commit comments