@mastra/server 0.14.0 → 0.14.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-PREC2QAP.js → chunk-22OZ4DMU.js} +991 -372
- package/dist/chunk-22OZ4DMU.js.map +1 -0
- package/dist/{chunk-ZROTEYUT.cjs → chunk-WPGDPPF2.cjs} +1842 -1223
- package/dist/chunk-WPGDPPF2.cjs.map +1 -0
- package/dist/server/handlers/agents.cjs +12 -12
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-PREC2QAP.js.map +0 -1
- package/dist/chunk-ZROTEYUT.cjs.map +0 -1
|
@@ -6,12 +6,12 @@ var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
|
6
6
|
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
7
7
|
var chunkEMMSS5I5_cjs = require('./chunk-EMMSS5I5.cjs');
|
|
8
8
|
var zod = require('zod');
|
|
9
|
-
var
|
|
9
|
+
var z62 = require('zod/v4');
|
|
10
10
|
var runtimeContext = require('@mastra/core/runtime-context');
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var z62__default = /*#__PURE__*/_interopDefault(z62);
|
|
15
15
|
|
|
16
16
|
// ../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js
|
|
17
17
|
var require_secure_json_parse = chunkEMMSS5I5_cjs.__commonJS({
|
|
@@ -3144,51 +3144,51 @@ function convertToBase64(value) {
|
|
|
3144
3144
|
function withoutTrailingSlash2(url) {
|
|
3145
3145
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
3146
3146
|
}
|
|
3147
|
-
var anthropicErrorDataSchema2 =
|
|
3148
|
-
type:
|
|
3149
|
-
error:
|
|
3150
|
-
type:
|
|
3151
|
-
message:
|
|
3147
|
+
var anthropicErrorDataSchema2 = z62.z.object({
|
|
3148
|
+
type: z62.z.literal("error"),
|
|
3149
|
+
error: z62.z.object({
|
|
3150
|
+
type: z62.z.string(),
|
|
3151
|
+
message: z62.z.string()
|
|
3152
3152
|
})
|
|
3153
3153
|
});
|
|
3154
3154
|
var anthropicFailedResponseHandler2 = createJsonErrorResponseHandler2({
|
|
3155
3155
|
errorSchema: anthropicErrorDataSchema2,
|
|
3156
3156
|
errorToMessage: (data) => data.error.message
|
|
3157
3157
|
});
|
|
3158
|
-
var anthropicFilePartProviderOptions =
|
|
3158
|
+
var anthropicFilePartProviderOptions = z62.z.object({
|
|
3159
3159
|
/**
|
|
3160
3160
|
* Citation configuration for this document.
|
|
3161
3161
|
* When enabled, this document will generate citations in the response.
|
|
3162
3162
|
*/
|
|
3163
|
-
citations:
|
|
3163
|
+
citations: z62.z.object({
|
|
3164
3164
|
/**
|
|
3165
3165
|
* Enable citations for this document
|
|
3166
3166
|
*/
|
|
3167
|
-
enabled:
|
|
3167
|
+
enabled: z62.z.boolean()
|
|
3168
3168
|
}).optional(),
|
|
3169
3169
|
/**
|
|
3170
3170
|
* Custom title for the document.
|
|
3171
3171
|
* If not provided, the filename will be used.
|
|
3172
3172
|
*/
|
|
3173
|
-
title:
|
|
3173
|
+
title: z62.z.string().optional(),
|
|
3174
3174
|
/**
|
|
3175
3175
|
* Context about the document that will be passed to the model
|
|
3176
3176
|
* but not used towards cited content.
|
|
3177
3177
|
* Useful for storing document metadata as text or stringified JSON.
|
|
3178
3178
|
*/
|
|
3179
|
-
context:
|
|
3179
|
+
context: z62.z.string().optional()
|
|
3180
3180
|
});
|
|
3181
|
-
var anthropicProviderOptions =
|
|
3182
|
-
sendReasoning:
|
|
3183
|
-
thinking:
|
|
3184
|
-
type:
|
|
3185
|
-
budgetTokens:
|
|
3181
|
+
var anthropicProviderOptions = z62.z.object({
|
|
3182
|
+
sendReasoning: z62.z.boolean().optional(),
|
|
3183
|
+
thinking: z62.z.object({
|
|
3184
|
+
type: z62.z.union([z62.z.literal("enabled"), z62.z.literal("disabled")]),
|
|
3185
|
+
budgetTokens: z62.z.number().optional()
|
|
3186
3186
|
}).optional(),
|
|
3187
3187
|
/**
|
|
3188
3188
|
* Whether to disable parallel function calling during tool use. Default is false.
|
|
3189
3189
|
* When set to true, Claude will use at most one tool per response.
|
|
3190
3190
|
*/
|
|
3191
|
-
disableParallelToolUse:
|
|
3191
|
+
disableParallelToolUse: z62.z.boolean().optional()
|
|
3192
3192
|
});
|
|
3193
3193
|
function getCacheControl(providerMetadata) {
|
|
3194
3194
|
var _a16;
|
|
@@ -3196,44 +3196,44 @@ function getCacheControl(providerMetadata) {
|
|
|
3196
3196
|
const cacheControlValue = (_a16 = anthropic22 == null ? void 0 : anthropic22.cacheControl) != null ? _a16 : anthropic22 == null ? void 0 : anthropic22.cache_control;
|
|
3197
3197
|
return cacheControlValue;
|
|
3198
3198
|
}
|
|
3199
|
-
var webSearch_20250305ArgsSchema =
|
|
3199
|
+
var webSearch_20250305ArgsSchema = z62.z.object({
|
|
3200
3200
|
/**
|
|
3201
3201
|
* Maximum number of web searches Claude can perform during the conversation.
|
|
3202
3202
|
*/
|
|
3203
|
-
maxUses:
|
|
3203
|
+
maxUses: z62.z.number().optional(),
|
|
3204
3204
|
/**
|
|
3205
3205
|
* Optional list of domains that Claude is allowed to search.
|
|
3206
3206
|
*/
|
|
3207
|
-
allowedDomains:
|
|
3207
|
+
allowedDomains: z62.z.array(z62.z.string()).optional(),
|
|
3208
3208
|
/**
|
|
3209
3209
|
* Optional list of domains that Claude should avoid when searching.
|
|
3210
3210
|
*/
|
|
3211
|
-
blockedDomains:
|
|
3211
|
+
blockedDomains: z62.z.array(z62.z.string()).optional(),
|
|
3212
3212
|
/**
|
|
3213
3213
|
* Optional user location information to provide geographically relevant search results.
|
|
3214
3214
|
*/
|
|
3215
|
-
userLocation:
|
|
3216
|
-
type:
|
|
3217
|
-
city:
|
|
3218
|
-
region:
|
|
3219
|
-
country:
|
|
3220
|
-
timezone:
|
|
3215
|
+
userLocation: z62.z.object({
|
|
3216
|
+
type: z62.z.literal("approximate"),
|
|
3217
|
+
city: z62.z.string().optional(),
|
|
3218
|
+
region: z62.z.string().optional(),
|
|
3219
|
+
country: z62.z.string().optional(),
|
|
3220
|
+
timezone: z62.z.string().optional()
|
|
3221
3221
|
}).optional()
|
|
3222
3222
|
});
|
|
3223
|
-
var webSearch_20250305OutputSchema =
|
|
3224
|
-
|
|
3225
|
-
url:
|
|
3226
|
-
title:
|
|
3227
|
-
pageAge:
|
|
3228
|
-
encryptedContent:
|
|
3229
|
-
type:
|
|
3223
|
+
var webSearch_20250305OutputSchema = z62.z.array(
|
|
3224
|
+
z62.z.object({
|
|
3225
|
+
url: z62.z.string(),
|
|
3226
|
+
title: z62.z.string(),
|
|
3227
|
+
pageAge: z62.z.string().nullable(),
|
|
3228
|
+
encryptedContent: z62.z.string(),
|
|
3229
|
+
type: z62.z.string()
|
|
3230
3230
|
})
|
|
3231
3231
|
);
|
|
3232
3232
|
var factory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
3233
3233
|
id: "anthropic.web_search_20250305",
|
|
3234
3234
|
name: "web_search",
|
|
3235
|
-
inputSchema:
|
|
3236
|
-
query:
|
|
3235
|
+
inputSchema: z62.z.object({
|
|
3236
|
+
query: z62.z.string()
|
|
3237
3237
|
}),
|
|
3238
3238
|
outputSchema: webSearch_20250305OutputSchema
|
|
3239
3239
|
});
|
|
@@ -3339,6 +3339,14 @@ function prepareTools2({
|
|
|
3339
3339
|
});
|
|
3340
3340
|
break;
|
|
3341
3341
|
}
|
|
3342
|
+
case "anthropic.code_execution_20250522": {
|
|
3343
|
+
betas.add("code-execution-2025-05-22");
|
|
3344
|
+
anthropicTools22.push({
|
|
3345
|
+
type: "code_execution_20250522",
|
|
3346
|
+
name: "code_execution"
|
|
3347
|
+
});
|
|
3348
|
+
break;
|
|
3349
|
+
}
|
|
3342
3350
|
default:
|
|
3343
3351
|
toolWarnings.push({ type: "unsupported-tool", tool: tool2 });
|
|
3344
3352
|
break;
|
|
@@ -3400,6 +3408,23 @@ function prepareTools2({
|
|
|
3400
3408
|
}
|
|
3401
3409
|
}
|
|
3402
3410
|
}
|
|
3411
|
+
var codeExecution_20250522OutputSchema = z62.z.object({
|
|
3412
|
+
type: z62.z.literal("code_execution_result"),
|
|
3413
|
+
stdout: z62.z.string(),
|
|
3414
|
+
stderr: z62.z.string(),
|
|
3415
|
+
return_code: z62.z.number()
|
|
3416
|
+
});
|
|
3417
|
+
var factory2 = createProviderDefinedToolFactoryWithOutputSchema({
|
|
3418
|
+
id: "anthropic.code_execution_20250522",
|
|
3419
|
+
name: "code_execution",
|
|
3420
|
+
inputSchema: z62.z.object({
|
|
3421
|
+
code: z62.z.string()
|
|
3422
|
+
}),
|
|
3423
|
+
outputSchema: codeExecution_20250522OutputSchema
|
|
3424
|
+
});
|
|
3425
|
+
var codeExecution_20250522 = (args = {}) => {
|
|
3426
|
+
return factory2(args);
|
|
3427
|
+
};
|
|
3403
3428
|
function convertToString(data) {
|
|
3404
3429
|
if (typeof data === "string") {
|
|
3405
3430
|
return Buffer.from(data, "base64").toString("utf-8");
|
|
@@ -3699,6 +3724,16 @@ async function convertToAnthropicMessagesPrompt2({
|
|
|
3699
3724
|
});
|
|
3700
3725
|
break;
|
|
3701
3726
|
}
|
|
3727
|
+
if (part.toolName === "code_execution") {
|
|
3728
|
+
anthropicContent.push({
|
|
3729
|
+
type: "server_tool_use",
|
|
3730
|
+
id: part.toolCallId,
|
|
3731
|
+
name: "code_execution",
|
|
3732
|
+
input: part.input,
|
|
3733
|
+
cache_control: cacheControl
|
|
3734
|
+
});
|
|
3735
|
+
break;
|
|
3736
|
+
}
|
|
3702
3737
|
warnings.push({
|
|
3703
3738
|
type: "other",
|
|
3704
3739
|
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
@@ -3741,6 +3776,29 @@ async function convertToAnthropicMessagesPrompt2({
|
|
|
3741
3776
|
});
|
|
3742
3777
|
break;
|
|
3743
3778
|
}
|
|
3779
|
+
if (part.toolName === "code_execution") {
|
|
3780
|
+
const output = part.output;
|
|
3781
|
+
if (output.type !== "json") {
|
|
3782
|
+
warnings.push({
|
|
3783
|
+
type: "other",
|
|
3784
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
3785
|
+
});
|
|
3786
|
+
break;
|
|
3787
|
+
}
|
|
3788
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
3789
|
+
anthropicContent.push({
|
|
3790
|
+
type: "code_execution_tool_result",
|
|
3791
|
+
tool_use_id: part.toolCallId,
|
|
3792
|
+
content: {
|
|
3793
|
+
type: codeExecutionOutput.type,
|
|
3794
|
+
stdout: codeExecutionOutput.stdout,
|
|
3795
|
+
stderr: codeExecutionOutput.stderr,
|
|
3796
|
+
return_code: codeExecutionOutput.return_code
|
|
3797
|
+
},
|
|
3798
|
+
cache_control: cacheControl
|
|
3799
|
+
});
|
|
3800
|
+
break;
|
|
3801
|
+
}
|
|
3744
3802
|
warnings.push({
|
|
3745
3803
|
type: "other",
|
|
3746
3804
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -3827,36 +3885,36 @@ function mapAnthropicStopReason2({
|
|
|
3827
3885
|
}
|
|
3828
3886
|
}
|
|
3829
3887
|
var citationSchemas = {
|
|
3830
|
-
webSearchResult:
|
|
3831
|
-
type:
|
|
3832
|
-
cited_text:
|
|
3833
|
-
url:
|
|
3834
|
-
title:
|
|
3835
|
-
encrypted_index:
|
|
3888
|
+
webSearchResult: z62.z.object({
|
|
3889
|
+
type: z62.z.literal("web_search_result_location"),
|
|
3890
|
+
cited_text: z62.z.string(),
|
|
3891
|
+
url: z62.z.string(),
|
|
3892
|
+
title: z62.z.string(),
|
|
3893
|
+
encrypted_index: z62.z.string()
|
|
3836
3894
|
}),
|
|
3837
|
-
pageLocation:
|
|
3838
|
-
type:
|
|
3839
|
-
cited_text:
|
|
3840
|
-
document_index:
|
|
3841
|
-
document_title:
|
|
3842
|
-
start_page_number:
|
|
3843
|
-
end_page_number:
|
|
3895
|
+
pageLocation: z62.z.object({
|
|
3896
|
+
type: z62.z.literal("page_location"),
|
|
3897
|
+
cited_text: z62.z.string(),
|
|
3898
|
+
document_index: z62.z.number(),
|
|
3899
|
+
document_title: z62.z.string().nullable(),
|
|
3900
|
+
start_page_number: z62.z.number(),
|
|
3901
|
+
end_page_number: z62.z.number()
|
|
3844
3902
|
}),
|
|
3845
|
-
charLocation:
|
|
3846
|
-
type:
|
|
3847
|
-
cited_text:
|
|
3848
|
-
document_index:
|
|
3849
|
-
document_title:
|
|
3850
|
-
start_char_index:
|
|
3851
|
-
end_char_index:
|
|
3903
|
+
charLocation: z62.z.object({
|
|
3904
|
+
type: z62.z.literal("char_location"),
|
|
3905
|
+
cited_text: z62.z.string(),
|
|
3906
|
+
document_index: z62.z.number(),
|
|
3907
|
+
document_title: z62.z.string().nullable(),
|
|
3908
|
+
start_char_index: z62.z.number(),
|
|
3909
|
+
end_char_index: z62.z.number()
|
|
3852
3910
|
})
|
|
3853
3911
|
};
|
|
3854
|
-
var citationSchema =
|
|
3912
|
+
var citationSchema = z62.z.discriminatedUnion("type", [
|
|
3855
3913
|
citationSchemas.webSearchResult,
|
|
3856
3914
|
citationSchemas.pageLocation,
|
|
3857
3915
|
citationSchemas.charLocation
|
|
3858
3916
|
]);
|
|
3859
|
-
|
|
3917
|
+
z62.z.discriminatedUnion("type", [
|
|
3860
3918
|
citationSchemas.pageLocation,
|
|
3861
3919
|
citationSchemas.charLocation
|
|
3862
3920
|
]);
|
|
@@ -4181,7 +4239,7 @@ var AnthropicMessagesLanguageModel2 = class {
|
|
|
4181
4239
|
break;
|
|
4182
4240
|
}
|
|
4183
4241
|
case "server_tool_use": {
|
|
4184
|
-
if (part.name === "web_search") {
|
|
4242
|
+
if (part.name === "web_search" || part.name === "code_execution") {
|
|
4185
4243
|
content.push({
|
|
4186
4244
|
type: "tool-call",
|
|
4187
4245
|
toolCallId: part.id,
|
|
@@ -4239,6 +4297,35 @@ var AnthropicMessagesLanguageModel2 = class {
|
|
|
4239
4297
|
}
|
|
4240
4298
|
break;
|
|
4241
4299
|
}
|
|
4300
|
+
case "code_execution_tool_result": {
|
|
4301
|
+
if (part.content.type === "code_execution_result") {
|
|
4302
|
+
content.push({
|
|
4303
|
+
type: "tool-result",
|
|
4304
|
+
toolCallId: part.tool_use_id,
|
|
4305
|
+
toolName: "code_execution",
|
|
4306
|
+
result: {
|
|
4307
|
+
type: part.content.type,
|
|
4308
|
+
stdout: part.content.stdout,
|
|
4309
|
+
stderr: part.content.stderr,
|
|
4310
|
+
return_code: part.content.return_code
|
|
4311
|
+
},
|
|
4312
|
+
providerExecuted: true
|
|
4313
|
+
});
|
|
4314
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
4315
|
+
content.push({
|
|
4316
|
+
type: "tool-result",
|
|
4317
|
+
toolCallId: part.tool_use_id,
|
|
4318
|
+
toolName: "code_execution",
|
|
4319
|
+
isError: true,
|
|
4320
|
+
result: {
|
|
4321
|
+
type: "code_execution_tool_result_error",
|
|
4322
|
+
errorCode: part.content.error_code
|
|
4323
|
+
},
|
|
4324
|
+
providerExecuted: true
|
|
4325
|
+
});
|
|
4326
|
+
}
|
|
4327
|
+
break;
|
|
4328
|
+
}
|
|
4242
4329
|
}
|
|
4243
4330
|
}
|
|
4244
4331
|
return {
|
|
@@ -4364,7 +4451,7 @@ var AnthropicMessagesLanguageModel2 = class {
|
|
|
4364
4451
|
return;
|
|
4365
4452
|
}
|
|
4366
4453
|
case "server_tool_use": {
|
|
4367
|
-
if (value.content_block.name === "web_search") {
|
|
4454
|
+
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
4368
4455
|
contentBlocks[value.index] = {
|
|
4369
4456
|
type: "tool-call",
|
|
4370
4457
|
toolCallId: value.content_block.id,
|
|
@@ -4429,6 +4516,36 @@ var AnthropicMessagesLanguageModel2 = class {
|
|
|
4429
4516
|
}
|
|
4430
4517
|
return;
|
|
4431
4518
|
}
|
|
4519
|
+
case "code_execution_tool_result": {
|
|
4520
|
+
const part = value.content_block;
|
|
4521
|
+
if (part.content.type === "code_execution_result") {
|
|
4522
|
+
controller.enqueue({
|
|
4523
|
+
type: "tool-result",
|
|
4524
|
+
toolCallId: part.tool_use_id,
|
|
4525
|
+
toolName: "code_execution",
|
|
4526
|
+
result: {
|
|
4527
|
+
type: part.content.type,
|
|
4528
|
+
stdout: part.content.stdout,
|
|
4529
|
+
stderr: part.content.stderr,
|
|
4530
|
+
return_code: part.content.return_code
|
|
4531
|
+
},
|
|
4532
|
+
providerExecuted: true
|
|
4533
|
+
});
|
|
4534
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
4535
|
+
controller.enqueue({
|
|
4536
|
+
type: "tool-result",
|
|
4537
|
+
toolCallId: part.tool_use_id,
|
|
4538
|
+
toolName: "code_execution",
|
|
4539
|
+
isError: true,
|
|
4540
|
+
result: {
|
|
4541
|
+
type: "code_execution_tool_result_error",
|
|
4542
|
+
errorCode: part.content.error_code
|
|
4543
|
+
},
|
|
4544
|
+
providerExecuted: true
|
|
4545
|
+
});
|
|
4546
|
+
}
|
|
4547
|
+
return;
|
|
4548
|
+
}
|
|
4432
4549
|
default: {
|
|
4433
4550
|
const _exhaustiveCheck = contentBlockType;
|
|
4434
4551
|
throw new Error(
|
|
@@ -4601,203 +4718,235 @@ var AnthropicMessagesLanguageModel2 = class {
|
|
|
4601
4718
|
};
|
|
4602
4719
|
}
|
|
4603
4720
|
};
|
|
4604
|
-
var anthropicMessagesResponseSchema2 =
|
|
4605
|
-
type:
|
|
4606
|
-
id:
|
|
4607
|
-
model:
|
|
4608
|
-
content:
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
type:
|
|
4612
|
-
text:
|
|
4613
|
-
citations:
|
|
4721
|
+
var anthropicMessagesResponseSchema2 = z62.z.object({
|
|
4722
|
+
type: z62.z.literal("message"),
|
|
4723
|
+
id: z62.z.string().nullish(),
|
|
4724
|
+
model: z62.z.string().nullish(),
|
|
4725
|
+
content: z62.z.array(
|
|
4726
|
+
z62.z.discriminatedUnion("type", [
|
|
4727
|
+
z62.z.object({
|
|
4728
|
+
type: z62.z.literal("text"),
|
|
4729
|
+
text: z62.z.string(),
|
|
4730
|
+
citations: z62.z.array(citationSchema).optional()
|
|
4614
4731
|
}),
|
|
4615
|
-
|
|
4616
|
-
type:
|
|
4617
|
-
thinking:
|
|
4618
|
-
signature:
|
|
4732
|
+
z62.z.object({
|
|
4733
|
+
type: z62.z.literal("thinking"),
|
|
4734
|
+
thinking: z62.z.string(),
|
|
4735
|
+
signature: z62.z.string()
|
|
4619
4736
|
}),
|
|
4620
|
-
|
|
4621
|
-
type:
|
|
4622
|
-
data:
|
|
4737
|
+
z62.z.object({
|
|
4738
|
+
type: z62.z.literal("redacted_thinking"),
|
|
4739
|
+
data: z62.z.string()
|
|
4623
4740
|
}),
|
|
4624
|
-
|
|
4625
|
-
type:
|
|
4626
|
-
id:
|
|
4627
|
-
name:
|
|
4628
|
-
input:
|
|
4741
|
+
z62.z.object({
|
|
4742
|
+
type: z62.z.literal("tool_use"),
|
|
4743
|
+
id: z62.z.string(),
|
|
4744
|
+
name: z62.z.string(),
|
|
4745
|
+
input: z62.z.unknown()
|
|
4629
4746
|
}),
|
|
4630
|
-
|
|
4631
|
-
type:
|
|
4632
|
-
id:
|
|
4633
|
-
name:
|
|
4634
|
-
input:
|
|
4747
|
+
z62.z.object({
|
|
4748
|
+
type: z62.z.literal("server_tool_use"),
|
|
4749
|
+
id: z62.z.string(),
|
|
4750
|
+
name: z62.z.string(),
|
|
4751
|
+
input: z62.z.record(z62.z.string(), z62.z.unknown()).nullish()
|
|
4635
4752
|
}),
|
|
4636
|
-
|
|
4637
|
-
type:
|
|
4638
|
-
tool_use_id:
|
|
4639
|
-
content:
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
type:
|
|
4643
|
-
url:
|
|
4644
|
-
title:
|
|
4645
|
-
encrypted_content:
|
|
4646
|
-
page_age:
|
|
4753
|
+
z62.z.object({
|
|
4754
|
+
type: z62.z.literal("web_search_tool_result"),
|
|
4755
|
+
tool_use_id: z62.z.string(),
|
|
4756
|
+
content: z62.z.union([
|
|
4757
|
+
z62.z.array(
|
|
4758
|
+
z62.z.object({
|
|
4759
|
+
type: z62.z.literal("web_search_result"),
|
|
4760
|
+
url: z62.z.string(),
|
|
4761
|
+
title: z62.z.string(),
|
|
4762
|
+
encrypted_content: z62.z.string(),
|
|
4763
|
+
page_age: z62.z.string().nullish()
|
|
4647
4764
|
})
|
|
4648
4765
|
),
|
|
4649
|
-
|
|
4650
|
-
type:
|
|
4651
|
-
error_code:
|
|
4766
|
+
z62.z.object({
|
|
4767
|
+
type: z62.z.literal("web_search_tool_result_error"),
|
|
4768
|
+
error_code: z62.z.string()
|
|
4769
|
+
})
|
|
4770
|
+
])
|
|
4771
|
+
}),
|
|
4772
|
+
z62.z.object({
|
|
4773
|
+
type: z62.z.literal("code_execution_tool_result"),
|
|
4774
|
+
tool_use_id: z62.z.string(),
|
|
4775
|
+
content: z62.z.union([
|
|
4776
|
+
z62.z.object({
|
|
4777
|
+
type: z62.z.literal("code_execution_result"),
|
|
4778
|
+
stdout: z62.z.string(),
|
|
4779
|
+
stderr: z62.z.string(),
|
|
4780
|
+
return_code: z62.z.number()
|
|
4781
|
+
}),
|
|
4782
|
+
z62.z.object({
|
|
4783
|
+
type: z62.z.literal("code_execution_tool_result_error"),
|
|
4784
|
+
error_code: z62.z.string()
|
|
4652
4785
|
})
|
|
4653
4786
|
])
|
|
4654
4787
|
})
|
|
4655
4788
|
])
|
|
4656
4789
|
),
|
|
4657
|
-
stop_reason:
|
|
4658
|
-
usage:
|
|
4659
|
-
input_tokens:
|
|
4660
|
-
output_tokens:
|
|
4661
|
-
cache_creation_input_tokens:
|
|
4662
|
-
cache_read_input_tokens:
|
|
4790
|
+
stop_reason: z62.z.string().nullish(),
|
|
4791
|
+
usage: z62.z.looseObject({
|
|
4792
|
+
input_tokens: z62.z.number(),
|
|
4793
|
+
output_tokens: z62.z.number(),
|
|
4794
|
+
cache_creation_input_tokens: z62.z.number().nullish(),
|
|
4795
|
+
cache_read_input_tokens: z62.z.number().nullish()
|
|
4663
4796
|
})
|
|
4664
4797
|
});
|
|
4665
|
-
var anthropicMessagesChunkSchema2 =
|
|
4666
|
-
|
|
4667
|
-
type:
|
|
4668
|
-
message:
|
|
4669
|
-
id:
|
|
4670
|
-
model:
|
|
4671
|
-
usage:
|
|
4672
|
-
input_tokens:
|
|
4673
|
-
output_tokens:
|
|
4674
|
-
cache_creation_input_tokens:
|
|
4675
|
-
cache_read_input_tokens:
|
|
4798
|
+
var anthropicMessagesChunkSchema2 = z62.z.discriminatedUnion("type", [
|
|
4799
|
+
z62.z.object({
|
|
4800
|
+
type: z62.z.literal("message_start"),
|
|
4801
|
+
message: z62.z.object({
|
|
4802
|
+
id: z62.z.string().nullish(),
|
|
4803
|
+
model: z62.z.string().nullish(),
|
|
4804
|
+
usage: z62.z.looseObject({
|
|
4805
|
+
input_tokens: z62.z.number(),
|
|
4806
|
+
output_tokens: z62.z.number(),
|
|
4807
|
+
cache_creation_input_tokens: z62.z.number().nullish(),
|
|
4808
|
+
cache_read_input_tokens: z62.z.number().nullish()
|
|
4676
4809
|
})
|
|
4677
4810
|
})
|
|
4678
4811
|
}),
|
|
4679
|
-
|
|
4680
|
-
type:
|
|
4681
|
-
index:
|
|
4682
|
-
content_block:
|
|
4683
|
-
|
|
4684
|
-
type:
|
|
4685
|
-
text:
|
|
4812
|
+
z62.z.object({
|
|
4813
|
+
type: z62.z.literal("content_block_start"),
|
|
4814
|
+
index: z62.z.number(),
|
|
4815
|
+
content_block: z62.z.discriminatedUnion("type", [
|
|
4816
|
+
z62.z.object({
|
|
4817
|
+
type: z62.z.literal("text"),
|
|
4818
|
+
text: z62.z.string()
|
|
4686
4819
|
}),
|
|
4687
|
-
|
|
4688
|
-
type:
|
|
4689
|
-
thinking:
|
|
4820
|
+
z62.z.object({
|
|
4821
|
+
type: z62.z.literal("thinking"),
|
|
4822
|
+
thinking: z62.z.string()
|
|
4690
4823
|
}),
|
|
4691
|
-
|
|
4692
|
-
type:
|
|
4693
|
-
id:
|
|
4694
|
-
name:
|
|
4824
|
+
z62.z.object({
|
|
4825
|
+
type: z62.z.literal("tool_use"),
|
|
4826
|
+
id: z62.z.string(),
|
|
4827
|
+
name: z62.z.string()
|
|
4695
4828
|
}),
|
|
4696
|
-
|
|
4697
|
-
type:
|
|
4698
|
-
data:
|
|
4829
|
+
z62.z.object({
|
|
4830
|
+
type: z62.z.literal("redacted_thinking"),
|
|
4831
|
+
data: z62.z.string()
|
|
4699
4832
|
}),
|
|
4700
|
-
|
|
4701
|
-
type:
|
|
4702
|
-
id:
|
|
4703
|
-
name:
|
|
4704
|
-
input:
|
|
4833
|
+
z62.z.object({
|
|
4834
|
+
type: z62.z.literal("server_tool_use"),
|
|
4835
|
+
id: z62.z.string(),
|
|
4836
|
+
name: z62.z.string(),
|
|
4837
|
+
input: z62.z.record(z62.z.string(), z62.z.unknown()).nullish()
|
|
4705
4838
|
}),
|
|
4706
|
-
|
|
4707
|
-
type:
|
|
4708
|
-
tool_use_id:
|
|
4709
|
-
content:
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
type:
|
|
4713
|
-
url:
|
|
4714
|
-
title:
|
|
4715
|
-
encrypted_content:
|
|
4716
|
-
page_age:
|
|
4839
|
+
z62.z.object({
|
|
4840
|
+
type: z62.z.literal("web_search_tool_result"),
|
|
4841
|
+
tool_use_id: z62.z.string(),
|
|
4842
|
+
content: z62.z.union([
|
|
4843
|
+
z62.z.array(
|
|
4844
|
+
z62.z.object({
|
|
4845
|
+
type: z62.z.literal("web_search_result"),
|
|
4846
|
+
url: z62.z.string(),
|
|
4847
|
+
title: z62.z.string(),
|
|
4848
|
+
encrypted_content: z62.z.string(),
|
|
4849
|
+
page_age: z62.z.string().nullish()
|
|
4717
4850
|
})
|
|
4718
4851
|
),
|
|
4719
|
-
|
|
4720
|
-
type:
|
|
4721
|
-
error_code:
|
|
4852
|
+
z62.z.object({
|
|
4853
|
+
type: z62.z.literal("web_search_tool_result_error"),
|
|
4854
|
+
error_code: z62.z.string()
|
|
4855
|
+
})
|
|
4856
|
+
])
|
|
4857
|
+
}),
|
|
4858
|
+
z62.z.object({
|
|
4859
|
+
type: z62.z.literal("code_execution_tool_result"),
|
|
4860
|
+
tool_use_id: z62.z.string(),
|
|
4861
|
+
content: z62.z.union([
|
|
4862
|
+
z62.z.object({
|
|
4863
|
+
type: z62.z.literal("code_execution_result"),
|
|
4864
|
+
stdout: z62.z.string(),
|
|
4865
|
+
stderr: z62.z.string(),
|
|
4866
|
+
return_code: z62.z.number()
|
|
4867
|
+
}),
|
|
4868
|
+
z62.z.object({
|
|
4869
|
+
type: z62.z.literal("code_execution_tool_result_error"),
|
|
4870
|
+
error_code: z62.z.string()
|
|
4722
4871
|
})
|
|
4723
4872
|
])
|
|
4724
4873
|
})
|
|
4725
4874
|
])
|
|
4726
4875
|
}),
|
|
4727
|
-
|
|
4728
|
-
type:
|
|
4729
|
-
index:
|
|
4730
|
-
delta:
|
|
4731
|
-
|
|
4732
|
-
type:
|
|
4733
|
-
partial_json:
|
|
4876
|
+
z62.z.object({
|
|
4877
|
+
type: z62.z.literal("content_block_delta"),
|
|
4878
|
+
index: z62.z.number(),
|
|
4879
|
+
delta: z62.z.discriminatedUnion("type", [
|
|
4880
|
+
z62.z.object({
|
|
4881
|
+
type: z62.z.literal("input_json_delta"),
|
|
4882
|
+
partial_json: z62.z.string()
|
|
4734
4883
|
}),
|
|
4735
|
-
|
|
4736
|
-
type:
|
|
4737
|
-
text:
|
|
4884
|
+
z62.z.object({
|
|
4885
|
+
type: z62.z.literal("text_delta"),
|
|
4886
|
+
text: z62.z.string()
|
|
4738
4887
|
}),
|
|
4739
|
-
|
|
4740
|
-
type:
|
|
4741
|
-
thinking:
|
|
4888
|
+
z62.z.object({
|
|
4889
|
+
type: z62.z.literal("thinking_delta"),
|
|
4890
|
+
thinking: z62.z.string()
|
|
4742
4891
|
}),
|
|
4743
|
-
|
|
4744
|
-
type:
|
|
4745
|
-
signature:
|
|
4892
|
+
z62.z.object({
|
|
4893
|
+
type: z62.z.literal("signature_delta"),
|
|
4894
|
+
signature: z62.z.string()
|
|
4746
4895
|
}),
|
|
4747
|
-
|
|
4748
|
-
type:
|
|
4896
|
+
z62.z.object({
|
|
4897
|
+
type: z62.z.literal("citations_delta"),
|
|
4749
4898
|
citation: citationSchema
|
|
4750
4899
|
})
|
|
4751
4900
|
])
|
|
4752
4901
|
}),
|
|
4753
|
-
|
|
4754
|
-
type:
|
|
4755
|
-
index:
|
|
4902
|
+
z62.z.object({
|
|
4903
|
+
type: z62.z.literal("content_block_stop"),
|
|
4904
|
+
index: z62.z.number()
|
|
4756
4905
|
}),
|
|
4757
|
-
|
|
4758
|
-
type:
|
|
4759
|
-
error:
|
|
4760
|
-
type:
|
|
4761
|
-
message:
|
|
4906
|
+
z62.z.object({
|
|
4907
|
+
type: z62.z.literal("error"),
|
|
4908
|
+
error: z62.z.object({
|
|
4909
|
+
type: z62.z.string(),
|
|
4910
|
+
message: z62.z.string()
|
|
4762
4911
|
})
|
|
4763
4912
|
}),
|
|
4764
|
-
|
|
4765
|
-
type:
|
|
4766
|
-
delta:
|
|
4767
|
-
usage:
|
|
4913
|
+
z62.z.object({
|
|
4914
|
+
type: z62.z.literal("message_delta"),
|
|
4915
|
+
delta: z62.z.object({ stop_reason: z62.z.string().nullish() }),
|
|
4916
|
+
usage: z62.z.object({ output_tokens: z62.z.number() })
|
|
4768
4917
|
}),
|
|
4769
|
-
|
|
4770
|
-
type:
|
|
4918
|
+
z62.z.object({
|
|
4919
|
+
type: z62.z.literal("message_stop")
|
|
4771
4920
|
}),
|
|
4772
|
-
|
|
4773
|
-
type:
|
|
4921
|
+
z62.z.object({
|
|
4922
|
+
type: z62.z.literal("ping")
|
|
4774
4923
|
})
|
|
4775
4924
|
]);
|
|
4776
|
-
var anthropicReasoningMetadataSchema =
|
|
4777
|
-
signature:
|
|
4778
|
-
redactedData:
|
|
4925
|
+
var anthropicReasoningMetadataSchema = z62.z.object({
|
|
4926
|
+
signature: z62.z.string().optional(),
|
|
4927
|
+
redactedData: z62.z.string().optional()
|
|
4779
4928
|
});
|
|
4780
4929
|
var bash_20241022 = createProviderDefinedToolFactory({
|
|
4781
4930
|
id: "anthropic.bash_20241022",
|
|
4782
4931
|
name: "bash",
|
|
4783
|
-
inputSchema:
|
|
4784
|
-
command:
|
|
4785
|
-
restart:
|
|
4932
|
+
inputSchema: z62__default.default.object({
|
|
4933
|
+
command: z62__default.default.string(),
|
|
4934
|
+
restart: z62__default.default.boolean().optional()
|
|
4786
4935
|
})
|
|
4787
4936
|
});
|
|
4788
4937
|
var bash_20250124 = createProviderDefinedToolFactory({
|
|
4789
4938
|
id: "anthropic.bash_20250124",
|
|
4790
4939
|
name: "bash",
|
|
4791
|
-
inputSchema:
|
|
4792
|
-
command:
|
|
4793
|
-
restart:
|
|
4940
|
+
inputSchema: z62__default.default.object({
|
|
4941
|
+
command: z62__default.default.string(),
|
|
4942
|
+
restart: z62__default.default.boolean().optional()
|
|
4794
4943
|
})
|
|
4795
4944
|
});
|
|
4796
4945
|
var computer_20241022 = createProviderDefinedToolFactory({
|
|
4797
4946
|
id: "anthropic.computer_20241022",
|
|
4798
4947
|
name: "computer",
|
|
4799
|
-
inputSchema:
|
|
4800
|
-
action:
|
|
4948
|
+
inputSchema: z62.z.object({
|
|
4949
|
+
action: z62.z.enum([
|
|
4801
4950
|
"key",
|
|
4802
4951
|
"type",
|
|
4803
4952
|
"mouse_move",
|
|
@@ -4809,15 +4958,15 @@ var computer_20241022 = createProviderDefinedToolFactory({
|
|
|
4809
4958
|
"screenshot",
|
|
4810
4959
|
"cursor_position"
|
|
4811
4960
|
]),
|
|
4812
|
-
coordinate:
|
|
4813
|
-
text:
|
|
4961
|
+
coordinate: z62.z.array(z62.z.number().int()).optional(),
|
|
4962
|
+
text: z62.z.string().optional()
|
|
4814
4963
|
})
|
|
4815
4964
|
});
|
|
4816
4965
|
var computer_20250124 = createProviderDefinedToolFactory({
|
|
4817
4966
|
id: "anthropic.computer_20250124",
|
|
4818
4967
|
name: "computer",
|
|
4819
|
-
inputSchema:
|
|
4820
|
-
action:
|
|
4968
|
+
inputSchema: z62.z.object({
|
|
4969
|
+
action: z62.z.enum([
|
|
4821
4970
|
"key",
|
|
4822
4971
|
"hold_key",
|
|
4823
4972
|
"type",
|
|
@@ -4835,51 +4984,51 @@ var computer_20250124 = createProviderDefinedToolFactory({
|
|
|
4835
4984
|
"wait",
|
|
4836
4985
|
"screenshot"
|
|
4837
4986
|
]),
|
|
4838
|
-
coordinate:
|
|
4839
|
-
duration:
|
|
4840
|
-
scroll_amount:
|
|
4841
|
-
scroll_direction:
|
|
4842
|
-
start_coordinate:
|
|
4843
|
-
text:
|
|
4987
|
+
coordinate: z62.z.tuple([z62.z.number().int(), z62.z.number().int()]).optional(),
|
|
4988
|
+
duration: z62.z.number().optional(),
|
|
4989
|
+
scroll_amount: z62.z.number().optional(),
|
|
4990
|
+
scroll_direction: z62.z.enum(["up", "down", "left", "right"]).optional(),
|
|
4991
|
+
start_coordinate: z62.z.tuple([z62.z.number().int(), z62.z.number().int()]).optional(),
|
|
4992
|
+
text: z62.z.string().optional()
|
|
4844
4993
|
})
|
|
4845
4994
|
});
|
|
4846
4995
|
var textEditor_20241022 = createProviderDefinedToolFactory({
|
|
4847
4996
|
id: "anthropic.text_editor_20241022",
|
|
4848
4997
|
name: "str_replace_editor",
|
|
4849
|
-
inputSchema:
|
|
4850
|
-
command:
|
|
4851
|
-
path:
|
|
4852
|
-
file_text:
|
|
4853
|
-
insert_line:
|
|
4854
|
-
new_str:
|
|
4855
|
-
old_str:
|
|
4856
|
-
view_range:
|
|
4998
|
+
inputSchema: z62.z.object({
|
|
4999
|
+
command: z62.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5000
|
+
path: z62.z.string(),
|
|
5001
|
+
file_text: z62.z.string().optional(),
|
|
5002
|
+
insert_line: z62.z.number().int().optional(),
|
|
5003
|
+
new_str: z62.z.string().optional(),
|
|
5004
|
+
old_str: z62.z.string().optional(),
|
|
5005
|
+
view_range: z62.z.array(z62.z.number().int()).optional()
|
|
4857
5006
|
})
|
|
4858
5007
|
});
|
|
4859
5008
|
var textEditor_20250124 = createProviderDefinedToolFactory({
|
|
4860
5009
|
id: "anthropic.text_editor_20250124",
|
|
4861
5010
|
name: "str_replace_editor",
|
|
4862
|
-
inputSchema:
|
|
4863
|
-
command:
|
|
4864
|
-
path:
|
|
4865
|
-
file_text:
|
|
4866
|
-
insert_line:
|
|
4867
|
-
new_str:
|
|
4868
|
-
old_str:
|
|
4869
|
-
view_range:
|
|
5011
|
+
inputSchema: z62.z.object({
|
|
5012
|
+
command: z62.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
5013
|
+
path: z62.z.string(),
|
|
5014
|
+
file_text: z62.z.string().optional(),
|
|
5015
|
+
insert_line: z62.z.number().int().optional(),
|
|
5016
|
+
new_str: z62.z.string().optional(),
|
|
5017
|
+
old_str: z62.z.string().optional(),
|
|
5018
|
+
view_range: z62.z.array(z62.z.number().int()).optional()
|
|
4870
5019
|
})
|
|
4871
5020
|
});
|
|
4872
5021
|
var textEditor_20250429 = createProviderDefinedToolFactory({
|
|
4873
5022
|
id: "anthropic.text_editor_20250429",
|
|
4874
5023
|
name: "str_replace_based_edit_tool",
|
|
4875
|
-
inputSchema:
|
|
4876
|
-
command:
|
|
4877
|
-
path:
|
|
4878
|
-
file_text:
|
|
4879
|
-
insert_line:
|
|
4880
|
-
new_str:
|
|
4881
|
-
old_str:
|
|
4882
|
-
view_range:
|
|
5024
|
+
inputSchema: z62.z.object({
|
|
5025
|
+
command: z62.z.enum(["view", "create", "str_replace", "insert"]),
|
|
5026
|
+
path: z62.z.string(),
|
|
5027
|
+
file_text: z62.z.string().optional(),
|
|
5028
|
+
insert_line: z62.z.number().int().optional(),
|
|
5029
|
+
new_str: z62.z.string().optional(),
|
|
5030
|
+
old_str: z62.z.string().optional(),
|
|
5031
|
+
view_range: z62.z.array(z62.z.number().int()).optional()
|
|
4883
5032
|
})
|
|
4884
5033
|
});
|
|
4885
5034
|
var anthropicTools2 = {
|
|
@@ -4942,7 +5091,11 @@ var anthropicTools2 = {
|
|
|
4942
5091
|
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
4943
5092
|
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
4944
5093
|
*/
|
|
4945
|
-
webSearch_20250305
|
|
5094
|
+
webSearch_20250305,
|
|
5095
|
+
/**
|
|
5096
|
+
* Creates a tool for executing Python code. Must have name "code_execution".
|
|
5097
|
+
*/
|
|
5098
|
+
codeExecution_20250522
|
|
4946
5099
|
};
|
|
4947
5100
|
function createAnthropic2(options = {}) {
|
|
4948
5101
|
var _a16;
|
|
@@ -5437,6 +5590,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
5437
5590
|
args: {
|
|
5438
5591
|
generationConfig,
|
|
5439
5592
|
contents,
|
|
5593
|
+
systemInstruction,
|
|
5440
5594
|
tools: {
|
|
5441
5595
|
functionDeclarations: [
|
|
5442
5596
|
{
|
|
@@ -5919,23 +6073,23 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
5919
6073
|
return provider;
|
|
5920
6074
|
}
|
|
5921
6075
|
var google = createGoogleGenerativeAI();
|
|
5922
|
-
var googleErrorDataSchema2 =
|
|
5923
|
-
error:
|
|
5924
|
-
code:
|
|
5925
|
-
message:
|
|
5926
|
-
status:
|
|
6076
|
+
var googleErrorDataSchema2 = z62.z.object({
|
|
6077
|
+
error: z62.z.object({
|
|
6078
|
+
code: z62.z.number().nullable(),
|
|
6079
|
+
message: z62.z.string(),
|
|
6080
|
+
status: z62.z.string()
|
|
5927
6081
|
})
|
|
5928
6082
|
});
|
|
5929
6083
|
var googleFailedResponseHandler2 = createJsonErrorResponseHandler2({
|
|
5930
6084
|
errorSchema: googleErrorDataSchema2,
|
|
5931
6085
|
errorToMessage: (data) => data.error.message
|
|
5932
6086
|
});
|
|
5933
|
-
var googleGenerativeAIEmbeddingProviderOptions =
|
|
6087
|
+
var googleGenerativeAIEmbeddingProviderOptions = z62.z.object({
|
|
5934
6088
|
/**
|
|
5935
6089
|
* Optional. Optional reduced dimension for the output embedding.
|
|
5936
6090
|
* If set, excessive values in the output embedding are truncated from the end.
|
|
5937
6091
|
*/
|
|
5938
|
-
outputDimensionality:
|
|
6092
|
+
outputDimensionality: z62.z.number().optional(),
|
|
5939
6093
|
/**
|
|
5940
6094
|
* Optional. Specifies the task type for generating embeddings.
|
|
5941
6095
|
* Supported task types:
|
|
@@ -5948,7 +6102,7 @@ var googleGenerativeAIEmbeddingProviderOptions = z52.z.object({
|
|
|
5948
6102
|
* - FACT_VERIFICATION: Optimized for verifying factual information.
|
|
5949
6103
|
* - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
|
|
5950
6104
|
*/
|
|
5951
|
-
taskType:
|
|
6105
|
+
taskType: z62.z.enum([
|
|
5952
6106
|
"SEMANTIC_SIMILARITY",
|
|
5953
6107
|
"CLASSIFICATION",
|
|
5954
6108
|
"CLUSTERING",
|
|
@@ -6051,11 +6205,11 @@ var GoogleGenerativeAIEmbeddingModel2 = class {
|
|
|
6051
6205
|
};
|
|
6052
6206
|
}
|
|
6053
6207
|
};
|
|
6054
|
-
var googleGenerativeAITextEmbeddingResponseSchema2 =
|
|
6055
|
-
embeddings:
|
|
6208
|
+
var googleGenerativeAITextEmbeddingResponseSchema2 = z62.z.object({
|
|
6209
|
+
embeddings: z62.z.array(z62.z.object({ values: z62.z.array(z62.z.number()) }))
|
|
6056
6210
|
});
|
|
6057
|
-
var googleGenerativeAISingleEmbeddingResponseSchema =
|
|
6058
|
-
embedding:
|
|
6211
|
+
var googleGenerativeAISingleEmbeddingResponseSchema = z62.z.object({
|
|
6212
|
+
embedding: z62.z.object({ values: z62.z.array(z62.z.number()) })
|
|
6059
6213
|
});
|
|
6060
6214
|
function convertJSONSchemaToOpenAPISchema2(jsonSchema) {
|
|
6061
6215
|
if (jsonSchema == null || isEmptyObjectSchema2(jsonSchema)) {
|
|
@@ -6205,9 +6359,20 @@ function convertToGoogleGenerativeAIMessages2(prompt, options) {
|
|
|
6205
6359
|
contents.push({
|
|
6206
6360
|
role: "model",
|
|
6207
6361
|
parts: content.map((part) => {
|
|
6362
|
+
var _a23, _b, _c, _d, _e, _f;
|
|
6208
6363
|
switch (part.type) {
|
|
6209
6364
|
case "text": {
|
|
6210
|
-
return part.text.length === 0 ? void 0 : {
|
|
6365
|
+
return part.text.length === 0 ? void 0 : {
|
|
6366
|
+
text: part.text,
|
|
6367
|
+
thoughtSignature: (_b = (_a23 = part.providerOptions) == null ? void 0 : _a23.google) == null ? void 0 : _b.thoughtSignature
|
|
6368
|
+
};
|
|
6369
|
+
}
|
|
6370
|
+
case "reasoning": {
|
|
6371
|
+
return part.text.length === 0 ? void 0 : {
|
|
6372
|
+
text: part.text,
|
|
6373
|
+
thought: true,
|
|
6374
|
+
thoughtSignature: (_d = (_c = part.providerOptions) == null ? void 0 : _c.google) == null ? void 0 : _d.thoughtSignature
|
|
6375
|
+
};
|
|
6211
6376
|
}
|
|
6212
6377
|
case "file": {
|
|
6213
6378
|
if (part.mediaType !== "image/png") {
|
|
@@ -6232,7 +6397,8 @@ function convertToGoogleGenerativeAIMessages2(prompt, options) {
|
|
|
6232
6397
|
functionCall: {
|
|
6233
6398
|
name: part.toolName,
|
|
6234
6399
|
args: part.input
|
|
6235
|
-
}
|
|
6400
|
+
},
|
|
6401
|
+
thoughtSignature: (_f = (_e = part.providerOptions) == null ? void 0 : _e.google) == null ? void 0 : _f.thoughtSignature
|
|
6236
6402
|
};
|
|
6237
6403
|
}
|
|
6238
6404
|
}
|
|
@@ -6270,18 +6436,18 @@ function convertToGoogleGenerativeAIMessages2(prompt, options) {
|
|
|
6270
6436
|
function getModelPath2(modelId) {
|
|
6271
6437
|
return modelId.includes("/") ? modelId : `models/${modelId}`;
|
|
6272
6438
|
}
|
|
6273
|
-
var googleGenerativeAIProviderOptions =
|
|
6274
|
-
responseModalities:
|
|
6275
|
-
thinkingConfig:
|
|
6276
|
-
thinkingBudget:
|
|
6277
|
-
includeThoughts:
|
|
6439
|
+
var googleGenerativeAIProviderOptions = z62.z.object({
|
|
6440
|
+
responseModalities: z62.z.array(z62.z.enum(["TEXT", "IMAGE"])).optional(),
|
|
6441
|
+
thinkingConfig: z62.z.object({
|
|
6442
|
+
thinkingBudget: z62.z.number().optional(),
|
|
6443
|
+
includeThoughts: z62.z.boolean().optional()
|
|
6278
6444
|
}).optional(),
|
|
6279
6445
|
/**
|
|
6280
6446
|
Optional.
|
|
6281
6447
|
The name of the cached content used as context to serve the prediction.
|
|
6282
6448
|
Format: cachedContents/{cachedContent}
|
|
6283
6449
|
*/
|
|
6284
|
-
cachedContent:
|
|
6450
|
+
cachedContent: z62.z.string().optional(),
|
|
6285
6451
|
/**
|
|
6286
6452
|
* Optional. Enable structured output. Default is true.
|
|
6287
6453
|
*
|
|
@@ -6290,13 +6456,13 @@ var googleGenerativeAIProviderOptions = z52.z.object({
|
|
|
6290
6456
|
* Google Generative AI uses. You can use this to disable
|
|
6291
6457
|
* structured outputs if you need to.
|
|
6292
6458
|
*/
|
|
6293
|
-
structuredOutputs:
|
|
6459
|
+
structuredOutputs: z62.z.boolean().optional(),
|
|
6294
6460
|
/**
|
|
6295
6461
|
Optional. A list of unique safety settings for blocking unsafe content.
|
|
6296
6462
|
*/
|
|
6297
|
-
safetySettings:
|
|
6298
|
-
|
|
6299
|
-
category:
|
|
6463
|
+
safetySettings: z62.z.array(
|
|
6464
|
+
z62.z.object({
|
|
6465
|
+
category: z62.z.enum([
|
|
6300
6466
|
"HARM_CATEGORY_UNSPECIFIED",
|
|
6301
6467
|
"HARM_CATEGORY_HATE_SPEECH",
|
|
6302
6468
|
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
|
@@ -6304,7 +6470,7 @@ var googleGenerativeAIProviderOptions = z52.z.object({
|
|
|
6304
6470
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
|
6305
6471
|
"HARM_CATEGORY_CIVIC_INTEGRITY"
|
|
6306
6472
|
]),
|
|
6307
|
-
threshold:
|
|
6473
|
+
threshold: z62.z.enum([
|
|
6308
6474
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
6309
6475
|
"BLOCK_LOW_AND_ABOVE",
|
|
6310
6476
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -6314,7 +6480,7 @@ var googleGenerativeAIProviderOptions = z52.z.object({
|
|
|
6314
6480
|
])
|
|
6315
6481
|
})
|
|
6316
6482
|
).optional(),
|
|
6317
|
-
threshold:
|
|
6483
|
+
threshold: z62.z.enum([
|
|
6318
6484
|
"HARM_BLOCK_THRESHOLD_UNSPECIFIED",
|
|
6319
6485
|
"BLOCK_LOW_AND_ABOVE",
|
|
6320
6486
|
"BLOCK_MEDIUM_AND_ABOVE",
|
|
@@ -6327,7 +6493,13 @@ var googleGenerativeAIProviderOptions = z52.z.object({
|
|
|
6327
6493
|
*
|
|
6328
6494
|
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
|
|
6329
6495
|
*/
|
|
6330
|
-
audioTimestamp:
|
|
6496
|
+
audioTimestamp: z62.z.boolean().optional(),
|
|
6497
|
+
/**
|
|
6498
|
+
* Optional. Defines labels used in billing reports. Available on Vertex AI only.
|
|
6499
|
+
*
|
|
6500
|
+
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
|
|
6501
|
+
*/
|
|
6502
|
+
labels: z62.z.record(z62.z.string(), z62.z.string()).optional()
|
|
6331
6503
|
});
|
|
6332
6504
|
function prepareTools4({
|
|
6333
6505
|
tools,
|
|
@@ -6493,55 +6665,55 @@ function mapGoogleGenerativeAIFinishReason2({
|
|
|
6493
6665
|
return "unknown";
|
|
6494
6666
|
}
|
|
6495
6667
|
}
|
|
6496
|
-
var groundingChunkSchema2 =
|
|
6497
|
-
web:
|
|
6498
|
-
retrievedContext:
|
|
6668
|
+
var groundingChunkSchema2 = z62.z.object({
|
|
6669
|
+
web: z62.z.object({ uri: z62.z.string(), title: z62.z.string() }).nullish(),
|
|
6670
|
+
retrievedContext: z62.z.object({ uri: z62.z.string(), title: z62.z.string() }).nullish()
|
|
6499
6671
|
});
|
|
6500
|
-
var groundingMetadataSchema2 =
|
|
6501
|
-
webSearchQueries:
|
|
6502
|
-
retrievalQueries:
|
|
6503
|
-
searchEntryPoint:
|
|
6504
|
-
groundingChunks:
|
|
6505
|
-
groundingSupports:
|
|
6506
|
-
|
|
6507
|
-
segment:
|
|
6508
|
-
startIndex:
|
|
6509
|
-
endIndex:
|
|
6510
|
-
text:
|
|
6672
|
+
var groundingMetadataSchema2 = z62.z.object({
|
|
6673
|
+
webSearchQueries: z62.z.array(z62.z.string()).nullish(),
|
|
6674
|
+
retrievalQueries: z62.z.array(z62.z.string()).nullish(),
|
|
6675
|
+
searchEntryPoint: z62.z.object({ renderedContent: z62.z.string() }).nullish(),
|
|
6676
|
+
groundingChunks: z62.z.array(groundingChunkSchema2).nullish(),
|
|
6677
|
+
groundingSupports: z62.z.array(
|
|
6678
|
+
z62.z.object({
|
|
6679
|
+
segment: z62.z.object({
|
|
6680
|
+
startIndex: z62.z.number().nullish(),
|
|
6681
|
+
endIndex: z62.z.number().nullish(),
|
|
6682
|
+
text: z62.z.string().nullish()
|
|
6511
6683
|
}),
|
|
6512
|
-
segment_text:
|
|
6513
|
-
groundingChunkIndices:
|
|
6514
|
-
supportChunkIndices:
|
|
6515
|
-
confidenceScores:
|
|
6516
|
-
confidenceScore:
|
|
6684
|
+
segment_text: z62.z.string().nullish(),
|
|
6685
|
+
groundingChunkIndices: z62.z.array(z62.z.number()).nullish(),
|
|
6686
|
+
supportChunkIndices: z62.z.array(z62.z.number()).nullish(),
|
|
6687
|
+
confidenceScores: z62.z.array(z62.z.number()).nullish(),
|
|
6688
|
+
confidenceScore: z62.z.array(z62.z.number()).nullish()
|
|
6517
6689
|
})
|
|
6518
6690
|
).nullish(),
|
|
6519
|
-
retrievalMetadata:
|
|
6520
|
-
|
|
6521
|
-
webDynamicRetrievalScore:
|
|
6691
|
+
retrievalMetadata: z62.z.union([
|
|
6692
|
+
z62.z.object({
|
|
6693
|
+
webDynamicRetrievalScore: z62.z.number()
|
|
6522
6694
|
}),
|
|
6523
|
-
|
|
6695
|
+
z62.z.object({})
|
|
6524
6696
|
]).nullish()
|
|
6525
6697
|
});
|
|
6526
6698
|
var googleSearch = createProviderDefinedToolFactory({
|
|
6527
6699
|
id: "google.google_search",
|
|
6528
6700
|
name: "google_search",
|
|
6529
|
-
inputSchema:
|
|
6530
|
-
mode:
|
|
6531
|
-
dynamicThreshold:
|
|
6701
|
+
inputSchema: z62.z.object({
|
|
6702
|
+
mode: z62.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
|
|
6703
|
+
dynamicThreshold: z62.z.number().default(1)
|
|
6532
6704
|
})
|
|
6533
6705
|
});
|
|
6534
|
-
var urlMetadataSchema =
|
|
6535
|
-
retrievedUrl:
|
|
6536
|
-
urlRetrievalStatus:
|
|
6706
|
+
var urlMetadataSchema = z62.z.object({
|
|
6707
|
+
retrievedUrl: z62.z.string(),
|
|
6708
|
+
urlRetrievalStatus: z62.z.string()
|
|
6537
6709
|
});
|
|
6538
|
-
var urlContextMetadataSchema =
|
|
6539
|
-
urlMetadata:
|
|
6710
|
+
var urlContextMetadataSchema = z62.z.object({
|
|
6711
|
+
urlMetadata: z62.z.array(urlMetadataSchema)
|
|
6540
6712
|
});
|
|
6541
6713
|
var urlContext = createProviderDefinedToolFactory({
|
|
6542
6714
|
id: "google.url_context",
|
|
6543
6715
|
name: "url_context",
|
|
6544
|
-
inputSchema:
|
|
6716
|
+
inputSchema: z62.z.object({})
|
|
6545
6717
|
});
|
|
6546
6718
|
var GoogleGenerativeAILanguageModel2 = class {
|
|
6547
6719
|
constructor(modelId, config) {
|
|
@@ -6630,7 +6802,8 @@ var GoogleGenerativeAILanguageModel2 = class {
|
|
|
6630
6802
|
safetySettings: googleOptions == null ? void 0 : googleOptions.safetySettings,
|
|
6631
6803
|
tools: googleTools2,
|
|
6632
6804
|
toolConfig: googleToolConfig,
|
|
6633
|
-
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent
|
|
6805
|
+
cachedContent: googleOptions == null ? void 0 : googleOptions.cachedContent,
|
|
6806
|
+
labels: googleOptions == null ? void 0 : googleOptions.labels
|
|
6634
6807
|
},
|
|
6635
6808
|
warnings: [...warnings, ...toolWarnings]
|
|
6636
6809
|
};
|
|
@@ -6688,17 +6861,18 @@ var GoogleGenerativeAILanguageModel2 = class {
|
|
|
6688
6861
|
});
|
|
6689
6862
|
lastCodeExecutionToolCallId = void 0;
|
|
6690
6863
|
} else if ("text" in part && part.text != null && part.text.length > 0) {
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
}
|
|
6864
|
+
content.push({
|
|
6865
|
+
type: part.thought === true ? "reasoning" : "text",
|
|
6866
|
+
text: part.text,
|
|
6867
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
6868
|
+
});
|
|
6696
6869
|
} else if ("functionCall" in part) {
|
|
6697
6870
|
content.push({
|
|
6698
6871
|
type: "tool-call",
|
|
6699
6872
|
toolCallId: this.config.generateId(),
|
|
6700
6873
|
toolName: part.functionCall.name,
|
|
6701
|
-
input: JSON.stringify(part.functionCall.args)
|
|
6874
|
+
input: JSON.stringify(part.functionCall.args),
|
|
6875
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
6702
6876
|
});
|
|
6703
6877
|
} else if ("inlineData" in part) {
|
|
6704
6878
|
content.push({
|
|
@@ -6860,13 +7034,21 @@ var GoogleGenerativeAILanguageModel2 = class {
|
|
|
6860
7034
|
currentReasoningBlockId = String(blockCounter++);
|
|
6861
7035
|
controller.enqueue({
|
|
6862
7036
|
type: "reasoning-start",
|
|
6863
|
-
id: currentReasoningBlockId
|
|
7037
|
+
id: currentReasoningBlockId,
|
|
7038
|
+
providerMetadata: part.thoughtSignature ? {
|
|
7039
|
+
google: {
|
|
7040
|
+
thoughtSignature: part.thoughtSignature
|
|
7041
|
+
}
|
|
7042
|
+
} : void 0
|
|
6864
7043
|
});
|
|
6865
7044
|
}
|
|
6866
7045
|
controller.enqueue({
|
|
6867
7046
|
type: "reasoning-delta",
|
|
6868
7047
|
id: currentReasoningBlockId,
|
|
6869
|
-
delta: part.text
|
|
7048
|
+
delta: part.text,
|
|
7049
|
+
providerMetadata: part.thoughtSignature ? {
|
|
7050
|
+
google: { thoughtSignature: part.thoughtSignature }
|
|
7051
|
+
} : void 0
|
|
6870
7052
|
});
|
|
6871
7053
|
} else {
|
|
6872
7054
|
if (currentReasoningBlockId !== null) {
|
|
@@ -6880,13 +7062,21 @@ var GoogleGenerativeAILanguageModel2 = class {
|
|
|
6880
7062
|
currentTextBlockId = String(blockCounter++);
|
|
6881
7063
|
controller.enqueue({
|
|
6882
7064
|
type: "text-start",
|
|
6883
|
-
id: currentTextBlockId
|
|
7065
|
+
id: currentTextBlockId,
|
|
7066
|
+
providerMetadata: part.thoughtSignature ? {
|
|
7067
|
+
google: {
|
|
7068
|
+
thoughtSignature: part.thoughtSignature
|
|
7069
|
+
}
|
|
7070
|
+
} : void 0
|
|
6884
7071
|
});
|
|
6885
7072
|
}
|
|
6886
7073
|
controller.enqueue({
|
|
6887
7074
|
type: "text-delta",
|
|
6888
7075
|
id: currentTextBlockId,
|
|
6889
|
-
delta: part.text
|
|
7076
|
+
delta: part.text,
|
|
7077
|
+
providerMetadata: part.thoughtSignature ? {
|
|
7078
|
+
google: { thoughtSignature: part.thoughtSignature }
|
|
7079
|
+
} : void 0
|
|
6890
7080
|
});
|
|
6891
7081
|
}
|
|
6892
7082
|
}
|
|
@@ -6910,22 +7100,26 @@ var GoogleGenerativeAILanguageModel2 = class {
|
|
|
6910
7100
|
controller.enqueue({
|
|
6911
7101
|
type: "tool-input-start",
|
|
6912
7102
|
id: toolCall.toolCallId,
|
|
6913
|
-
toolName: toolCall.toolName
|
|
7103
|
+
toolName: toolCall.toolName,
|
|
7104
|
+
providerMetadata: toolCall.providerMetadata
|
|
6914
7105
|
});
|
|
6915
7106
|
controller.enqueue({
|
|
6916
7107
|
type: "tool-input-delta",
|
|
6917
7108
|
id: toolCall.toolCallId,
|
|
6918
|
-
delta: toolCall.args
|
|
7109
|
+
delta: toolCall.args,
|
|
7110
|
+
providerMetadata: toolCall.providerMetadata
|
|
6919
7111
|
});
|
|
6920
7112
|
controller.enqueue({
|
|
6921
7113
|
type: "tool-input-end",
|
|
6922
|
-
id: toolCall.toolCallId
|
|
7114
|
+
id: toolCall.toolCallId,
|
|
7115
|
+
providerMetadata: toolCall.providerMetadata
|
|
6923
7116
|
});
|
|
6924
7117
|
controller.enqueue({
|
|
6925
7118
|
type: "tool-call",
|
|
6926
7119
|
toolCallId: toolCall.toolCallId,
|
|
6927
7120
|
toolName: toolCall.toolName,
|
|
6928
|
-
input: toolCall.args
|
|
7121
|
+
input: toolCall.args,
|
|
7122
|
+
providerMetadata: toolCall.providerMetadata
|
|
6929
7123
|
});
|
|
6930
7124
|
hasToolCalls = true;
|
|
6931
7125
|
}
|
|
@@ -6986,7 +7180,8 @@ function getToolCallsFromParts2({
|
|
|
6986
7180
|
type: "tool-call",
|
|
6987
7181
|
toolCallId: generateId3(),
|
|
6988
7182
|
toolName: part.functionCall.name,
|
|
6989
|
-
args: JSON.stringify(part.functionCall.args)
|
|
7183
|
+
args: JSON.stringify(part.functionCall.args),
|
|
7184
|
+
providerMetadata: part.thoughtSignature ? { google: { thoughtSignature: part.thoughtSignature } } : void 0
|
|
6990
7185
|
}));
|
|
6991
7186
|
}
|
|
6992
7187
|
function getInlineDataParts2(parts) {
|
|
@@ -7009,70 +7204,72 @@ function extractSources2({
|
|
|
7009
7204
|
title: chunk.web.title
|
|
7010
7205
|
}));
|
|
7011
7206
|
}
|
|
7012
|
-
var contentSchema2 =
|
|
7013
|
-
parts:
|
|
7014
|
-
|
|
7207
|
+
var contentSchema2 = z62.z.object({
|
|
7208
|
+
parts: z62.z.array(
|
|
7209
|
+
z62.z.union([
|
|
7015
7210
|
// note: order matters since text can be fully empty
|
|
7016
|
-
|
|
7017
|
-
functionCall:
|
|
7018
|
-
name:
|
|
7019
|
-
args:
|
|
7020
|
-
})
|
|
7211
|
+
z62.z.object({
|
|
7212
|
+
functionCall: z62.z.object({
|
|
7213
|
+
name: z62.z.string(),
|
|
7214
|
+
args: z62.z.unknown()
|
|
7215
|
+
}),
|
|
7216
|
+
thoughtSignature: z62.z.string().nullish()
|
|
7021
7217
|
}),
|
|
7022
|
-
|
|
7023
|
-
inlineData:
|
|
7024
|
-
mimeType:
|
|
7025
|
-
data:
|
|
7218
|
+
z62.z.object({
|
|
7219
|
+
inlineData: z62.z.object({
|
|
7220
|
+
mimeType: z62.z.string(),
|
|
7221
|
+
data: z62.z.string()
|
|
7026
7222
|
})
|
|
7027
7223
|
}),
|
|
7028
|
-
|
|
7029
|
-
executableCode:
|
|
7030
|
-
language:
|
|
7031
|
-
code:
|
|
7224
|
+
z62.z.object({
|
|
7225
|
+
executableCode: z62.z.object({
|
|
7226
|
+
language: z62.z.string(),
|
|
7227
|
+
code: z62.z.string()
|
|
7032
7228
|
}).nullish(),
|
|
7033
|
-
codeExecutionResult:
|
|
7034
|
-
outcome:
|
|
7035
|
-
output:
|
|
7229
|
+
codeExecutionResult: z62.z.object({
|
|
7230
|
+
outcome: z62.z.string(),
|
|
7231
|
+
output: z62.z.string()
|
|
7036
7232
|
}).nullish(),
|
|
7037
|
-
text:
|
|
7038
|
-
thought:
|
|
7233
|
+
text: z62.z.string().nullish(),
|
|
7234
|
+
thought: z62.z.boolean().nullish(),
|
|
7235
|
+
thoughtSignature: z62.z.string().nullish()
|
|
7039
7236
|
})
|
|
7040
7237
|
])
|
|
7041
7238
|
).nullish()
|
|
7042
7239
|
});
|
|
7043
|
-
var safetyRatingSchema2 =
|
|
7044
|
-
category:
|
|
7045
|
-
probability:
|
|
7046
|
-
probabilityScore:
|
|
7047
|
-
severity:
|
|
7048
|
-
severityScore:
|
|
7049
|
-
blocked:
|
|
7240
|
+
var safetyRatingSchema2 = z62.z.object({
|
|
7241
|
+
category: z62.z.string().nullish(),
|
|
7242
|
+
probability: z62.z.string().nullish(),
|
|
7243
|
+
probabilityScore: z62.z.number().nullish(),
|
|
7244
|
+
severity: z62.z.string().nullish(),
|
|
7245
|
+
severityScore: z62.z.number().nullish(),
|
|
7246
|
+
blocked: z62.z.boolean().nullish()
|
|
7050
7247
|
});
|
|
7051
|
-
var usageSchema =
|
|
7052
|
-
cachedContentTokenCount:
|
|
7053
|
-
thoughtsTokenCount:
|
|
7054
|
-
promptTokenCount:
|
|
7055
|
-
candidatesTokenCount:
|
|
7056
|
-
totalTokenCount:
|
|
7248
|
+
var usageSchema = z62.z.object({
|
|
7249
|
+
cachedContentTokenCount: z62.z.number().nullish(),
|
|
7250
|
+
thoughtsTokenCount: z62.z.number().nullish(),
|
|
7251
|
+
promptTokenCount: z62.z.number().nullish(),
|
|
7252
|
+
candidatesTokenCount: z62.z.number().nullish(),
|
|
7253
|
+
totalTokenCount: z62.z.number().nullish()
|
|
7057
7254
|
});
|
|
7058
|
-
var responseSchema2 =
|
|
7059
|
-
candidates:
|
|
7060
|
-
|
|
7061
|
-
content: contentSchema2.nullish().or(
|
|
7062
|
-
finishReason:
|
|
7063
|
-
safetyRatings:
|
|
7255
|
+
var responseSchema2 = z62.z.object({
|
|
7256
|
+
candidates: z62.z.array(
|
|
7257
|
+
z62.z.object({
|
|
7258
|
+
content: contentSchema2.nullish().or(z62.z.object({}).strict()),
|
|
7259
|
+
finishReason: z62.z.string().nullish(),
|
|
7260
|
+
safetyRatings: z62.z.array(safetyRatingSchema2).nullish(),
|
|
7064
7261
|
groundingMetadata: groundingMetadataSchema2.nullish(),
|
|
7065
7262
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
|
7066
7263
|
})
|
|
7067
7264
|
),
|
|
7068
7265
|
usageMetadata: usageSchema.nullish()
|
|
7069
7266
|
});
|
|
7070
|
-
var chunkSchema2 =
|
|
7071
|
-
candidates:
|
|
7072
|
-
|
|
7267
|
+
var chunkSchema2 = z62.z.object({
|
|
7268
|
+
candidates: z62.z.array(
|
|
7269
|
+
z62.z.object({
|
|
7073
7270
|
content: contentSchema2.nullish(),
|
|
7074
|
-
finishReason:
|
|
7075
|
-
safetyRatings:
|
|
7271
|
+
finishReason: z62.z.string().nullish(),
|
|
7272
|
+
safetyRatings: z62.z.array(safetyRatingSchema2).nullish(),
|
|
7076
7273
|
groundingMetadata: groundingMetadataSchema2.nullish(),
|
|
7077
7274
|
urlContextMetadata: urlContextMetadataSchema.nullish()
|
|
7078
7275
|
})
|
|
@@ -7082,13 +7279,13 @@ var chunkSchema2 = z52.z.object({
|
|
|
7082
7279
|
var codeExecution = createProviderDefinedToolFactoryWithOutputSchema({
|
|
7083
7280
|
id: "google.code_execution",
|
|
7084
7281
|
name: "code_execution",
|
|
7085
|
-
inputSchema:
|
|
7086
|
-
language:
|
|
7087
|
-
code:
|
|
7282
|
+
inputSchema: z62.z.object({
|
|
7283
|
+
language: z62.z.string().describe("The programming language of the code."),
|
|
7284
|
+
code: z62.z.string().describe("The code to be executed.")
|
|
7088
7285
|
}),
|
|
7089
|
-
outputSchema:
|
|
7090
|
-
outcome:
|
|
7091
|
-
output:
|
|
7286
|
+
outputSchema: z62.z.object({
|
|
7287
|
+
outcome: z62.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
|
|
7288
|
+
output: z62.z.string().describe("The output from the code execution.")
|
|
7092
7289
|
})
|
|
7093
7290
|
});
|
|
7094
7291
|
var googleTools = {
|
|
@@ -7205,12 +7402,12 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
7205
7402
|
};
|
|
7206
7403
|
}
|
|
7207
7404
|
};
|
|
7208
|
-
var googleImageResponseSchema =
|
|
7209
|
-
predictions:
|
|
7405
|
+
var googleImageResponseSchema = z62.z.object({
|
|
7406
|
+
predictions: z62.z.array(z62.z.object({ bytesBase64Encoded: z62.z.string() })).default([])
|
|
7210
7407
|
});
|
|
7211
|
-
var googleImageProviderOptionsSchema =
|
|
7212
|
-
personGeneration:
|
|
7213
|
-
aspectRatio:
|
|
7408
|
+
var googleImageProviderOptionsSchema = z62.z.object({
|
|
7409
|
+
personGeneration: z62.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
7410
|
+
aspectRatio: z62.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
7214
7411
|
});
|
|
7215
7412
|
function createGoogleGenerativeAI2(options = {}) {
|
|
7216
7413
|
var _a16;
|
|
@@ -7232,9 +7429,14 @@ function createGoogleGenerativeAI2(options = {}) {
|
|
|
7232
7429
|
generateId: (_a23 = options.generateId) != null ? _a23 : generateId2,
|
|
7233
7430
|
supportedUrls: () => ({
|
|
7234
7431
|
"*": [
|
|
7235
|
-
//
|
|
7432
|
+
// Google Generative Language "files" endpoint
|
|
7236
7433
|
// e.g. https://generativelanguage.googleapis.com/v1beta/files/...
|
|
7237
|
-
new RegExp(`^${baseURL}/files/.*$`)
|
|
7434
|
+
new RegExp(`^${baseURL}/files/.*$`),
|
|
7435
|
+
// YouTube URLs (public or unlisted videos)
|
|
7436
|
+
new RegExp(
|
|
7437
|
+
`^https://(?:www\\.)?youtube\\.com/watch\\?v=[\\w-]+(?:&[\\w=&.-]*)?$`
|
|
7438
|
+
),
|
|
7439
|
+
new RegExp(`^https://youtu\\.be/[\\w-]+(?:\\?[\\w=&.-]*)?$`)
|
|
7238
7440
|
]
|
|
7239
7441
|
}),
|
|
7240
7442
|
fetch: options.fetch
|
|
@@ -7389,12 +7591,12 @@ function prepareTools5({
|
|
|
7389
7591
|
return { tools: void 0, tool_choice: void 0, toolWarnings };
|
|
7390
7592
|
}
|
|
7391
7593
|
const toolChoice = mode.toolChoice;
|
|
7392
|
-
const
|
|
7594
|
+
const groqTools2 = [];
|
|
7393
7595
|
for (const tool2 of tools) {
|
|
7394
7596
|
if (tool2.type === "provider-defined") {
|
|
7395
7597
|
toolWarnings.push({ type: "unsupported-tool", tool: tool2 });
|
|
7396
7598
|
} else {
|
|
7397
|
-
|
|
7599
|
+
groqTools2.push({
|
|
7398
7600
|
type: "function",
|
|
7399
7601
|
function: {
|
|
7400
7602
|
name: tool2.name,
|
|
@@ -7405,17 +7607,17 @@ function prepareTools5({
|
|
|
7405
7607
|
}
|
|
7406
7608
|
}
|
|
7407
7609
|
if (toolChoice == null) {
|
|
7408
|
-
return { tools:
|
|
7610
|
+
return { tools: groqTools2, tool_choice: void 0, toolWarnings };
|
|
7409
7611
|
}
|
|
7410
7612
|
const type = toolChoice.type;
|
|
7411
7613
|
switch (type) {
|
|
7412
7614
|
case "auto":
|
|
7413
7615
|
case "none":
|
|
7414
7616
|
case "required":
|
|
7415
|
-
return { tools:
|
|
7617
|
+
return { tools: groqTools2, tool_choice: type, toolWarnings };
|
|
7416
7618
|
case "tool":
|
|
7417
7619
|
return {
|
|
7418
|
-
tools:
|
|
7620
|
+
tools: groqTools2,
|
|
7419
7621
|
tool_choice: {
|
|
7420
7622
|
type: "function",
|
|
7421
7623
|
function: {
|
|
@@ -8056,7 +8258,7 @@ function convertToGroqChatMessages2(prompt) {
|
|
|
8056
8258
|
return {
|
|
8057
8259
|
type: "image_url",
|
|
8058
8260
|
image_url: {
|
|
8059
|
-
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`
|
|
8261
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
8060
8262
|
}
|
|
8061
8263
|
};
|
|
8062
8264
|
}
|
|
@@ -8067,9 +8269,16 @@ function convertToGroqChatMessages2(prompt) {
|
|
|
8067
8269
|
}
|
|
8068
8270
|
case "assistant": {
|
|
8069
8271
|
let text = "";
|
|
8272
|
+
let reasoning = "";
|
|
8070
8273
|
const toolCalls = [];
|
|
8071
8274
|
for (const part of content) {
|
|
8072
8275
|
switch (part.type) {
|
|
8276
|
+
// groq supports reasoning for tool-calls in multi-turn conversations
|
|
8277
|
+
// https://github.com/vercel/ai/issues/7860
|
|
8278
|
+
case "reasoning": {
|
|
8279
|
+
reasoning += part.text;
|
|
8280
|
+
break;
|
|
8281
|
+
}
|
|
8073
8282
|
case "text": {
|
|
8074
8283
|
text += part.text;
|
|
8075
8284
|
break;
|
|
@@ -8090,7 +8299,8 @@ function convertToGroqChatMessages2(prompt) {
|
|
|
8090
8299
|
messages.push({
|
|
8091
8300
|
role: "assistant",
|
|
8092
8301
|
content: text,
|
|
8093
|
-
|
|
8302
|
+
...reasoning.length > 0 ? { reasoning } : null,
|
|
8303
|
+
...toolCalls.length > 0 ? { tool_calls: toolCalls } : null
|
|
8094
8304
|
});
|
|
8095
8305
|
break;
|
|
8096
8306
|
}
|
|
@@ -8136,49 +8346,75 @@ function getResponseMetadata2({
|
|
|
8136
8346
|
timestamp: created != null ? new Date(created * 1e3) : void 0
|
|
8137
8347
|
};
|
|
8138
8348
|
}
|
|
8139
|
-
var groqProviderOptions =
|
|
8140
|
-
reasoningFormat:
|
|
8349
|
+
var groqProviderOptions = z62.z.object({
|
|
8350
|
+
reasoningFormat: z62.z.enum(["parsed", "raw", "hidden"]).optional(),
|
|
8351
|
+
reasoningEffort: z62.z.string().optional(),
|
|
8141
8352
|
/**
|
|
8142
8353
|
* Whether to enable parallel function calling during tool use. Default to true.
|
|
8143
8354
|
*/
|
|
8144
|
-
parallelToolCalls:
|
|
8355
|
+
parallelToolCalls: z62.z.boolean().optional(),
|
|
8145
8356
|
/**
|
|
8146
8357
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
8147
8358
|
* monitor and detect abuse. Learn more.
|
|
8148
8359
|
*/
|
|
8149
|
-
user:
|
|
8360
|
+
user: z62.z.string().optional(),
|
|
8150
8361
|
/**
|
|
8151
8362
|
* Whether to use structured outputs.
|
|
8152
8363
|
*
|
|
8153
8364
|
* @default true
|
|
8154
8365
|
*/
|
|
8155
|
-
structuredOutputs:
|
|
8366
|
+
structuredOutputs: z62.z.boolean().optional()
|
|
8156
8367
|
});
|
|
8157
|
-
var groqErrorDataSchema2 =
|
|
8158
|
-
error:
|
|
8159
|
-
message:
|
|
8160
|
-
type:
|
|
8368
|
+
var groqErrorDataSchema2 = z62.z.object({
|
|
8369
|
+
error: z62.z.object({
|
|
8370
|
+
message: z62.z.string(),
|
|
8371
|
+
type: z62.z.string()
|
|
8161
8372
|
})
|
|
8162
8373
|
});
|
|
8163
8374
|
var groqFailedResponseHandler2 = createJsonErrorResponseHandler2({
|
|
8164
8375
|
errorSchema: groqErrorDataSchema2,
|
|
8165
8376
|
errorToMessage: (data) => data.error.message
|
|
8166
8377
|
});
|
|
8378
|
+
var BROWSER_SEARCH_SUPPORTED_MODELS = [
|
|
8379
|
+
"openai/gpt-oss-20b",
|
|
8380
|
+
"openai/gpt-oss-120b"
|
|
8381
|
+
];
|
|
8382
|
+
function isBrowserSearchSupportedModel(modelId) {
|
|
8383
|
+
return BROWSER_SEARCH_SUPPORTED_MODELS.includes(modelId);
|
|
8384
|
+
}
|
|
8385
|
+
function getSupportedModelsString() {
|
|
8386
|
+
return BROWSER_SEARCH_SUPPORTED_MODELS.join(", ");
|
|
8387
|
+
}
|
|
8167
8388
|
function prepareTools6({
|
|
8168
8389
|
tools,
|
|
8169
|
-
toolChoice
|
|
8390
|
+
toolChoice,
|
|
8391
|
+
modelId
|
|
8170
8392
|
}) {
|
|
8171
8393
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
8172
8394
|
const toolWarnings = [];
|
|
8173
8395
|
if (tools == null) {
|
|
8174
8396
|
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
8175
8397
|
}
|
|
8176
|
-
const
|
|
8398
|
+
const groqTools2 = [];
|
|
8177
8399
|
for (const tool2 of tools) {
|
|
8178
8400
|
if (tool2.type === "provider-defined") {
|
|
8179
|
-
|
|
8401
|
+
if (tool2.id === "groq.browser_search") {
|
|
8402
|
+
if (!isBrowserSearchSupportedModel(modelId)) {
|
|
8403
|
+
toolWarnings.push({
|
|
8404
|
+
type: "unsupported-tool",
|
|
8405
|
+
tool: tool2,
|
|
8406
|
+
details: `Browser search is only supported on the following models: ${getSupportedModelsString()}. Current model: ${modelId}`
|
|
8407
|
+
});
|
|
8408
|
+
} else {
|
|
8409
|
+
groqTools2.push({
|
|
8410
|
+
type: "browser_search"
|
|
8411
|
+
});
|
|
8412
|
+
}
|
|
8413
|
+
} else {
|
|
8414
|
+
toolWarnings.push({ type: "unsupported-tool", tool: tool2 });
|
|
8415
|
+
}
|
|
8180
8416
|
} else {
|
|
8181
|
-
|
|
8417
|
+
groqTools2.push({
|
|
8182
8418
|
type: "function",
|
|
8183
8419
|
function: {
|
|
8184
8420
|
name: tool2.name,
|
|
@@ -8189,17 +8425,17 @@ function prepareTools6({
|
|
|
8189
8425
|
}
|
|
8190
8426
|
}
|
|
8191
8427
|
if (toolChoice == null) {
|
|
8192
|
-
return { tools:
|
|
8428
|
+
return { tools: groqTools2, toolChoice: void 0, toolWarnings };
|
|
8193
8429
|
}
|
|
8194
8430
|
const type = toolChoice.type;
|
|
8195
8431
|
switch (type) {
|
|
8196
8432
|
case "auto":
|
|
8197
8433
|
case "none":
|
|
8198
8434
|
case "required":
|
|
8199
|
-
return { tools:
|
|
8435
|
+
return { tools: groqTools2, toolChoice: type, toolWarnings };
|
|
8200
8436
|
case "tool":
|
|
8201
8437
|
return {
|
|
8202
|
-
tools:
|
|
8438
|
+
tools: groqTools2,
|
|
8203
8439
|
toolChoice: {
|
|
8204
8440
|
type: "function",
|
|
8205
8441
|
function: {
|
|
@@ -8281,10 +8517,10 @@ var GroqChatLanguageModel2 = class {
|
|
|
8281
8517
|
});
|
|
8282
8518
|
}
|
|
8283
8519
|
const {
|
|
8284
|
-
tools:
|
|
8520
|
+
tools: groqTools2,
|
|
8285
8521
|
toolChoice: groqToolChoice,
|
|
8286
8522
|
toolWarnings
|
|
8287
|
-
} = prepareTools6({ tools, toolChoice });
|
|
8523
|
+
} = prepareTools6({ tools, toolChoice, modelId: this.modelId });
|
|
8288
8524
|
return {
|
|
8289
8525
|
args: {
|
|
8290
8526
|
// model id:
|
|
@@ -8311,10 +8547,11 @@ var GroqChatLanguageModel2 = class {
|
|
|
8311
8547
|
} : { type: "json_object" } : void 0,
|
|
8312
8548
|
// provider options:
|
|
8313
8549
|
reasoning_format: groqOptions == null ? void 0 : groqOptions.reasoningFormat,
|
|
8550
|
+
reasoning_effort: groqOptions == null ? void 0 : groqOptions.reasoningEffort,
|
|
8314
8551
|
// messages:
|
|
8315
8552
|
messages: convertToGroqChatMessages2(prompt),
|
|
8316
8553
|
// tools:
|
|
8317
|
-
tools:
|
|
8554
|
+
tools: groqTools2,
|
|
8318
8555
|
tool_choice: groqToolChoice
|
|
8319
8556
|
},
|
|
8320
8557
|
warnings: [...warnings, ...toolWarnings]
|
|
@@ -8590,78 +8827,78 @@ var GroqChatLanguageModel2 = class {
|
|
|
8590
8827
|
};
|
|
8591
8828
|
}
|
|
8592
8829
|
};
|
|
8593
|
-
var groqChatResponseSchema2 =
|
|
8594
|
-
id:
|
|
8595
|
-
created:
|
|
8596
|
-
model:
|
|
8597
|
-
choices:
|
|
8598
|
-
|
|
8599
|
-
message:
|
|
8600
|
-
content:
|
|
8601
|
-
reasoning:
|
|
8602
|
-
tool_calls:
|
|
8603
|
-
|
|
8604
|
-
id:
|
|
8605
|
-
type:
|
|
8606
|
-
function:
|
|
8607
|
-
name:
|
|
8608
|
-
arguments:
|
|
8830
|
+
var groqChatResponseSchema2 = z62.z.object({
|
|
8831
|
+
id: z62.z.string().nullish(),
|
|
8832
|
+
created: z62.z.number().nullish(),
|
|
8833
|
+
model: z62.z.string().nullish(),
|
|
8834
|
+
choices: z62.z.array(
|
|
8835
|
+
z62.z.object({
|
|
8836
|
+
message: z62.z.object({
|
|
8837
|
+
content: z62.z.string().nullish(),
|
|
8838
|
+
reasoning: z62.z.string().nullish(),
|
|
8839
|
+
tool_calls: z62.z.array(
|
|
8840
|
+
z62.z.object({
|
|
8841
|
+
id: z62.z.string().nullish(),
|
|
8842
|
+
type: z62.z.literal("function"),
|
|
8843
|
+
function: z62.z.object({
|
|
8844
|
+
name: z62.z.string(),
|
|
8845
|
+
arguments: z62.z.string()
|
|
8609
8846
|
})
|
|
8610
8847
|
})
|
|
8611
8848
|
).nullish()
|
|
8612
8849
|
}),
|
|
8613
|
-
index:
|
|
8614
|
-
finish_reason:
|
|
8850
|
+
index: z62.z.number(),
|
|
8851
|
+
finish_reason: z62.z.string().nullish()
|
|
8615
8852
|
})
|
|
8616
8853
|
),
|
|
8617
|
-
usage:
|
|
8618
|
-
prompt_tokens:
|
|
8619
|
-
completion_tokens:
|
|
8620
|
-
total_tokens:
|
|
8854
|
+
usage: z62.z.object({
|
|
8855
|
+
prompt_tokens: z62.z.number().nullish(),
|
|
8856
|
+
completion_tokens: z62.z.number().nullish(),
|
|
8857
|
+
total_tokens: z62.z.number().nullish()
|
|
8621
8858
|
}).nullish()
|
|
8622
8859
|
});
|
|
8623
|
-
var groqChatChunkSchema2 =
|
|
8624
|
-
|
|
8625
|
-
id:
|
|
8626
|
-
created:
|
|
8627
|
-
model:
|
|
8628
|
-
choices:
|
|
8629
|
-
|
|
8630
|
-
delta:
|
|
8631
|
-
content:
|
|
8632
|
-
reasoning:
|
|
8633
|
-
tool_calls:
|
|
8634
|
-
|
|
8635
|
-
index:
|
|
8636
|
-
id:
|
|
8637
|
-
type:
|
|
8638
|
-
function:
|
|
8639
|
-
name:
|
|
8640
|
-
arguments:
|
|
8860
|
+
var groqChatChunkSchema2 = z62.z.union([
|
|
8861
|
+
z62.z.object({
|
|
8862
|
+
id: z62.z.string().nullish(),
|
|
8863
|
+
created: z62.z.number().nullish(),
|
|
8864
|
+
model: z62.z.string().nullish(),
|
|
8865
|
+
choices: z62.z.array(
|
|
8866
|
+
z62.z.object({
|
|
8867
|
+
delta: z62.z.object({
|
|
8868
|
+
content: z62.z.string().nullish(),
|
|
8869
|
+
reasoning: z62.z.string().nullish(),
|
|
8870
|
+
tool_calls: z62.z.array(
|
|
8871
|
+
z62.z.object({
|
|
8872
|
+
index: z62.z.number(),
|
|
8873
|
+
id: z62.z.string().nullish(),
|
|
8874
|
+
type: z62.z.literal("function").optional(),
|
|
8875
|
+
function: z62.z.object({
|
|
8876
|
+
name: z62.z.string().nullish(),
|
|
8877
|
+
arguments: z62.z.string().nullish()
|
|
8641
8878
|
})
|
|
8642
8879
|
})
|
|
8643
8880
|
).nullish()
|
|
8644
8881
|
}).nullish(),
|
|
8645
|
-
finish_reason:
|
|
8646
|
-
index:
|
|
8882
|
+
finish_reason: z62.z.string().nullable().optional(),
|
|
8883
|
+
index: z62.z.number()
|
|
8647
8884
|
})
|
|
8648
8885
|
),
|
|
8649
|
-
x_groq:
|
|
8650
|
-
usage:
|
|
8651
|
-
prompt_tokens:
|
|
8652
|
-
completion_tokens:
|
|
8653
|
-
total_tokens:
|
|
8886
|
+
x_groq: z62.z.object({
|
|
8887
|
+
usage: z62.z.object({
|
|
8888
|
+
prompt_tokens: z62.z.number().nullish(),
|
|
8889
|
+
completion_tokens: z62.z.number().nullish(),
|
|
8890
|
+
total_tokens: z62.z.number().nullish()
|
|
8654
8891
|
}).nullish()
|
|
8655
8892
|
}).nullish()
|
|
8656
8893
|
}),
|
|
8657
8894
|
groqErrorDataSchema2
|
|
8658
8895
|
]);
|
|
8659
|
-
var groqProviderOptionsSchema2 =
|
|
8660
|
-
language:
|
|
8661
|
-
prompt:
|
|
8662
|
-
responseFormat:
|
|
8663
|
-
temperature:
|
|
8664
|
-
timestampGranularities:
|
|
8896
|
+
var groqProviderOptionsSchema2 = z62.z.object({
|
|
8897
|
+
language: z62.z.string().nullish(),
|
|
8898
|
+
prompt: z62.z.string().nullish(),
|
|
8899
|
+
responseFormat: z62.z.string().nullish(),
|
|
8900
|
+
temperature: z62.z.number().min(0).max(1).nullish(),
|
|
8901
|
+
timestampGranularities: z62.z.array(z62.z.string()).nullish()
|
|
8665
8902
|
});
|
|
8666
8903
|
var GroqTranscriptionModel2 = class {
|
|
8667
8904
|
constructor(modelId, config) {
|
|
@@ -8749,29 +8986,37 @@ var GroqTranscriptionModel2 = class {
|
|
|
8749
8986
|
};
|
|
8750
8987
|
}
|
|
8751
8988
|
};
|
|
8752
|
-
var groqTranscriptionResponseSchema2 =
|
|
8753
|
-
task:
|
|
8754
|
-
language:
|
|
8755
|
-
duration:
|
|
8756
|
-
text:
|
|
8757
|
-
segments:
|
|
8758
|
-
|
|
8759
|
-
id:
|
|
8760
|
-
seek:
|
|
8761
|
-
start:
|
|
8762
|
-
end:
|
|
8763
|
-
text:
|
|
8764
|
-
tokens:
|
|
8765
|
-
temperature:
|
|
8766
|
-
avg_logprob:
|
|
8767
|
-
compression_ratio:
|
|
8768
|
-
no_speech_prob:
|
|
8989
|
+
var groqTranscriptionResponseSchema2 = z62.z.object({
|
|
8990
|
+
task: z62.z.string(),
|
|
8991
|
+
language: z62.z.string(),
|
|
8992
|
+
duration: z62.z.number(),
|
|
8993
|
+
text: z62.z.string(),
|
|
8994
|
+
segments: z62.z.array(
|
|
8995
|
+
z62.z.object({
|
|
8996
|
+
id: z62.z.number(),
|
|
8997
|
+
seek: z62.z.number(),
|
|
8998
|
+
start: z62.z.number(),
|
|
8999
|
+
end: z62.z.number(),
|
|
9000
|
+
text: z62.z.string(),
|
|
9001
|
+
tokens: z62.z.array(z62.z.number()),
|
|
9002
|
+
temperature: z62.z.number(),
|
|
9003
|
+
avg_logprob: z62.z.number(),
|
|
9004
|
+
compression_ratio: z62.z.number(),
|
|
9005
|
+
no_speech_prob: z62.z.number()
|
|
8769
9006
|
})
|
|
8770
9007
|
),
|
|
8771
|
-
x_groq:
|
|
8772
|
-
id:
|
|
9008
|
+
x_groq: z62.z.object({
|
|
9009
|
+
id: z62.z.string()
|
|
8773
9010
|
})
|
|
8774
9011
|
});
|
|
9012
|
+
var browserSearch = createProviderDefinedToolFactory({
|
|
9013
|
+
id: "groq.browser_search",
|
|
9014
|
+
name: "browser_search",
|
|
9015
|
+
inputSchema: z62.z.object({})
|
|
9016
|
+
});
|
|
9017
|
+
var groqTools = {
|
|
9018
|
+
browserSearch
|
|
9019
|
+
};
|
|
8775
9020
|
function createGroq2(options = {}) {
|
|
8776
9021
|
var _a16;
|
|
8777
9022
|
const baseURL = (_a16 = withoutTrailingSlash2(options.baseURL)) != null ? _a16 : "https://api.groq.com/openai/v1";
|
|
@@ -8817,6 +9062,7 @@ function createGroq2(options = {}) {
|
|
|
8817
9062
|
throw new NoSuchModelError2({ modelId, modelType: "imageModel" });
|
|
8818
9063
|
};
|
|
8819
9064
|
provider.transcription = createTranscriptionModel;
|
|
9065
|
+
provider.tools = groqTools;
|
|
8820
9066
|
return provider;
|
|
8821
9067
|
}
|
|
8822
9068
|
var groq2 = createGroq2();
|
|
@@ -11587,6 +11833,21 @@ var openai = createOpenAI({
|
|
|
11587
11833
|
compatibility: "strict"
|
|
11588
11834
|
// strict for OpenAI API
|
|
11589
11835
|
});
|
|
11836
|
+
var openaiErrorDataSchema2 = z62.z.object({
|
|
11837
|
+
error: z62.z.object({
|
|
11838
|
+
message: z62.z.string(),
|
|
11839
|
+
// The additional information below is handled loosely to support
|
|
11840
|
+
// OpenAI-compatible providers that have slightly different error
|
|
11841
|
+
// responses:
|
|
11842
|
+
type: z62.z.string().nullish(),
|
|
11843
|
+
param: z62.z.any().nullish(),
|
|
11844
|
+
code: z62.z.union([z62.z.string(), z62.z.number()]).nullish()
|
|
11845
|
+
})
|
|
11846
|
+
});
|
|
11847
|
+
var openaiFailedResponseHandler2 = createJsonErrorResponseHandler2({
|
|
11848
|
+
errorSchema: openaiErrorDataSchema2,
|
|
11849
|
+
errorToMessage: (data) => data.error.message
|
|
11850
|
+
});
|
|
11590
11851
|
function convertToOpenAIChatMessages2({
|
|
11591
11852
|
prompt,
|
|
11592
11853
|
systemMessageMode = "system"
|
|
@@ -11685,7 +11946,7 @@ function convertToOpenAIChatMessages2({
|
|
|
11685
11946
|
}
|
|
11686
11947
|
return {
|
|
11687
11948
|
type: "file",
|
|
11688
|
-
file: {
|
|
11949
|
+
file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
|
|
11689
11950
|
filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
|
|
11690
11951
|
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
11691
11952
|
}
|
|
@@ -11787,14 +12048,14 @@ function mapOpenAIFinishReason2(finishReason) {
|
|
|
11787
12048
|
return "unknown";
|
|
11788
12049
|
}
|
|
11789
12050
|
}
|
|
11790
|
-
var openaiProviderOptions =
|
|
12051
|
+
var openaiProviderOptions = z62.z.object({
|
|
11791
12052
|
/**
|
|
11792
12053
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
11793
12054
|
*
|
|
11794
12055
|
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
11795
12056
|
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
11796
12057
|
*/
|
|
11797
|
-
logitBias:
|
|
12058
|
+
logitBias: z62.z.record(z62.z.coerce.number(), z62.z.number()).optional(),
|
|
11798
12059
|
/**
|
|
11799
12060
|
* Return the log probabilities of the tokens.
|
|
11800
12061
|
*
|
|
@@ -11804,42 +12065,42 @@ var openaiProviderOptions = z52.z.object({
|
|
|
11804
12065
|
* Setting to a number will return the log probabilities of the top n
|
|
11805
12066
|
* tokens that were generated.
|
|
11806
12067
|
*/
|
|
11807
|
-
logprobs:
|
|
12068
|
+
logprobs: z62.z.union([z62.z.boolean(), z62.z.number()]).optional(),
|
|
11808
12069
|
/**
|
|
11809
12070
|
* Whether to enable parallel function calling during tool use. Default to true.
|
|
11810
12071
|
*/
|
|
11811
|
-
parallelToolCalls:
|
|
12072
|
+
parallelToolCalls: z62.z.boolean().optional(),
|
|
11812
12073
|
/**
|
|
11813
12074
|
* A unique identifier representing your end-user, which can help OpenAI to
|
|
11814
12075
|
* monitor and detect abuse.
|
|
11815
12076
|
*/
|
|
11816
|
-
user:
|
|
12077
|
+
user: z62.z.string().optional(),
|
|
11817
12078
|
/**
|
|
11818
12079
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
11819
12080
|
*/
|
|
11820
|
-
reasoningEffort:
|
|
12081
|
+
reasoningEffort: z62.z.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
11821
12082
|
/**
|
|
11822
12083
|
* Maximum number of completion tokens to generate. Useful for reasoning models.
|
|
11823
12084
|
*/
|
|
11824
|
-
maxCompletionTokens:
|
|
12085
|
+
maxCompletionTokens: z62.z.number().optional(),
|
|
11825
12086
|
/**
|
|
11826
12087
|
* Whether to enable persistence in responses API.
|
|
11827
12088
|
*/
|
|
11828
|
-
store:
|
|
12089
|
+
store: z62.z.boolean().optional(),
|
|
11829
12090
|
/**
|
|
11830
12091
|
* Metadata to associate with the request.
|
|
11831
12092
|
*/
|
|
11832
|
-
metadata:
|
|
12093
|
+
metadata: z62.z.record(z62.z.string().max(64), z62.z.string().max(512)).optional(),
|
|
11833
12094
|
/**
|
|
11834
12095
|
* Parameters for prediction mode.
|
|
11835
12096
|
*/
|
|
11836
|
-
prediction:
|
|
12097
|
+
prediction: z62.z.record(z62.z.string(), z62.z.any()).optional(),
|
|
11837
12098
|
/**
|
|
11838
12099
|
* Whether to use structured outputs.
|
|
11839
12100
|
*
|
|
11840
12101
|
* @default true
|
|
11841
12102
|
*/
|
|
11842
|
-
structuredOutputs:
|
|
12103
|
+
structuredOutputs: z62.z.boolean().optional(),
|
|
11843
12104
|
/**
|
|
11844
12105
|
* Service tier for the request.
|
|
11845
12106
|
* - 'auto': Default service tier
|
|
@@ -11848,55 +12109,58 @@ var openaiProviderOptions = z52.z.object({
|
|
|
11848
12109
|
*
|
|
11849
12110
|
* @default 'auto'
|
|
11850
12111
|
*/
|
|
11851
|
-
serviceTier:
|
|
12112
|
+
serviceTier: z62.z.enum(["auto", "flex", "priority"]).optional(),
|
|
11852
12113
|
/**
|
|
11853
12114
|
* Whether to use strict JSON schema validation.
|
|
11854
12115
|
*
|
|
11855
12116
|
* @default false
|
|
11856
12117
|
*/
|
|
11857
|
-
strictJsonSchema:
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
12118
|
+
strictJsonSchema: z62.z.boolean().optional(),
|
|
12119
|
+
/**
|
|
12120
|
+
* Controls the verbosity of the model's responses.
|
|
12121
|
+
* Lower values will result in more concise responses, while higher values will result in more verbose responses.
|
|
12122
|
+
*/
|
|
12123
|
+
textVerbosity: z62.z.enum(["low", "medium", "high"]).optional(),
|
|
12124
|
+
/**
|
|
12125
|
+
* A cache key for prompt caching. Allows manual control over prompt caching behavior.
|
|
12126
|
+
* Useful for improving cache hit rates and working around automatic caching issues.
|
|
12127
|
+
*/
|
|
12128
|
+
promptCacheKey: z62.z.string().optional(),
|
|
12129
|
+
/**
|
|
12130
|
+
* A stable identifier used to help detect users of your application
|
|
12131
|
+
* that may be violating OpenAI's usage policies. The IDs should be a
|
|
12132
|
+
* string that uniquely identifies each user. We recommend hashing their
|
|
12133
|
+
* username or email address, in order to avoid sending us any identifying
|
|
12134
|
+
* information.
|
|
12135
|
+
*/
|
|
12136
|
+
safetyIdentifier: z62.z.string().optional()
|
|
11873
12137
|
});
|
|
11874
|
-
var comparisonFilterSchema =
|
|
11875
|
-
key:
|
|
11876
|
-
type:
|
|
11877
|
-
value:
|
|
12138
|
+
var comparisonFilterSchema = z62.z.object({
|
|
12139
|
+
key: z62.z.string(),
|
|
12140
|
+
type: z62.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
12141
|
+
value: z62.z.union([z62.z.string(), z62.z.number(), z62.z.boolean()])
|
|
11878
12142
|
});
|
|
11879
|
-
var compoundFilterSchema =
|
|
11880
|
-
type:
|
|
11881
|
-
filters:
|
|
11882
|
-
|
|
12143
|
+
var compoundFilterSchema = z62.z.object({
|
|
12144
|
+
type: z62.z.enum(["and", "or"]),
|
|
12145
|
+
filters: z62.z.array(
|
|
12146
|
+
z62.z.union([comparisonFilterSchema, z62.z.lazy(() => compoundFilterSchema)])
|
|
11883
12147
|
)
|
|
11884
12148
|
});
|
|
11885
|
-
var filtersSchema =
|
|
11886
|
-
var fileSearchArgsSchema =
|
|
12149
|
+
var filtersSchema = z62.z.union([comparisonFilterSchema, compoundFilterSchema]);
|
|
12150
|
+
var fileSearchArgsSchema = z62.z.object({
|
|
11887
12151
|
/**
|
|
11888
12152
|
* List of vector store IDs to search through. If not provided, searches all available vector stores.
|
|
11889
12153
|
*/
|
|
11890
|
-
vectorStoreIds:
|
|
12154
|
+
vectorStoreIds: z62.z.array(z62.z.string()).optional(),
|
|
11891
12155
|
/**
|
|
11892
12156
|
* Maximum number of search results to return. Defaults to 10.
|
|
11893
12157
|
*/
|
|
11894
|
-
maxNumResults:
|
|
12158
|
+
maxNumResults: z62.z.number().optional(),
|
|
11895
12159
|
/**
|
|
11896
12160
|
* Ranking options for the search.
|
|
11897
12161
|
*/
|
|
11898
|
-
ranking:
|
|
11899
|
-
ranker:
|
|
12162
|
+
ranking: z62.z.object({
|
|
12163
|
+
ranker: z62.z.enum(["auto", "default-2024-08-21"]).optional()
|
|
11900
12164
|
}).optional(),
|
|
11901
12165
|
/**
|
|
11902
12166
|
* A filter to apply based on file attributes.
|
|
@@ -11906,50 +12170,50 @@ var fileSearchArgsSchema = z52.z.object({
|
|
|
11906
12170
|
var fileSearch = createProviderDefinedToolFactory({
|
|
11907
12171
|
id: "openai.file_search",
|
|
11908
12172
|
name: "file_search",
|
|
11909
|
-
inputSchema:
|
|
11910
|
-
query:
|
|
12173
|
+
inputSchema: z62.z.object({
|
|
12174
|
+
query: z62.z.string()
|
|
11911
12175
|
})
|
|
11912
12176
|
});
|
|
11913
|
-
var webSearchPreviewArgsSchema =
|
|
12177
|
+
var webSearchPreviewArgsSchema = z62.z.object({
|
|
11914
12178
|
/**
|
|
11915
12179
|
* Search context size to use for the web search.
|
|
11916
12180
|
* - high: Most comprehensive context, highest cost, slower response
|
|
11917
12181
|
* - medium: Balanced context, cost, and latency (default)
|
|
11918
12182
|
* - low: Least context, lowest cost, fastest response
|
|
11919
12183
|
*/
|
|
11920
|
-
searchContextSize:
|
|
12184
|
+
searchContextSize: z62.z.enum(["low", "medium", "high"]).optional(),
|
|
11921
12185
|
/**
|
|
11922
12186
|
* User location information to provide geographically relevant search results.
|
|
11923
12187
|
*/
|
|
11924
|
-
userLocation:
|
|
12188
|
+
userLocation: z62.z.object({
|
|
11925
12189
|
/**
|
|
11926
12190
|
* Type of location (always 'approximate')
|
|
11927
12191
|
*/
|
|
11928
|
-
type:
|
|
12192
|
+
type: z62.z.literal("approximate"),
|
|
11929
12193
|
/**
|
|
11930
12194
|
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
11931
12195
|
*/
|
|
11932
|
-
country:
|
|
12196
|
+
country: z62.z.string().optional(),
|
|
11933
12197
|
/**
|
|
11934
12198
|
* City name (free text, e.g., 'Minneapolis')
|
|
11935
12199
|
*/
|
|
11936
|
-
city:
|
|
12200
|
+
city: z62.z.string().optional(),
|
|
11937
12201
|
/**
|
|
11938
12202
|
* Region name (free text, e.g., 'Minnesota')
|
|
11939
12203
|
*/
|
|
11940
|
-
region:
|
|
12204
|
+
region: z62.z.string().optional(),
|
|
11941
12205
|
/**
|
|
11942
12206
|
* IANA timezone (e.g., 'America/Chicago')
|
|
11943
12207
|
*/
|
|
11944
|
-
timezone:
|
|
12208
|
+
timezone: z62.z.string().optional()
|
|
11945
12209
|
}).optional()
|
|
11946
12210
|
});
|
|
11947
12211
|
var webSearchPreview = createProviderDefinedToolFactory({
|
|
11948
12212
|
id: "openai.web_search_preview",
|
|
11949
12213
|
name: "web_search_preview",
|
|
11950
|
-
inputSchema:
|
|
12214
|
+
inputSchema: z62.z.object({})
|
|
11951
12215
|
});
|
|
11952
|
-
function
|
|
12216
|
+
function prepareChatTools({
|
|
11953
12217
|
tools,
|
|
11954
12218
|
toolChoice,
|
|
11955
12219
|
structuredOutputs,
|
|
@@ -12116,14 +12380,17 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12116
12380
|
} : { type: "json_object" } : void 0,
|
|
12117
12381
|
stop: stopSequences,
|
|
12118
12382
|
seed,
|
|
12383
|
+
verbosity: openaiOptions.textVerbosity,
|
|
12119
12384
|
// openai specific settings:
|
|
12120
|
-
// TODO
|
|
12385
|
+
// TODO AI SDK 6: remove, we auto-map maxOutputTokens now
|
|
12121
12386
|
max_completion_tokens: openaiOptions.maxCompletionTokens,
|
|
12122
12387
|
store: openaiOptions.store,
|
|
12123
12388
|
metadata: openaiOptions.metadata,
|
|
12124
12389
|
prediction: openaiOptions.prediction,
|
|
12125
12390
|
reasoning_effort: openaiOptions.reasoningEffort,
|
|
12126
12391
|
service_tier: openaiOptions.serviceTier,
|
|
12392
|
+
prompt_cache_key: openaiOptions.promptCacheKey,
|
|
12393
|
+
safety_identifier: openaiOptions.safetyIdentifier,
|
|
12127
12394
|
// messages:
|
|
12128
12395
|
messages
|
|
12129
12396
|
};
|
|
@@ -12201,7 +12468,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12201
12468
|
warnings.push({
|
|
12202
12469
|
type: "unsupported-setting",
|
|
12203
12470
|
setting: "serviceTier",
|
|
12204
|
-
details: "flex processing is only available for o3
|
|
12471
|
+
details: "flex processing is only available for o3, o4-mini, and gpt-5 models"
|
|
12205
12472
|
});
|
|
12206
12473
|
baseArgs.service_tier = void 0;
|
|
12207
12474
|
}
|
|
@@ -12209,7 +12476,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12209
12476
|
warnings.push({
|
|
12210
12477
|
type: "unsupported-setting",
|
|
12211
12478
|
setting: "serviceTier",
|
|
12212
|
-
details: "priority processing is only available for supported models (
|
|
12479
|
+
details: "priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"
|
|
12213
12480
|
});
|
|
12214
12481
|
baseArgs.service_tier = void 0;
|
|
12215
12482
|
}
|
|
@@ -12217,7 +12484,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12217
12484
|
tools: openaiTools22,
|
|
12218
12485
|
toolChoice: openaiToolChoice,
|
|
12219
12486
|
toolWarnings
|
|
12220
|
-
} =
|
|
12487
|
+
} = prepareChatTools({
|
|
12221
12488
|
tools,
|
|
12222
12489
|
toolChoice,
|
|
12223
12490
|
structuredOutputs,
|
|
@@ -12233,7 +12500,7 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12233
12500
|
};
|
|
12234
12501
|
}
|
|
12235
12502
|
async doGenerate(options) {
|
|
12236
|
-
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
12503
|
+
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
12237
12504
|
const { args: body, warnings } = await this.getArgs(options);
|
|
12238
12505
|
const {
|
|
12239
12506
|
responseHeaders,
|
|
@@ -12267,8 +12534,17 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12267
12534
|
input: toolCall.function.arguments
|
|
12268
12535
|
});
|
|
12269
12536
|
}
|
|
12270
|
-
const
|
|
12271
|
-
|
|
12537
|
+
for (const annotation of (_c = choice.message.annotations) != null ? _c : []) {
|
|
12538
|
+
content.push({
|
|
12539
|
+
type: "source",
|
|
12540
|
+
sourceType: "url",
|
|
12541
|
+
id: generateId2(),
|
|
12542
|
+
url: annotation.url,
|
|
12543
|
+
title: annotation.title
|
|
12544
|
+
});
|
|
12545
|
+
}
|
|
12546
|
+
const completionTokenDetails = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
|
|
12547
|
+
const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
|
|
12272
12548
|
const providerMetadata = { openai: {} };
|
|
12273
12549
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
12274
12550
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -12276,18 +12552,18 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12276
12552
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
12277
12553
|
providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
12278
12554
|
}
|
|
12279
|
-
if (((
|
|
12555
|
+
if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
|
|
12280
12556
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
12281
12557
|
}
|
|
12282
12558
|
return {
|
|
12283
12559
|
content,
|
|
12284
12560
|
finishReason: mapOpenAIFinishReason2(choice.finish_reason),
|
|
12285
12561
|
usage: {
|
|
12286
|
-
inputTokens: (
|
|
12287
|
-
outputTokens: (
|
|
12288
|
-
totalTokens: (
|
|
12289
|
-
reasoningTokens: (
|
|
12290
|
-
cachedInputTokens: (
|
|
12562
|
+
inputTokens: (_h = (_g = response.usage) == null ? void 0 : _g.prompt_tokens) != null ? _h : void 0,
|
|
12563
|
+
outputTokens: (_j = (_i = response.usage) == null ? void 0 : _i.completion_tokens) != null ? _j : void 0,
|
|
12564
|
+
totalTokens: (_l = (_k = response.usage) == null ? void 0 : _k.total_tokens) != null ? _l : void 0,
|
|
12565
|
+
reasoningTokens: (_m = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _m : void 0,
|
|
12566
|
+
cachedInputTokens: (_n = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _n : void 0
|
|
12291
12567
|
},
|
|
12292
12568
|
request: { body },
|
|
12293
12569
|
response: {
|
|
@@ -12484,6 +12760,17 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12484
12760
|
}
|
|
12485
12761
|
}
|
|
12486
12762
|
}
|
|
12763
|
+
if (delta.annotations != null) {
|
|
12764
|
+
for (const annotation of delta.annotations) {
|
|
12765
|
+
controller.enqueue({
|
|
12766
|
+
type: "source",
|
|
12767
|
+
sourceType: "url",
|
|
12768
|
+
id: generateId2(),
|
|
12769
|
+
url: annotation.url,
|
|
12770
|
+
title: annotation.title
|
|
12771
|
+
});
|
|
12772
|
+
}
|
|
12773
|
+
}
|
|
12487
12774
|
},
|
|
12488
12775
|
flush(controller) {
|
|
12489
12776
|
if (isActiveText) {
|
|
@@ -12503,97 +12790,115 @@ var OpenAIChatLanguageModel2 = class {
|
|
|
12503
12790
|
};
|
|
12504
12791
|
}
|
|
12505
12792
|
};
|
|
12506
|
-
var openaiTokenUsageSchema2 =
|
|
12507
|
-
prompt_tokens:
|
|
12508
|
-
completion_tokens:
|
|
12509
|
-
total_tokens:
|
|
12510
|
-
prompt_tokens_details:
|
|
12511
|
-
cached_tokens:
|
|
12793
|
+
var openaiTokenUsageSchema2 = z62.z.object({
|
|
12794
|
+
prompt_tokens: z62.z.number().nullish(),
|
|
12795
|
+
completion_tokens: z62.z.number().nullish(),
|
|
12796
|
+
total_tokens: z62.z.number().nullish(),
|
|
12797
|
+
prompt_tokens_details: z62.z.object({
|
|
12798
|
+
cached_tokens: z62.z.number().nullish()
|
|
12512
12799
|
}).nullish(),
|
|
12513
|
-
completion_tokens_details:
|
|
12514
|
-
reasoning_tokens:
|
|
12515
|
-
accepted_prediction_tokens:
|
|
12516
|
-
rejected_prediction_tokens:
|
|
12800
|
+
completion_tokens_details: z62.z.object({
|
|
12801
|
+
reasoning_tokens: z62.z.number().nullish(),
|
|
12802
|
+
accepted_prediction_tokens: z62.z.number().nullish(),
|
|
12803
|
+
rejected_prediction_tokens: z62.z.number().nullish()
|
|
12517
12804
|
}).nullish()
|
|
12518
12805
|
}).nullish();
|
|
12519
|
-
var openaiChatResponseSchema2 =
|
|
12520
|
-
id:
|
|
12521
|
-
created:
|
|
12522
|
-
model:
|
|
12523
|
-
choices:
|
|
12524
|
-
|
|
12525
|
-
message:
|
|
12526
|
-
role:
|
|
12527
|
-
content:
|
|
12528
|
-
tool_calls:
|
|
12529
|
-
|
|
12530
|
-
id:
|
|
12531
|
-
type:
|
|
12532
|
-
function:
|
|
12533
|
-
name:
|
|
12534
|
-
arguments:
|
|
12806
|
+
var openaiChatResponseSchema2 = z62.z.object({
|
|
12807
|
+
id: z62.z.string().nullish(),
|
|
12808
|
+
created: z62.z.number().nullish(),
|
|
12809
|
+
model: z62.z.string().nullish(),
|
|
12810
|
+
choices: z62.z.array(
|
|
12811
|
+
z62.z.object({
|
|
12812
|
+
message: z62.z.object({
|
|
12813
|
+
role: z62.z.literal("assistant").nullish(),
|
|
12814
|
+
content: z62.z.string().nullish(),
|
|
12815
|
+
tool_calls: z62.z.array(
|
|
12816
|
+
z62.z.object({
|
|
12817
|
+
id: z62.z.string().nullish(),
|
|
12818
|
+
type: z62.z.literal("function"),
|
|
12819
|
+
function: z62.z.object({
|
|
12820
|
+
name: z62.z.string(),
|
|
12821
|
+
arguments: z62.z.string()
|
|
12535
12822
|
})
|
|
12536
12823
|
})
|
|
12824
|
+
).nullish(),
|
|
12825
|
+
annotations: z62.z.array(
|
|
12826
|
+
z62.z.object({
|
|
12827
|
+
type: z62.z.literal("url_citation"),
|
|
12828
|
+
start_index: z62.z.number(),
|
|
12829
|
+
end_index: z62.z.number(),
|
|
12830
|
+
url: z62.z.string(),
|
|
12831
|
+
title: z62.z.string()
|
|
12832
|
+
})
|
|
12537
12833
|
).nullish()
|
|
12538
12834
|
}),
|
|
12539
|
-
index:
|
|
12540
|
-
logprobs:
|
|
12541
|
-
content:
|
|
12542
|
-
|
|
12543
|
-
token:
|
|
12544
|
-
logprob:
|
|
12545
|
-
top_logprobs:
|
|
12546
|
-
|
|
12547
|
-
token:
|
|
12548
|
-
logprob:
|
|
12835
|
+
index: z62.z.number(),
|
|
12836
|
+
logprobs: z62.z.object({
|
|
12837
|
+
content: z62.z.array(
|
|
12838
|
+
z62.z.object({
|
|
12839
|
+
token: z62.z.string(),
|
|
12840
|
+
logprob: z62.z.number(),
|
|
12841
|
+
top_logprobs: z62.z.array(
|
|
12842
|
+
z62.z.object({
|
|
12843
|
+
token: z62.z.string(),
|
|
12844
|
+
logprob: z62.z.number()
|
|
12549
12845
|
})
|
|
12550
12846
|
)
|
|
12551
12847
|
})
|
|
12552
12848
|
).nullish()
|
|
12553
12849
|
}).nullish(),
|
|
12554
|
-
finish_reason:
|
|
12850
|
+
finish_reason: z62.z.string().nullish()
|
|
12555
12851
|
})
|
|
12556
12852
|
),
|
|
12557
12853
|
usage: openaiTokenUsageSchema2
|
|
12558
12854
|
});
|
|
12559
|
-
var openaiChatChunkSchema2 =
|
|
12560
|
-
|
|
12561
|
-
id:
|
|
12562
|
-
created:
|
|
12563
|
-
model:
|
|
12564
|
-
choices:
|
|
12565
|
-
|
|
12566
|
-
delta:
|
|
12567
|
-
role:
|
|
12568
|
-
content:
|
|
12569
|
-
tool_calls:
|
|
12570
|
-
|
|
12571
|
-
index:
|
|
12572
|
-
id:
|
|
12573
|
-
type:
|
|
12574
|
-
function:
|
|
12575
|
-
name:
|
|
12576
|
-
arguments:
|
|
12855
|
+
var openaiChatChunkSchema2 = z62.z.union([
|
|
12856
|
+
z62.z.object({
|
|
12857
|
+
id: z62.z.string().nullish(),
|
|
12858
|
+
created: z62.z.number().nullish(),
|
|
12859
|
+
model: z62.z.string().nullish(),
|
|
12860
|
+
choices: z62.z.array(
|
|
12861
|
+
z62.z.object({
|
|
12862
|
+
delta: z62.z.object({
|
|
12863
|
+
role: z62.z.enum(["assistant"]).nullish(),
|
|
12864
|
+
content: z62.z.string().nullish(),
|
|
12865
|
+
tool_calls: z62.z.array(
|
|
12866
|
+
z62.z.object({
|
|
12867
|
+
index: z62.z.number(),
|
|
12868
|
+
id: z62.z.string().nullish(),
|
|
12869
|
+
type: z62.z.literal("function").nullish(),
|
|
12870
|
+
function: z62.z.object({
|
|
12871
|
+
name: z62.z.string().nullish(),
|
|
12872
|
+
arguments: z62.z.string().nullish()
|
|
12577
12873
|
})
|
|
12578
12874
|
})
|
|
12875
|
+
).nullish(),
|
|
12876
|
+
annotations: z62.z.array(
|
|
12877
|
+
z62.z.object({
|
|
12878
|
+
type: z62.z.literal("url_citation"),
|
|
12879
|
+
start_index: z62.z.number(),
|
|
12880
|
+
end_index: z62.z.number(),
|
|
12881
|
+
url: z62.z.string(),
|
|
12882
|
+
title: z62.z.string()
|
|
12883
|
+
})
|
|
12579
12884
|
).nullish()
|
|
12580
12885
|
}).nullish(),
|
|
12581
|
-
logprobs:
|
|
12582
|
-
content:
|
|
12583
|
-
|
|
12584
|
-
token:
|
|
12585
|
-
logprob:
|
|
12586
|
-
top_logprobs:
|
|
12587
|
-
|
|
12588
|
-
token:
|
|
12589
|
-
logprob:
|
|
12886
|
+
logprobs: z62.z.object({
|
|
12887
|
+
content: z62.z.array(
|
|
12888
|
+
z62.z.object({
|
|
12889
|
+
token: z62.z.string(),
|
|
12890
|
+
logprob: z62.z.number(),
|
|
12891
|
+
top_logprobs: z62.z.array(
|
|
12892
|
+
z62.z.object({
|
|
12893
|
+
token: z62.z.string(),
|
|
12894
|
+
logprob: z62.z.number()
|
|
12590
12895
|
})
|
|
12591
12896
|
)
|
|
12592
12897
|
})
|
|
12593
12898
|
).nullish()
|
|
12594
12899
|
}).nullish(),
|
|
12595
|
-
finish_reason:
|
|
12596
|
-
index:
|
|
12900
|
+
finish_reason: z62.z.string().nullish(),
|
|
12901
|
+
index: z62.z.number()
|
|
12597
12902
|
})
|
|
12598
12903
|
),
|
|
12599
12904
|
usage: openaiTokenUsageSchema2
|
|
@@ -12601,13 +12906,13 @@ var openaiChatChunkSchema2 = z52.z.union([
|
|
|
12601
12906
|
openaiErrorDataSchema2
|
|
12602
12907
|
]);
|
|
12603
12908
|
function isReasoningModel2(modelId) {
|
|
12604
|
-
return modelId.startsWith("o");
|
|
12909
|
+
return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
|
|
12605
12910
|
}
|
|
12606
12911
|
function supportsFlexProcessing(modelId) {
|
|
12607
|
-
return modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
12912
|
+
return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
12608
12913
|
}
|
|
12609
12914
|
function supportsPriorityProcessing(modelId) {
|
|
12610
|
-
return modelId.startsWith("gpt-4") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
12915
|
+
return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
12611
12916
|
}
|
|
12612
12917
|
function getSystemMessageMode2(modelId) {
|
|
12613
12918
|
var _a16, _b;
|
|
@@ -12720,11 +13025,37 @@ ${assistantMessage}
|
|
|
12720
13025
|
${user}:`]
|
|
12721
13026
|
};
|
|
12722
13027
|
}
|
|
12723
|
-
|
|
13028
|
+
function getResponseMetadata22({
|
|
13029
|
+
id,
|
|
13030
|
+
model,
|
|
13031
|
+
created
|
|
13032
|
+
}) {
|
|
13033
|
+
return {
|
|
13034
|
+
id: id != null ? id : void 0,
|
|
13035
|
+
modelId: model != null ? model : void 0,
|
|
13036
|
+
timestamp: created != null ? new Date(created * 1e3) : void 0
|
|
13037
|
+
};
|
|
13038
|
+
}
|
|
13039
|
+
function mapOpenAIFinishReason22(finishReason) {
|
|
13040
|
+
switch (finishReason) {
|
|
13041
|
+
case "stop":
|
|
13042
|
+
return "stop";
|
|
13043
|
+
case "length":
|
|
13044
|
+
return "length";
|
|
13045
|
+
case "content_filter":
|
|
13046
|
+
return "content-filter";
|
|
13047
|
+
case "function_call":
|
|
13048
|
+
case "tool_calls":
|
|
13049
|
+
return "tool-calls";
|
|
13050
|
+
default:
|
|
13051
|
+
return "unknown";
|
|
13052
|
+
}
|
|
13053
|
+
}
|
|
13054
|
+
var openaiCompletionProviderOptions = z62.z.object({
|
|
12724
13055
|
/**
|
|
12725
13056
|
Echo back the prompt in addition to the completion.
|
|
12726
13057
|
*/
|
|
12727
|
-
echo:
|
|
13058
|
+
echo: z62.z.boolean().optional(),
|
|
12728
13059
|
/**
|
|
12729
13060
|
Modify the likelihood of specified tokens appearing in the completion.
|
|
12730
13061
|
|
|
@@ -12739,16 +13070,16 @@ var openaiCompletionProviderOptions = z52.z.object({
|
|
|
12739
13070
|
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
12740
13071
|
token from being generated.
|
|
12741
13072
|
*/
|
|
12742
|
-
logitBias:
|
|
13073
|
+
logitBias: z62.z.record(z62.z.string(), z62.z.number()).optional(),
|
|
12743
13074
|
/**
|
|
12744
13075
|
The suffix that comes after a completion of inserted text.
|
|
12745
13076
|
*/
|
|
12746
|
-
suffix:
|
|
13077
|
+
suffix: z62.z.string().optional(),
|
|
12747
13078
|
/**
|
|
12748
13079
|
A unique identifier representing your end-user, which can help OpenAI to
|
|
12749
13080
|
monitor and detect abuse. Learn more.
|
|
12750
13081
|
*/
|
|
12751
|
-
user:
|
|
13082
|
+
user: z62.z.string().optional(),
|
|
12752
13083
|
/**
|
|
12753
13084
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
12754
13085
|
the response size and can slow down response times. However, it can
|
|
@@ -12758,7 +13089,7 @@ var openaiCompletionProviderOptions = z52.z.object({
|
|
|
12758
13089
|
Setting to a number will return the log probabilities of the top n
|
|
12759
13090
|
tokens that were generated.
|
|
12760
13091
|
*/
|
|
12761
|
-
logprobs:
|
|
13092
|
+
logprobs: z62.z.union([z62.z.boolean(), z62.z.number()]).optional()
|
|
12762
13093
|
});
|
|
12763
13094
|
var OpenAICompletionLanguageModel2 = class {
|
|
12764
13095
|
constructor(modelId, config) {
|
|
@@ -12879,10 +13210,10 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
12879
13210
|
outputTokens: (_b = response.usage) == null ? void 0 : _b.completion_tokens,
|
|
12880
13211
|
totalTokens: (_c = response.usage) == null ? void 0 : _c.total_tokens
|
|
12881
13212
|
},
|
|
12882
|
-
finishReason:
|
|
13213
|
+
finishReason: mapOpenAIFinishReason22(choice.finish_reason),
|
|
12883
13214
|
request: { body: args },
|
|
12884
13215
|
response: {
|
|
12885
|
-
...
|
|
13216
|
+
...getResponseMetadata22(response),
|
|
12886
13217
|
headers: responseHeaders,
|
|
12887
13218
|
body: rawResponse
|
|
12888
13219
|
},
|
|
@@ -12946,7 +13277,7 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
12946
13277
|
isFirstChunk = false;
|
|
12947
13278
|
controller.enqueue({
|
|
12948
13279
|
type: "response-metadata",
|
|
12949
|
-
...
|
|
13280
|
+
...getResponseMetadata22(value)
|
|
12950
13281
|
});
|
|
12951
13282
|
controller.enqueue({ type: "text-start", id: "0" });
|
|
12952
13283
|
}
|
|
@@ -12957,7 +13288,7 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
12957
13288
|
}
|
|
12958
13289
|
const choice = value.choices[0];
|
|
12959
13290
|
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
12960
|
-
finishReason =
|
|
13291
|
+
finishReason = mapOpenAIFinishReason22(choice.finish_reason);
|
|
12961
13292
|
}
|
|
12962
13293
|
if ((choice == null ? void 0 : choice.logprobs) != null) {
|
|
12963
13294
|
providerMetadata.openai.logprobs = choice.logprobs;
|
|
@@ -12988,42 +13319,42 @@ var OpenAICompletionLanguageModel2 = class {
|
|
|
12988
13319
|
};
|
|
12989
13320
|
}
|
|
12990
13321
|
};
|
|
12991
|
-
var usageSchema3 =
|
|
12992
|
-
prompt_tokens:
|
|
12993
|
-
completion_tokens:
|
|
12994
|
-
total_tokens:
|
|
13322
|
+
var usageSchema3 = z62.z.object({
|
|
13323
|
+
prompt_tokens: z62.z.number(),
|
|
13324
|
+
completion_tokens: z62.z.number(),
|
|
13325
|
+
total_tokens: z62.z.number()
|
|
12995
13326
|
});
|
|
12996
|
-
var openaiCompletionResponseSchema2 =
|
|
12997
|
-
id:
|
|
12998
|
-
created:
|
|
12999
|
-
model:
|
|
13000
|
-
choices:
|
|
13001
|
-
|
|
13002
|
-
text:
|
|
13003
|
-
finish_reason:
|
|
13004
|
-
logprobs:
|
|
13005
|
-
tokens:
|
|
13006
|
-
token_logprobs:
|
|
13007
|
-
top_logprobs:
|
|
13327
|
+
var openaiCompletionResponseSchema2 = z62.z.object({
|
|
13328
|
+
id: z62.z.string().nullish(),
|
|
13329
|
+
created: z62.z.number().nullish(),
|
|
13330
|
+
model: z62.z.string().nullish(),
|
|
13331
|
+
choices: z62.z.array(
|
|
13332
|
+
z62.z.object({
|
|
13333
|
+
text: z62.z.string(),
|
|
13334
|
+
finish_reason: z62.z.string(),
|
|
13335
|
+
logprobs: z62.z.object({
|
|
13336
|
+
tokens: z62.z.array(z62.z.string()),
|
|
13337
|
+
token_logprobs: z62.z.array(z62.z.number()),
|
|
13338
|
+
top_logprobs: z62.z.array(z62.z.record(z62.z.string(), z62.z.number())).nullish()
|
|
13008
13339
|
}).nullish()
|
|
13009
13340
|
})
|
|
13010
13341
|
),
|
|
13011
13342
|
usage: usageSchema3.nullish()
|
|
13012
13343
|
});
|
|
13013
|
-
var openaiCompletionChunkSchema2 =
|
|
13014
|
-
|
|
13015
|
-
id:
|
|
13016
|
-
created:
|
|
13017
|
-
model:
|
|
13018
|
-
choices:
|
|
13019
|
-
|
|
13020
|
-
text:
|
|
13021
|
-
finish_reason:
|
|
13022
|
-
index:
|
|
13023
|
-
logprobs:
|
|
13024
|
-
tokens:
|
|
13025
|
-
token_logprobs:
|
|
13026
|
-
top_logprobs:
|
|
13344
|
+
var openaiCompletionChunkSchema2 = z62.z.union([
|
|
13345
|
+
z62.z.object({
|
|
13346
|
+
id: z62.z.string().nullish(),
|
|
13347
|
+
created: z62.z.number().nullish(),
|
|
13348
|
+
model: z62.z.string().nullish(),
|
|
13349
|
+
choices: z62.z.array(
|
|
13350
|
+
z62.z.object({
|
|
13351
|
+
text: z62.z.string(),
|
|
13352
|
+
finish_reason: z62.z.string().nullish(),
|
|
13353
|
+
index: z62.z.number(),
|
|
13354
|
+
logprobs: z62.z.object({
|
|
13355
|
+
tokens: z62.z.array(z62.z.string()),
|
|
13356
|
+
token_logprobs: z62.z.array(z62.z.number()),
|
|
13357
|
+
top_logprobs: z62.z.array(z62.z.record(z62.z.string(), z62.z.number())).nullish()
|
|
13027
13358
|
}).nullish()
|
|
13028
13359
|
})
|
|
13029
13360
|
),
|
|
@@ -13031,17 +13362,17 @@ var openaiCompletionChunkSchema2 = z52.z.union([
|
|
|
13031
13362
|
}),
|
|
13032
13363
|
openaiErrorDataSchema2
|
|
13033
13364
|
]);
|
|
13034
|
-
var openaiEmbeddingProviderOptions =
|
|
13365
|
+
var openaiEmbeddingProviderOptions = z62.z.object({
|
|
13035
13366
|
/**
|
|
13036
13367
|
The number of dimensions the resulting output embeddings should have.
|
|
13037
13368
|
Only supported in text-embedding-3 and later models.
|
|
13038
13369
|
*/
|
|
13039
|
-
dimensions:
|
|
13370
|
+
dimensions: z62.z.number().optional(),
|
|
13040
13371
|
/**
|
|
13041
13372
|
A unique identifier representing your end-user, which can help OpenAI to
|
|
13042
13373
|
monitor and detect abuse. Learn more.
|
|
13043
13374
|
*/
|
|
13044
|
-
user:
|
|
13375
|
+
user: z62.z.string().optional()
|
|
13045
13376
|
});
|
|
13046
13377
|
var OpenAIEmbeddingModel2 = class {
|
|
13047
13378
|
constructor(modelId, config) {
|
|
@@ -13105,9 +13436,9 @@ var OpenAIEmbeddingModel2 = class {
|
|
|
13105
13436
|
};
|
|
13106
13437
|
}
|
|
13107
13438
|
};
|
|
13108
|
-
var openaiTextEmbeddingResponseSchema2 =
|
|
13109
|
-
data:
|
|
13110
|
-
usage:
|
|
13439
|
+
var openaiTextEmbeddingResponseSchema2 = z62.z.object({
|
|
13440
|
+
data: z62.z.array(z62.z.object({ embedding: z62.z.array(z62.z.number()) })),
|
|
13441
|
+
usage: z62.z.object({ prompt_tokens: z62.z.number() }).nullish()
|
|
13111
13442
|
});
|
|
13112
13443
|
var modelMaxImagesPerCall2 = {
|
|
13113
13444
|
"dall-e-3": 1,
|
|
@@ -13192,198 +13523,37 @@ var OpenAIImageModel2 = class {
|
|
|
13192
13523
|
};
|
|
13193
13524
|
}
|
|
13194
13525
|
};
|
|
13195
|
-
var openaiImageResponseSchema2 =
|
|
13196
|
-
data:
|
|
13197
|
-
|
|
13526
|
+
var openaiImageResponseSchema2 = z62.z.object({
|
|
13527
|
+
data: z62.z.array(
|
|
13528
|
+
z62.z.object({ b64_json: z62.z.string(), revised_prompt: z62.z.string().optional() })
|
|
13198
13529
|
)
|
|
13199
13530
|
});
|
|
13531
|
+
var codeInterpreterArgsSchema = z62.z.object({
|
|
13532
|
+
container: z62.z.union([
|
|
13533
|
+
z62.z.string(),
|
|
13534
|
+
z62.z.object({
|
|
13535
|
+
fileIds: z62.z.array(z62.z.string()).optional()
|
|
13536
|
+
})
|
|
13537
|
+
]).optional()
|
|
13538
|
+
});
|
|
13539
|
+
var codeInterpreter = createProviderDefinedToolFactory({
|
|
13540
|
+
id: "openai.code_interpreter",
|
|
13541
|
+
name: "code_interpreter",
|
|
13542
|
+
inputSchema: z62.z.object({})
|
|
13543
|
+
});
|
|
13200
13544
|
var openaiTools2 = {
|
|
13545
|
+
codeInterpreter,
|
|
13201
13546
|
fileSearch,
|
|
13202
13547
|
webSearchPreview
|
|
13203
13548
|
};
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
include: z52.z.array(z52.z.string()).optional(),
|
|
13209
|
-
/**
|
|
13210
|
-
* The language of the input audio in ISO-639-1 format.
|
|
13211
|
-
*/
|
|
13212
|
-
language: z52.z.string().optional(),
|
|
13213
|
-
/**
|
|
13214
|
-
* An optional text to guide the model's style or continue a previous audio segment.
|
|
13215
|
-
*/
|
|
13216
|
-
prompt: z52.z.string().optional(),
|
|
13217
|
-
/**
|
|
13218
|
-
* The sampling temperature, between 0 and 1.
|
|
13219
|
-
* @default 0
|
|
13220
|
-
*/
|
|
13221
|
-
temperature: z52.z.number().min(0).max(1).default(0).optional(),
|
|
13222
|
-
/**
|
|
13223
|
-
* The timestamp granularities to populate for this transcription.
|
|
13224
|
-
* @default ['segment']
|
|
13225
|
-
*/
|
|
13226
|
-
timestampGranularities: z52.z.array(z52.z.enum(["word", "segment"])).default(["segment"]).optional()
|
|
13227
|
-
});
|
|
13228
|
-
var languageMap2 = {
|
|
13229
|
-
afrikaans: "af",
|
|
13230
|
-
arabic: "ar",
|
|
13231
|
-
armenian: "hy",
|
|
13232
|
-
azerbaijani: "az",
|
|
13233
|
-
belarusian: "be",
|
|
13234
|
-
bosnian: "bs",
|
|
13235
|
-
bulgarian: "bg",
|
|
13236
|
-
catalan: "ca",
|
|
13237
|
-
chinese: "zh",
|
|
13238
|
-
croatian: "hr",
|
|
13239
|
-
czech: "cs",
|
|
13240
|
-
danish: "da",
|
|
13241
|
-
dutch: "nl",
|
|
13242
|
-
english: "en",
|
|
13243
|
-
estonian: "et",
|
|
13244
|
-
finnish: "fi",
|
|
13245
|
-
french: "fr",
|
|
13246
|
-
galician: "gl",
|
|
13247
|
-
german: "de",
|
|
13248
|
-
greek: "el",
|
|
13249
|
-
hebrew: "he",
|
|
13250
|
-
hindi: "hi",
|
|
13251
|
-
hungarian: "hu",
|
|
13252
|
-
icelandic: "is",
|
|
13253
|
-
indonesian: "id",
|
|
13254
|
-
italian: "it",
|
|
13255
|
-
japanese: "ja",
|
|
13256
|
-
kannada: "kn",
|
|
13257
|
-
kazakh: "kk",
|
|
13258
|
-
korean: "ko",
|
|
13259
|
-
latvian: "lv",
|
|
13260
|
-
lithuanian: "lt",
|
|
13261
|
-
macedonian: "mk",
|
|
13262
|
-
malay: "ms",
|
|
13263
|
-
marathi: "mr",
|
|
13264
|
-
maori: "mi",
|
|
13265
|
-
nepali: "ne",
|
|
13266
|
-
norwegian: "no",
|
|
13267
|
-
persian: "fa",
|
|
13268
|
-
polish: "pl",
|
|
13269
|
-
portuguese: "pt",
|
|
13270
|
-
romanian: "ro",
|
|
13271
|
-
russian: "ru",
|
|
13272
|
-
serbian: "sr",
|
|
13273
|
-
slovak: "sk",
|
|
13274
|
-
slovenian: "sl",
|
|
13275
|
-
spanish: "es",
|
|
13276
|
-
swahili: "sw",
|
|
13277
|
-
swedish: "sv",
|
|
13278
|
-
tagalog: "tl",
|
|
13279
|
-
tamil: "ta",
|
|
13280
|
-
thai: "th",
|
|
13281
|
-
turkish: "tr",
|
|
13282
|
-
ukrainian: "uk",
|
|
13283
|
-
urdu: "ur",
|
|
13284
|
-
vietnamese: "vi",
|
|
13285
|
-
welsh: "cy"
|
|
13286
|
-
};
|
|
13287
|
-
var OpenAITranscriptionModel2 = class {
|
|
13288
|
-
constructor(modelId, config) {
|
|
13289
|
-
this.modelId = modelId;
|
|
13290
|
-
this.config = config;
|
|
13291
|
-
this.specificationVersion = "v2";
|
|
13292
|
-
}
|
|
13293
|
-
get provider() {
|
|
13294
|
-
return this.config.provider;
|
|
13295
|
-
}
|
|
13296
|
-
async getArgs({
|
|
13297
|
-
audio,
|
|
13298
|
-
mediaType,
|
|
13299
|
-
providerOptions
|
|
13300
|
-
}) {
|
|
13301
|
-
const warnings = [];
|
|
13302
|
-
const openAIOptions = await parseProviderOptions2({
|
|
13303
|
-
provider: "openai",
|
|
13304
|
-
providerOptions,
|
|
13305
|
-
schema: openAITranscriptionProviderOptions
|
|
13306
|
-
});
|
|
13307
|
-
const formData = new FormData();
|
|
13308
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array2(audio)]);
|
|
13309
|
-
formData.append("model", this.modelId);
|
|
13310
|
-
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
13311
|
-
if (openAIOptions) {
|
|
13312
|
-
const transcriptionModelOptions = {
|
|
13313
|
-
include: openAIOptions.include,
|
|
13314
|
-
language: openAIOptions.language,
|
|
13315
|
-
prompt: openAIOptions.prompt,
|
|
13316
|
-
temperature: openAIOptions.temperature,
|
|
13317
|
-
timestamp_granularities: openAIOptions.timestampGranularities
|
|
13318
|
-
};
|
|
13319
|
-
for (const [key, value] of Object.entries(transcriptionModelOptions)) {
|
|
13320
|
-
if (value != null) {
|
|
13321
|
-
formData.append(key, String(value));
|
|
13322
|
-
}
|
|
13323
|
-
}
|
|
13324
|
-
}
|
|
13325
|
-
return {
|
|
13326
|
-
formData,
|
|
13327
|
-
warnings
|
|
13328
|
-
};
|
|
13329
|
-
}
|
|
13330
|
-
async doGenerate(options) {
|
|
13331
|
-
var _a16, _b, _c, _d, _e, _f;
|
|
13332
|
-
const currentDate = (_c = (_b = (_a16 = this.config._internal) == null ? void 0 : _a16.currentDate) == null ? void 0 : _b.call(_a16)) != null ? _c : /* @__PURE__ */ new Date();
|
|
13333
|
-
const { formData, warnings } = await this.getArgs(options);
|
|
13334
|
-
const {
|
|
13335
|
-
value: response,
|
|
13336
|
-
responseHeaders,
|
|
13337
|
-
rawValue: rawResponse
|
|
13338
|
-
} = await postFormDataToApi2({
|
|
13339
|
-
url: this.config.url({
|
|
13340
|
-
path: "/audio/transcriptions",
|
|
13341
|
-
modelId: this.modelId
|
|
13342
|
-
}),
|
|
13343
|
-
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
13344
|
-
formData,
|
|
13345
|
-
failedResponseHandler: openaiFailedResponseHandler2,
|
|
13346
|
-
successfulResponseHandler: createJsonResponseHandler2(
|
|
13347
|
-
openaiTranscriptionResponseSchema2
|
|
13348
|
-
),
|
|
13349
|
-
abortSignal: options.abortSignal,
|
|
13350
|
-
fetch: this.config.fetch
|
|
13351
|
-
});
|
|
13352
|
-
const language = response.language != null && response.language in languageMap2 ? languageMap2[response.language] : void 0;
|
|
13353
|
-
return {
|
|
13354
|
-
text: response.text,
|
|
13355
|
-
segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
|
|
13356
|
-
text: word.word,
|
|
13357
|
-
startSecond: word.start,
|
|
13358
|
-
endSecond: word.end
|
|
13359
|
-
}))) != null ? _e : [],
|
|
13360
|
-
language,
|
|
13361
|
-
durationInSeconds: (_f = response.duration) != null ? _f : void 0,
|
|
13362
|
-
warnings,
|
|
13363
|
-
response: {
|
|
13364
|
-
timestamp: currentDate,
|
|
13365
|
-
modelId: this.modelId,
|
|
13366
|
-
headers: responseHeaders,
|
|
13367
|
-
body: rawResponse
|
|
13368
|
-
}
|
|
13369
|
-
};
|
|
13370
|
-
}
|
|
13371
|
-
};
|
|
13372
|
-
var openaiTranscriptionResponseSchema2 = z52.z.object({
|
|
13373
|
-
text: z52.z.string(),
|
|
13374
|
-
language: z52.z.string().nullish(),
|
|
13375
|
-
duration: z52.z.number().nullish(),
|
|
13376
|
-
words: z52.z.array(
|
|
13377
|
-
z52.z.object({
|
|
13378
|
-
word: z52.z.string(),
|
|
13379
|
-
start: z52.z.number(),
|
|
13380
|
-
end: z52.z.number()
|
|
13381
|
-
})
|
|
13382
|
-
).nullish()
|
|
13383
|
-
});
|
|
13549
|
+
function isFileId(data, prefixes) {
|
|
13550
|
+
if (!prefixes) return false;
|
|
13551
|
+
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
13552
|
+
}
|
|
13384
13553
|
async function convertToOpenAIResponsesMessages2({
|
|
13385
13554
|
prompt,
|
|
13386
|
-
systemMessageMode
|
|
13555
|
+
systemMessageMode,
|
|
13556
|
+
fileIdPrefixes
|
|
13387
13557
|
}) {
|
|
13388
13558
|
var _a16, _b, _c, _d, _e, _f;
|
|
13389
13559
|
const messages = [];
|
|
@@ -13430,8 +13600,9 @@ async function convertToOpenAIResponsesMessages2({
|
|
|
13430
13600
|
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
13431
13601
|
return {
|
|
13432
13602
|
type: "input_image",
|
|
13433
|
-
|
|
13434
|
-
|
|
13603
|
+
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
13604
|
+
image_url: `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
13605
|
+
},
|
|
13435
13606
|
detail: (_b2 = (_a23 = part.providerOptions) == null ? void 0 : _a23.openai) == null ? void 0 : _b2.imageDetail
|
|
13436
13607
|
};
|
|
13437
13608
|
} else if (part.mediaType === "application/pdf") {
|
|
@@ -13442,8 +13613,10 @@ async function convertToOpenAIResponsesMessages2({
|
|
|
13442
13613
|
}
|
|
13443
13614
|
return {
|
|
13444
13615
|
type: "input_file",
|
|
13445
|
-
|
|
13446
|
-
|
|
13616
|
+
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
13617
|
+
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
13618
|
+
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
13619
|
+
}
|
|
13447
13620
|
};
|
|
13448
13621
|
} else {
|
|
13449
13622
|
throw new UnsupportedFunctionalityError2({
|
|
@@ -13560,9 +13733,9 @@ async function convertToOpenAIResponsesMessages2({
|
|
|
13560
13733
|
}
|
|
13561
13734
|
return { messages, warnings };
|
|
13562
13735
|
}
|
|
13563
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
13564
|
-
itemId:
|
|
13565
|
-
reasoningEncryptedContent:
|
|
13736
|
+
var openaiResponsesReasoningProviderOptionsSchema = z62.z.object({
|
|
13737
|
+
itemId: z62.z.string().nullish(),
|
|
13738
|
+
reasoningEncryptedContent: z62.z.string().nullish()
|
|
13566
13739
|
});
|
|
13567
13740
|
function mapOpenAIResponseFinishReason2({
|
|
13568
13741
|
finishReason,
|
|
@@ -13602,7 +13775,7 @@ function prepareResponsesTools2({
|
|
|
13602
13775
|
strict: strictJsonSchema
|
|
13603
13776
|
});
|
|
13604
13777
|
break;
|
|
13605
|
-
case "provider-defined":
|
|
13778
|
+
case "provider-defined": {
|
|
13606
13779
|
switch (tool2.id) {
|
|
13607
13780
|
case "openai.file_search": {
|
|
13608
13781
|
const args = fileSearchArgsSchema.parse(tool2.args);
|
|
@@ -13615,18 +13788,30 @@ function prepareResponsesTools2({
|
|
|
13615
13788
|
});
|
|
13616
13789
|
break;
|
|
13617
13790
|
}
|
|
13618
|
-
case "openai.web_search_preview":
|
|
13791
|
+
case "openai.web_search_preview": {
|
|
13792
|
+
const args = webSearchPreviewArgsSchema.parse(tool2.args);
|
|
13619
13793
|
openaiTools22.push({
|
|
13620
13794
|
type: "web_search_preview",
|
|
13621
|
-
search_context_size:
|
|
13622
|
-
user_location:
|
|
13795
|
+
search_context_size: args.searchContextSize,
|
|
13796
|
+
user_location: args.userLocation
|
|
13623
13797
|
});
|
|
13624
13798
|
break;
|
|
13625
|
-
|
|
13799
|
+
}
|
|
13800
|
+
case "openai.code_interpreter": {
|
|
13801
|
+
const args = codeInterpreterArgsSchema.parse(tool2.args);
|
|
13802
|
+
openaiTools22.push({
|
|
13803
|
+
type: "code_interpreter",
|
|
13804
|
+
container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
|
|
13805
|
+
});
|
|
13806
|
+
break;
|
|
13807
|
+
}
|
|
13808
|
+
default: {
|
|
13626
13809
|
toolWarnings.push({ type: "unsupported-tool", tool: tool2 });
|
|
13627
13810
|
break;
|
|
13811
|
+
}
|
|
13628
13812
|
}
|
|
13629
13813
|
break;
|
|
13814
|
+
}
|
|
13630
13815
|
default:
|
|
13631
13816
|
toolWarnings.push({ type: "unsupported-tool", tool: tool2 });
|
|
13632
13817
|
break;
|
|
@@ -13644,7 +13829,7 @@ function prepareResponsesTools2({
|
|
|
13644
13829
|
case "tool":
|
|
13645
13830
|
return {
|
|
13646
13831
|
tools: openaiTools22,
|
|
13647
|
-
toolChoice: toolChoice.toolName === "
|
|
13832
|
+
toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
13648
13833
|
toolWarnings
|
|
13649
13834
|
};
|
|
13650
13835
|
default: {
|
|
@@ -13655,6 +13840,19 @@ function prepareResponsesTools2({
|
|
|
13655
13840
|
}
|
|
13656
13841
|
}
|
|
13657
13842
|
}
|
|
13843
|
+
var TOP_LOGPROBS_MAX = 20;
|
|
13844
|
+
var LOGPROBS_SCHEMA = z62.z.array(
|
|
13845
|
+
z62.z.object({
|
|
13846
|
+
token: z62.z.string(),
|
|
13847
|
+
logprob: z62.z.number(),
|
|
13848
|
+
top_logprobs: z62.z.array(
|
|
13849
|
+
z62.z.object({
|
|
13850
|
+
token: z62.z.string(),
|
|
13851
|
+
logprob: z62.z.number()
|
|
13852
|
+
})
|
|
13853
|
+
)
|
|
13854
|
+
})
|
|
13855
|
+
);
|
|
13658
13856
|
var OpenAIResponsesLanguageModel2 = class {
|
|
13659
13857
|
constructor(modelId, config) {
|
|
13660
13858
|
this.specificationVersion = "v2";
|
|
@@ -13708,7 +13906,8 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13708
13906
|
}
|
|
13709
13907
|
const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages2({
|
|
13710
13908
|
prompt,
|
|
13711
|
-
systemMessageMode: modelConfig.systemMessageMode
|
|
13909
|
+
systemMessageMode: modelConfig.systemMessageMode,
|
|
13910
|
+
fileIdPrefixes: this.config.fileIdPrefixes
|
|
13712
13911
|
});
|
|
13713
13912
|
warnings.push(...messageWarnings);
|
|
13714
13913
|
const openaiOptions = await parseProviderOptions2({
|
|
@@ -13717,21 +13916,28 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13717
13916
|
schema: openaiResponsesProviderOptionsSchema2
|
|
13718
13917
|
});
|
|
13719
13918
|
const strictJsonSchema = (_a16 = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a16 : false;
|
|
13919
|
+
const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
|
|
13920
|
+
const openaiOptionsInclude = topLogprobs ? Array.isArray(openaiOptions == null ? void 0 : openaiOptions.include) ? [...openaiOptions == null ? void 0 : openaiOptions.include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : openaiOptions == null ? void 0 : openaiOptions.include;
|
|
13720
13921
|
const baseArgs = {
|
|
13721
13922
|
model: this.modelId,
|
|
13722
13923
|
input: messages,
|
|
13723
13924
|
temperature,
|
|
13724
13925
|
top_p: topP,
|
|
13725
13926
|
max_output_tokens: maxOutputTokens,
|
|
13726
|
-
...(responseFormat == null ? void 0 : responseFormat.type) === "json" && {
|
|
13927
|
+
...((responseFormat == null ? void 0 : responseFormat.type) === "json" || (openaiOptions == null ? void 0 : openaiOptions.textVerbosity)) && {
|
|
13727
13928
|
text: {
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13929
|
+
...(responseFormat == null ? void 0 : responseFormat.type) === "json" && {
|
|
13930
|
+
format: responseFormat.schema != null ? {
|
|
13931
|
+
type: "json_schema",
|
|
13932
|
+
strict: strictJsonSchema,
|
|
13933
|
+
name: (_b = responseFormat.name) != null ? _b : "response",
|
|
13934
|
+
description: responseFormat.description,
|
|
13935
|
+
schema: responseFormat.schema
|
|
13936
|
+
} : { type: "json_object" }
|
|
13937
|
+
},
|
|
13938
|
+
...(openaiOptions == null ? void 0 : openaiOptions.textVerbosity) && {
|
|
13939
|
+
verbosity: openaiOptions.textVerbosity
|
|
13940
|
+
}
|
|
13735
13941
|
}
|
|
13736
13942
|
},
|
|
13737
13943
|
// provider options:
|
|
@@ -13742,7 +13948,10 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13742
13948
|
user: openaiOptions == null ? void 0 : openaiOptions.user,
|
|
13743
13949
|
instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
|
|
13744
13950
|
service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
|
|
13745
|
-
include:
|
|
13951
|
+
include: openaiOptionsInclude,
|
|
13952
|
+
prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
|
|
13953
|
+
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
13954
|
+
top_logprobs: topLogprobs,
|
|
13746
13955
|
// model-specific settings:
|
|
13747
13956
|
...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
13748
13957
|
reasoning: {
|
|
@@ -13791,19 +14000,19 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13791
14000
|
});
|
|
13792
14001
|
}
|
|
13793
14002
|
}
|
|
13794
|
-
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !
|
|
14003
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "flex" && !modelConfig.supportsFlexProcessing) {
|
|
13795
14004
|
warnings.push({
|
|
13796
14005
|
type: "unsupported-setting",
|
|
13797
14006
|
setting: "serviceTier",
|
|
13798
|
-
details: "flex processing is only available for o3
|
|
14007
|
+
details: "flex processing is only available for o3, o4-mini, and gpt-5 models"
|
|
13799
14008
|
});
|
|
13800
14009
|
delete baseArgs.service_tier;
|
|
13801
14010
|
}
|
|
13802
|
-
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !
|
|
14011
|
+
if ((openaiOptions == null ? void 0 : openaiOptions.serviceTier) === "priority" && !modelConfig.supportsPriorityProcessing) {
|
|
13803
14012
|
warnings.push({
|
|
13804
14013
|
type: "unsupported-setting",
|
|
13805
14014
|
setting: "serviceTier",
|
|
13806
|
-
details: "priority processing is only available for supported models (
|
|
14015
|
+
details: "priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"
|
|
13807
14016
|
});
|
|
13808
14017
|
delete baseArgs.service_tier;
|
|
13809
14018
|
}
|
|
@@ -13826,7 +14035,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13826
14035
|
};
|
|
13827
14036
|
}
|
|
13828
14037
|
async doGenerate(options) {
|
|
13829
|
-
var _a16, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
14038
|
+
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
13830
14039
|
const { args: body, warnings } = await this.getArgs(options);
|
|
13831
14040
|
const url = this.config.url({
|
|
13832
14041
|
path: "/responses",
|
|
@@ -13842,67 +14051,97 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13842
14051
|
body,
|
|
13843
14052
|
failedResponseHandler: openaiFailedResponseHandler2,
|
|
13844
14053
|
successfulResponseHandler: createJsonResponseHandler2(
|
|
13845
|
-
|
|
13846
|
-
id:
|
|
13847
|
-
created_at:
|
|
13848
|
-
error:
|
|
13849
|
-
code:
|
|
13850
|
-
message:
|
|
14054
|
+
z62.z.object({
|
|
14055
|
+
id: z62.z.string(),
|
|
14056
|
+
created_at: z62.z.number(),
|
|
14057
|
+
error: z62.z.object({
|
|
14058
|
+
code: z62.z.string(),
|
|
14059
|
+
message: z62.z.string()
|
|
13851
14060
|
}).nullish(),
|
|
13852
|
-
model:
|
|
13853
|
-
output:
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
type:
|
|
13857
|
-
role:
|
|
13858
|
-
id:
|
|
13859
|
-
content:
|
|
13860
|
-
|
|
13861
|
-
type:
|
|
13862
|
-
text:
|
|
13863
|
-
|
|
13864
|
-
|
|
13865
|
-
|
|
13866
|
-
|
|
13867
|
-
|
|
13868
|
-
|
|
13869
|
-
|
|
13870
|
-
|
|
14061
|
+
model: z62.z.string(),
|
|
14062
|
+
output: z62.z.array(
|
|
14063
|
+
z62.z.discriminatedUnion("type", [
|
|
14064
|
+
z62.z.object({
|
|
14065
|
+
type: z62.z.literal("message"),
|
|
14066
|
+
role: z62.z.literal("assistant"),
|
|
14067
|
+
id: z62.z.string(),
|
|
14068
|
+
content: z62.z.array(
|
|
14069
|
+
z62.z.object({
|
|
14070
|
+
type: z62.z.literal("output_text"),
|
|
14071
|
+
text: z62.z.string(),
|
|
14072
|
+
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
14073
|
+
annotations: z62.z.array(
|
|
14074
|
+
z62.z.discriminatedUnion("type", [
|
|
14075
|
+
z62.z.object({
|
|
14076
|
+
type: z62.z.literal("url_citation"),
|
|
14077
|
+
start_index: z62.z.number(),
|
|
14078
|
+
end_index: z62.z.number(),
|
|
14079
|
+
url: z62.z.string(),
|
|
14080
|
+
title: z62.z.string()
|
|
14081
|
+
}),
|
|
14082
|
+
z62.z.object({
|
|
14083
|
+
type: z62.z.literal("file_citation"),
|
|
14084
|
+
start_index: z62.z.number(),
|
|
14085
|
+
end_index: z62.z.number(),
|
|
14086
|
+
file_id: z62.z.string(),
|
|
14087
|
+
quote: z62.z.string()
|
|
14088
|
+
})
|
|
14089
|
+
])
|
|
13871
14090
|
)
|
|
13872
14091
|
})
|
|
13873
14092
|
)
|
|
13874
14093
|
}),
|
|
13875
|
-
|
|
13876
|
-
type:
|
|
13877
|
-
call_id:
|
|
13878
|
-
name:
|
|
13879
|
-
arguments:
|
|
13880
|
-
id:
|
|
14094
|
+
z62.z.object({
|
|
14095
|
+
type: z62.z.literal("function_call"),
|
|
14096
|
+
call_id: z62.z.string(),
|
|
14097
|
+
name: z62.z.string(),
|
|
14098
|
+
arguments: z62.z.string(),
|
|
14099
|
+
id: z62.z.string()
|
|
13881
14100
|
}),
|
|
13882
|
-
|
|
13883
|
-
type:
|
|
13884
|
-
id:
|
|
13885
|
-
status:
|
|
14101
|
+
z62.z.object({
|
|
14102
|
+
type: z62.z.literal("web_search_call"),
|
|
14103
|
+
id: z62.z.string(),
|
|
14104
|
+
status: z62.z.string().optional(),
|
|
14105
|
+
action: z62.z.object({
|
|
14106
|
+
type: z62.z.literal("search"),
|
|
14107
|
+
query: z62.z.string().optional()
|
|
14108
|
+
}).nullish()
|
|
13886
14109
|
}),
|
|
13887
|
-
|
|
13888
|
-
type:
|
|
13889
|
-
id:
|
|
13890
|
-
status:
|
|
14110
|
+
z62.z.object({
|
|
14111
|
+
type: z62.z.literal("computer_call"),
|
|
14112
|
+
id: z62.z.string(),
|
|
14113
|
+
status: z62.z.string().optional()
|
|
14114
|
+
}),
|
|
14115
|
+
z62.z.object({
|
|
14116
|
+
type: z62.z.literal("file_search_call"),
|
|
14117
|
+
id: z62.z.string(),
|
|
14118
|
+
status: z62.z.string().optional(),
|
|
14119
|
+
queries: z62.z.array(z62.z.string()).nullish(),
|
|
14120
|
+
results: z62.z.array(
|
|
14121
|
+
z62.z.object({
|
|
14122
|
+
attributes: z62.z.object({
|
|
14123
|
+
file_id: z62.z.string(),
|
|
14124
|
+
filename: z62.z.string(),
|
|
14125
|
+
score: z62.z.number(),
|
|
14126
|
+
text: z62.z.string()
|
|
14127
|
+
})
|
|
14128
|
+
})
|
|
14129
|
+
).nullish()
|
|
13891
14130
|
}),
|
|
13892
|
-
|
|
13893
|
-
type:
|
|
13894
|
-
id:
|
|
13895
|
-
encrypted_content:
|
|
13896
|
-
summary:
|
|
13897
|
-
|
|
13898
|
-
type:
|
|
13899
|
-
text:
|
|
14131
|
+
z62.z.object({
|
|
14132
|
+
type: z62.z.literal("reasoning"),
|
|
14133
|
+
id: z62.z.string(),
|
|
14134
|
+
encrypted_content: z62.z.string().nullish(),
|
|
14135
|
+
summary: z62.z.array(
|
|
14136
|
+
z62.z.object({
|
|
14137
|
+
type: z62.z.literal("summary_text"),
|
|
14138
|
+
text: z62.z.string()
|
|
13900
14139
|
})
|
|
13901
14140
|
)
|
|
13902
14141
|
})
|
|
13903
14142
|
])
|
|
13904
14143
|
),
|
|
13905
|
-
incomplete_details:
|
|
14144
|
+
incomplete_details: z62.z.object({ reason: z62.z.string() }).nullable(),
|
|
13906
14145
|
usage: usageSchema22
|
|
13907
14146
|
})
|
|
13908
14147
|
),
|
|
@@ -13921,6 +14160,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13921
14160
|
});
|
|
13922
14161
|
}
|
|
13923
14162
|
const content = [];
|
|
14163
|
+
const logprobs = [];
|
|
13924
14164
|
for (const part of response.output) {
|
|
13925
14165
|
switch (part.type) {
|
|
13926
14166
|
case "reasoning": {
|
|
@@ -13943,6 +14183,9 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13943
14183
|
}
|
|
13944
14184
|
case "message": {
|
|
13945
14185
|
for (const contentPart of part.content) {
|
|
14186
|
+
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
14187
|
+
logprobs.push(contentPart.logprobs);
|
|
14188
|
+
}
|
|
13946
14189
|
content.push({
|
|
13947
14190
|
type: "text",
|
|
13948
14191
|
text: contentPart.text,
|
|
@@ -13953,13 +14196,24 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13953
14196
|
}
|
|
13954
14197
|
});
|
|
13955
14198
|
for (const annotation of contentPart.annotations) {
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
|
|
14199
|
+
if (annotation.type === "url_citation") {
|
|
14200
|
+
content.push({
|
|
14201
|
+
type: "source",
|
|
14202
|
+
sourceType: "url",
|
|
14203
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : generateId2(),
|
|
14204
|
+
url: annotation.url,
|
|
14205
|
+
title: annotation.title
|
|
14206
|
+
});
|
|
14207
|
+
} else if (annotation.type === "file_citation") {
|
|
14208
|
+
content.push({
|
|
14209
|
+
type: "source",
|
|
14210
|
+
sourceType: "document",
|
|
14211
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
14212
|
+
mediaType: "text/plain",
|
|
14213
|
+
title: annotation.quote,
|
|
14214
|
+
filename: annotation.file_id
|
|
14215
|
+
});
|
|
14216
|
+
}
|
|
13963
14217
|
}
|
|
13964
14218
|
}
|
|
13965
14219
|
break;
|
|
@@ -13983,14 +14237,17 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
13983
14237
|
type: "tool-call",
|
|
13984
14238
|
toolCallId: part.id,
|
|
13985
14239
|
toolName: "web_search_preview",
|
|
13986
|
-
input: "",
|
|
14240
|
+
input: (_k = (_j = part.action) == null ? void 0 : _j.query) != null ? _k : "",
|
|
13987
14241
|
providerExecuted: true
|
|
13988
14242
|
});
|
|
13989
14243
|
content.push({
|
|
13990
14244
|
type: "tool-result",
|
|
13991
14245
|
toolCallId: part.id,
|
|
13992
14246
|
toolName: "web_search_preview",
|
|
13993
|
-
result: {
|
|
14247
|
+
result: {
|
|
14248
|
+
status: part.status || "completed",
|
|
14249
|
+
...((_l = part.action) == null ? void 0 : _l.query) && { query: part.action.query }
|
|
14250
|
+
},
|
|
13994
14251
|
providerExecuted: true
|
|
13995
14252
|
});
|
|
13996
14253
|
break;
|
|
@@ -14015,20 +14272,48 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14015
14272
|
});
|
|
14016
14273
|
break;
|
|
14017
14274
|
}
|
|
14275
|
+
case "file_search_call": {
|
|
14276
|
+
content.push({
|
|
14277
|
+
type: "tool-call",
|
|
14278
|
+
toolCallId: part.id,
|
|
14279
|
+
toolName: "file_search",
|
|
14280
|
+
input: "",
|
|
14281
|
+
providerExecuted: true
|
|
14282
|
+
});
|
|
14283
|
+
content.push({
|
|
14284
|
+
type: "tool-result",
|
|
14285
|
+
toolCallId: part.id,
|
|
14286
|
+
toolName: "file_search",
|
|
14287
|
+
result: {
|
|
14288
|
+
type: "file_search_tool_result",
|
|
14289
|
+
status: part.status || "completed",
|
|
14290
|
+
...part.queries && { queries: part.queries },
|
|
14291
|
+
...part.results && { results: part.results }
|
|
14292
|
+
},
|
|
14293
|
+
providerExecuted: true
|
|
14294
|
+
});
|
|
14295
|
+
break;
|
|
14296
|
+
}
|
|
14018
14297
|
}
|
|
14019
14298
|
}
|
|
14299
|
+
const providerMetadata = {
|
|
14300
|
+
openai: { responseId: response.id }
|
|
14301
|
+
};
|
|
14302
|
+
if (logprobs.length > 0) {
|
|
14303
|
+
providerMetadata.openai.logprobs = logprobs;
|
|
14304
|
+
}
|
|
14020
14305
|
return {
|
|
14021
14306
|
content,
|
|
14022
14307
|
finishReason: mapOpenAIResponseFinishReason2({
|
|
14023
|
-
finishReason: (
|
|
14308
|
+
finishReason: (_m = response.incomplete_details) == null ? void 0 : _m.reason,
|
|
14024
14309
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
14025
14310
|
}),
|
|
14026
14311
|
usage: {
|
|
14027
14312
|
inputTokens: response.usage.input_tokens,
|
|
14028
14313
|
outputTokens: response.usage.output_tokens,
|
|
14029
14314
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
14030
|
-
reasoningTokens: (
|
|
14031
|
-
cachedInputTokens: (
|
|
14315
|
+
reasoningTokens: (_o = (_n = response.usage.output_tokens_details) == null ? void 0 : _n.reasoning_tokens) != null ? _o : void 0,
|
|
14316
|
+
cachedInputTokens: (_q = (_p = response.usage.input_tokens_details) == null ? void 0 : _p.cached_tokens) != null ? _q : void 0
|
|
14032
14317
|
},
|
|
14033
14318
|
request: { body },
|
|
14034
14319
|
response: {
|
|
@@ -14038,11 +14323,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14038
14323
|
headers: responseHeaders,
|
|
14039
14324
|
body: rawResponse
|
|
14040
14325
|
},
|
|
14041
|
-
providerMetadata
|
|
14042
|
-
openai: {
|
|
14043
|
-
responseId: response.id
|
|
14044
|
-
}
|
|
14045
|
-
},
|
|
14326
|
+
providerMetadata,
|
|
14046
14327
|
warnings
|
|
14047
14328
|
};
|
|
14048
14329
|
}
|
|
@@ -14072,6 +14353,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14072
14353
|
outputTokens: void 0,
|
|
14073
14354
|
totalTokens: void 0
|
|
14074
14355
|
};
|
|
14356
|
+
const logprobs = [];
|
|
14075
14357
|
let responseId = null;
|
|
14076
14358
|
const ongoingToolCalls = {};
|
|
14077
14359
|
let hasToolCalls = false;
|
|
@@ -14083,7 +14365,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14083
14365
|
controller.enqueue({ type: "stream-start", warnings });
|
|
14084
14366
|
},
|
|
14085
14367
|
transform(chunk, controller) {
|
|
14086
|
-
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
14368
|
+
var _a16, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
14087
14369
|
if (options.includeRawChunks) {
|
|
14088
14370
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
14089
14371
|
}
|
|
@@ -14124,6 +14406,16 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14124
14406
|
id: value.item.id,
|
|
14125
14407
|
toolName: "computer_use"
|
|
14126
14408
|
});
|
|
14409
|
+
} else if (value.item.type === "file_search_call") {
|
|
14410
|
+
ongoingToolCalls[value.output_index] = {
|
|
14411
|
+
toolName: "file_search",
|
|
14412
|
+
toolCallId: value.item.id
|
|
14413
|
+
};
|
|
14414
|
+
controller.enqueue({
|
|
14415
|
+
type: "tool-input-start",
|
|
14416
|
+
id: value.item.id,
|
|
14417
|
+
toolName: "file_search"
|
|
14418
|
+
});
|
|
14127
14419
|
} else if (value.item.type === "message") {
|
|
14128
14420
|
controller.enqueue({
|
|
14129
14421
|
type: "text-start",
|
|
@@ -14180,7 +14472,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14180
14472
|
type: "tool-call",
|
|
14181
14473
|
toolCallId: value.item.id,
|
|
14182
14474
|
toolName: "web_search_preview",
|
|
14183
|
-
input: "",
|
|
14475
|
+
input: (_c = (_b = value.item.action) == null ? void 0 : _b.query) != null ? _c : "",
|
|
14184
14476
|
providerExecuted: true
|
|
14185
14477
|
});
|
|
14186
14478
|
controller.enqueue({
|
|
@@ -14189,7 +14481,10 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14189
14481
|
toolName: "web_search_preview",
|
|
14190
14482
|
result: {
|
|
14191
14483
|
type: "web_search_tool_result",
|
|
14192
|
-
status: value.item.status || "completed"
|
|
14484
|
+
status: value.item.status || "completed",
|
|
14485
|
+
...((_d = value.item.action) == null ? void 0 : _d.query) && {
|
|
14486
|
+
query: value.item.action.query
|
|
14487
|
+
}
|
|
14193
14488
|
},
|
|
14194
14489
|
providerExecuted: true
|
|
14195
14490
|
});
|
|
@@ -14217,6 +14512,32 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14217
14512
|
},
|
|
14218
14513
|
providerExecuted: true
|
|
14219
14514
|
});
|
|
14515
|
+
} else if (value.item.type === "file_search_call") {
|
|
14516
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
14517
|
+
hasToolCalls = true;
|
|
14518
|
+
controller.enqueue({
|
|
14519
|
+
type: "tool-input-end",
|
|
14520
|
+
id: value.item.id
|
|
14521
|
+
});
|
|
14522
|
+
controller.enqueue({
|
|
14523
|
+
type: "tool-call",
|
|
14524
|
+
toolCallId: value.item.id,
|
|
14525
|
+
toolName: "file_search",
|
|
14526
|
+
input: "",
|
|
14527
|
+
providerExecuted: true
|
|
14528
|
+
});
|
|
14529
|
+
controller.enqueue({
|
|
14530
|
+
type: "tool-result",
|
|
14531
|
+
toolCallId: value.item.id,
|
|
14532
|
+
toolName: "file_search",
|
|
14533
|
+
result: {
|
|
14534
|
+
type: "file_search_tool_result",
|
|
14535
|
+
status: value.item.status || "completed",
|
|
14536
|
+
...value.item.queries && { queries: value.item.queries },
|
|
14537
|
+
...value.item.results && { results: value.item.results }
|
|
14538
|
+
},
|
|
14539
|
+
providerExecuted: true
|
|
14540
|
+
});
|
|
14220
14541
|
} else if (value.item.type === "message") {
|
|
14221
14542
|
controller.enqueue({
|
|
14222
14543
|
type: "text-end",
|
|
@@ -14231,7 +14552,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14231
14552
|
providerMetadata: {
|
|
14232
14553
|
openai: {
|
|
14233
14554
|
itemId: value.item.id,
|
|
14234
|
-
reasoningEncryptedContent: (
|
|
14555
|
+
reasoningEncryptedContent: (_e = value.item.encrypted_content) != null ? _e : null
|
|
14235
14556
|
}
|
|
14236
14557
|
}
|
|
14237
14558
|
});
|
|
@@ -14261,9 +14582,12 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14261
14582
|
id: value.item_id,
|
|
14262
14583
|
delta: value.delta
|
|
14263
14584
|
});
|
|
14585
|
+
if (value.logprobs) {
|
|
14586
|
+
logprobs.push(value.logprobs);
|
|
14587
|
+
}
|
|
14264
14588
|
} else if (isResponseReasoningSummaryPartAddedChunk(value)) {
|
|
14265
14589
|
if (value.summary_index > 0) {
|
|
14266
|
-
(
|
|
14590
|
+
(_f = activeReasoning[value.item_id]) == null ? void 0 : _f.summaryParts.push(
|
|
14267
14591
|
value.summary_index
|
|
14268
14592
|
);
|
|
14269
14593
|
controller.enqueue({
|
|
@@ -14272,7 +14596,7 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14272
14596
|
providerMetadata: {
|
|
14273
14597
|
openai: {
|
|
14274
14598
|
itemId: value.item_id,
|
|
14275
|
-
reasoningEncryptedContent: (
|
|
14599
|
+
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
14276
14600
|
}
|
|
14277
14601
|
}
|
|
14278
14602
|
});
|
|
@@ -14290,36 +14614,51 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14290
14614
|
});
|
|
14291
14615
|
} else if (isResponseFinishedChunk2(value)) {
|
|
14292
14616
|
finishReason = mapOpenAIResponseFinishReason2({
|
|
14293
|
-
finishReason: (
|
|
14617
|
+
finishReason: (_i = value.response.incomplete_details) == null ? void 0 : _i.reason,
|
|
14294
14618
|
hasToolCalls
|
|
14295
14619
|
});
|
|
14296
14620
|
usage.inputTokens = value.response.usage.input_tokens;
|
|
14297
14621
|
usage.outputTokens = value.response.usage.output_tokens;
|
|
14298
14622
|
usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
|
|
14299
|
-
usage.reasoningTokens = (
|
|
14300
|
-
usage.cachedInputTokens = (
|
|
14623
|
+
usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? void 0 : _j.reasoning_tokens) != null ? _k : void 0;
|
|
14624
|
+
usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? void 0 : _l.cached_tokens) != null ? _m : void 0;
|
|
14301
14625
|
} else if (isResponseAnnotationAddedChunk2(value)) {
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14626
|
+
if (value.annotation.type === "url_citation") {
|
|
14627
|
+
controller.enqueue({
|
|
14628
|
+
type: "source",
|
|
14629
|
+
sourceType: "url",
|
|
14630
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
14631
|
+
url: value.annotation.url,
|
|
14632
|
+
title: value.annotation.title
|
|
14633
|
+
});
|
|
14634
|
+
} else if (value.annotation.type === "file_citation") {
|
|
14635
|
+
controller.enqueue({
|
|
14636
|
+
type: "source",
|
|
14637
|
+
sourceType: "document",
|
|
14638
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId2(),
|
|
14639
|
+
mediaType: "text/plain",
|
|
14640
|
+
title: value.annotation.quote,
|
|
14641
|
+
filename: value.annotation.file_id
|
|
14642
|
+
});
|
|
14643
|
+
}
|
|
14309
14644
|
} else if (isErrorChunk2(value)) {
|
|
14310
14645
|
controller.enqueue({ type: "error", error: value });
|
|
14311
14646
|
}
|
|
14312
14647
|
},
|
|
14313
14648
|
flush(controller) {
|
|
14649
|
+
const providerMetadata = {
|
|
14650
|
+
openai: {
|
|
14651
|
+
responseId
|
|
14652
|
+
}
|
|
14653
|
+
};
|
|
14654
|
+
if (logprobs.length > 0) {
|
|
14655
|
+
providerMetadata.openai.logprobs = logprobs;
|
|
14656
|
+
}
|
|
14314
14657
|
controller.enqueue({
|
|
14315
14658
|
type: "finish",
|
|
14316
14659
|
finishReason,
|
|
14317
14660
|
usage,
|
|
14318
|
-
providerMetadata
|
|
14319
|
-
openai: {
|
|
14320
|
-
responseId
|
|
14321
|
-
}
|
|
14322
|
-
}
|
|
14661
|
+
providerMetadata
|
|
14323
14662
|
});
|
|
14324
14663
|
}
|
|
14325
14664
|
})
|
|
@@ -14329,130 +14668,178 @@ var OpenAIResponsesLanguageModel2 = class {
|
|
|
14329
14668
|
};
|
|
14330
14669
|
}
|
|
14331
14670
|
};
|
|
14332
|
-
var usageSchema22 =
|
|
14333
|
-
input_tokens:
|
|
14334
|
-
input_tokens_details:
|
|
14335
|
-
output_tokens:
|
|
14336
|
-
output_tokens_details:
|
|
14671
|
+
var usageSchema22 = z62.z.object({
|
|
14672
|
+
input_tokens: z62.z.number(),
|
|
14673
|
+
input_tokens_details: z62.z.object({ cached_tokens: z62.z.number().nullish() }).nullish(),
|
|
14674
|
+
output_tokens: z62.z.number(),
|
|
14675
|
+
output_tokens_details: z62.z.object({ reasoning_tokens: z62.z.number().nullish() }).nullish()
|
|
14337
14676
|
});
|
|
14338
|
-
var textDeltaChunkSchema2 =
|
|
14339
|
-
type:
|
|
14340
|
-
item_id:
|
|
14341
|
-
delta:
|
|
14677
|
+
var textDeltaChunkSchema2 = z62.z.object({
|
|
14678
|
+
type: z62.z.literal("response.output_text.delta"),
|
|
14679
|
+
item_id: z62.z.string(),
|
|
14680
|
+
delta: z62.z.string(),
|
|
14681
|
+
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
14342
14682
|
});
|
|
14343
|
-
var errorChunkSchema2 =
|
|
14344
|
-
type:
|
|
14345
|
-
code:
|
|
14346
|
-
message:
|
|
14347
|
-
param:
|
|
14348
|
-
sequence_number:
|
|
14683
|
+
var errorChunkSchema2 = z62.z.object({
|
|
14684
|
+
type: z62.z.literal("error"),
|
|
14685
|
+
code: z62.z.string(),
|
|
14686
|
+
message: z62.z.string(),
|
|
14687
|
+
param: z62.z.string().nullish(),
|
|
14688
|
+
sequence_number: z62.z.number()
|
|
14349
14689
|
});
|
|
14350
|
-
var responseFinishedChunkSchema2 =
|
|
14351
|
-
type:
|
|
14352
|
-
response:
|
|
14353
|
-
incomplete_details:
|
|
14690
|
+
var responseFinishedChunkSchema2 = z62.z.object({
|
|
14691
|
+
type: z62.z.enum(["response.completed", "response.incomplete"]),
|
|
14692
|
+
response: z62.z.object({
|
|
14693
|
+
incomplete_details: z62.z.object({ reason: z62.z.string() }).nullish(),
|
|
14354
14694
|
usage: usageSchema22
|
|
14355
14695
|
})
|
|
14356
14696
|
});
|
|
14357
|
-
var responseCreatedChunkSchema2 =
|
|
14358
|
-
type:
|
|
14359
|
-
response:
|
|
14360
|
-
id:
|
|
14361
|
-
created_at:
|
|
14362
|
-
model:
|
|
14697
|
+
var responseCreatedChunkSchema2 = z62.z.object({
|
|
14698
|
+
type: z62.z.literal("response.created"),
|
|
14699
|
+
response: z62.z.object({
|
|
14700
|
+
id: z62.z.string(),
|
|
14701
|
+
created_at: z62.z.number(),
|
|
14702
|
+
model: z62.z.string()
|
|
14363
14703
|
})
|
|
14364
14704
|
});
|
|
14365
|
-
var responseOutputItemAddedSchema2 =
|
|
14366
|
-
type:
|
|
14367
|
-
output_index:
|
|
14368
|
-
item:
|
|
14369
|
-
|
|
14370
|
-
type:
|
|
14371
|
-
id:
|
|
14705
|
+
var responseOutputItemAddedSchema2 = z62.z.object({
|
|
14706
|
+
type: z62.z.literal("response.output_item.added"),
|
|
14707
|
+
output_index: z62.z.number(),
|
|
14708
|
+
item: z62.z.discriminatedUnion("type", [
|
|
14709
|
+
z62.z.object({
|
|
14710
|
+
type: z62.z.literal("message"),
|
|
14711
|
+
id: z62.z.string()
|
|
14712
|
+
}),
|
|
14713
|
+
z62.z.object({
|
|
14714
|
+
type: z62.z.literal("reasoning"),
|
|
14715
|
+
id: z62.z.string(),
|
|
14716
|
+
encrypted_content: z62.z.string().nullish()
|
|
14372
14717
|
}),
|
|
14373
|
-
|
|
14374
|
-
type:
|
|
14375
|
-
id:
|
|
14376
|
-
|
|
14718
|
+
z62.z.object({
|
|
14719
|
+
type: z62.z.literal("function_call"),
|
|
14720
|
+
id: z62.z.string(),
|
|
14721
|
+
call_id: z62.z.string(),
|
|
14722
|
+
name: z62.z.string(),
|
|
14723
|
+
arguments: z62.z.string()
|
|
14377
14724
|
}),
|
|
14378
|
-
|
|
14379
|
-
type:
|
|
14380
|
-
id:
|
|
14381
|
-
|
|
14382
|
-
|
|
14383
|
-
|
|
14725
|
+
z62.z.object({
|
|
14726
|
+
type: z62.z.literal("web_search_call"),
|
|
14727
|
+
id: z62.z.string(),
|
|
14728
|
+
status: z62.z.string(),
|
|
14729
|
+
action: z62.z.object({
|
|
14730
|
+
type: z62.z.literal("search"),
|
|
14731
|
+
query: z62.z.string().optional()
|
|
14732
|
+
}).nullish()
|
|
14384
14733
|
}),
|
|
14385
|
-
|
|
14386
|
-
type:
|
|
14387
|
-
id:
|
|
14388
|
-
status:
|
|
14734
|
+
z62.z.object({
|
|
14735
|
+
type: z62.z.literal("computer_call"),
|
|
14736
|
+
id: z62.z.string(),
|
|
14737
|
+
status: z62.z.string()
|
|
14389
14738
|
}),
|
|
14390
|
-
|
|
14391
|
-
type:
|
|
14392
|
-
id:
|
|
14393
|
-
status:
|
|
14739
|
+
z62.z.object({
|
|
14740
|
+
type: z62.z.literal("file_search_call"),
|
|
14741
|
+
id: z62.z.string(),
|
|
14742
|
+
status: z62.z.string(),
|
|
14743
|
+
queries: z62.z.array(z62.z.string()).nullish(),
|
|
14744
|
+
results: z62.z.array(
|
|
14745
|
+
z62.z.object({
|
|
14746
|
+
attributes: z62.z.object({
|
|
14747
|
+
file_id: z62.z.string(),
|
|
14748
|
+
filename: z62.z.string(),
|
|
14749
|
+
score: z62.z.number(),
|
|
14750
|
+
text: z62.z.string()
|
|
14751
|
+
})
|
|
14752
|
+
})
|
|
14753
|
+
).optional()
|
|
14394
14754
|
})
|
|
14395
14755
|
])
|
|
14396
14756
|
});
|
|
14397
|
-
var responseOutputItemDoneSchema2 =
|
|
14398
|
-
type:
|
|
14399
|
-
output_index:
|
|
14400
|
-
item:
|
|
14401
|
-
|
|
14402
|
-
type:
|
|
14403
|
-
id:
|
|
14757
|
+
var responseOutputItemDoneSchema2 = z62.z.object({
|
|
14758
|
+
type: z62.z.literal("response.output_item.done"),
|
|
14759
|
+
output_index: z62.z.number(),
|
|
14760
|
+
item: z62.z.discriminatedUnion("type", [
|
|
14761
|
+
z62.z.object({
|
|
14762
|
+
type: z62.z.literal("message"),
|
|
14763
|
+
id: z62.z.string()
|
|
14404
14764
|
}),
|
|
14405
|
-
|
|
14406
|
-
type:
|
|
14407
|
-
id:
|
|
14408
|
-
encrypted_content:
|
|
14765
|
+
z62.z.object({
|
|
14766
|
+
type: z62.z.literal("reasoning"),
|
|
14767
|
+
id: z62.z.string(),
|
|
14768
|
+
encrypted_content: z62.z.string().nullish()
|
|
14409
14769
|
}),
|
|
14410
|
-
|
|
14411
|
-
type:
|
|
14412
|
-
id:
|
|
14413
|
-
call_id:
|
|
14414
|
-
name:
|
|
14415
|
-
arguments:
|
|
14416
|
-
status:
|
|
14770
|
+
z62.z.object({
|
|
14771
|
+
type: z62.z.literal("function_call"),
|
|
14772
|
+
id: z62.z.string(),
|
|
14773
|
+
call_id: z62.z.string(),
|
|
14774
|
+
name: z62.z.string(),
|
|
14775
|
+
arguments: z62.z.string(),
|
|
14776
|
+
status: z62.z.literal("completed")
|
|
14777
|
+
}),
|
|
14778
|
+
z62.z.object({
|
|
14779
|
+
type: z62.z.literal("web_search_call"),
|
|
14780
|
+
id: z62.z.string(),
|
|
14781
|
+
status: z62.z.literal("completed"),
|
|
14782
|
+
action: z62.z.object({
|
|
14783
|
+
type: z62.z.literal("search"),
|
|
14784
|
+
query: z62.z.string().optional()
|
|
14785
|
+
}).nullish()
|
|
14417
14786
|
}),
|
|
14418
|
-
|
|
14419
|
-
type:
|
|
14420
|
-
id:
|
|
14421
|
-
status:
|
|
14787
|
+
z62.z.object({
|
|
14788
|
+
type: z62.z.literal("computer_call"),
|
|
14789
|
+
id: z62.z.string(),
|
|
14790
|
+
status: z62.z.literal("completed")
|
|
14422
14791
|
}),
|
|
14423
|
-
|
|
14424
|
-
type:
|
|
14425
|
-
id:
|
|
14426
|
-
status:
|
|
14792
|
+
z62.z.object({
|
|
14793
|
+
type: z62.z.literal("file_search_call"),
|
|
14794
|
+
id: z62.z.string(),
|
|
14795
|
+
status: z62.z.literal("completed"),
|
|
14796
|
+
queries: z62.z.array(z62.z.string()).nullish(),
|
|
14797
|
+
results: z62.z.array(
|
|
14798
|
+
z62.z.object({
|
|
14799
|
+
attributes: z62.z.object({
|
|
14800
|
+
file_id: z62.z.string(),
|
|
14801
|
+
filename: z62.z.string(),
|
|
14802
|
+
score: z62.z.number(),
|
|
14803
|
+
text: z62.z.string()
|
|
14804
|
+
})
|
|
14805
|
+
})
|
|
14806
|
+
).nullish()
|
|
14427
14807
|
})
|
|
14428
14808
|
])
|
|
14429
14809
|
});
|
|
14430
|
-
var responseFunctionCallArgumentsDeltaSchema2 =
|
|
14431
|
-
type:
|
|
14432
|
-
item_id:
|
|
14433
|
-
output_index:
|
|
14434
|
-
delta:
|
|
14810
|
+
var responseFunctionCallArgumentsDeltaSchema2 = z62.z.object({
|
|
14811
|
+
type: z62.z.literal("response.function_call_arguments.delta"),
|
|
14812
|
+
item_id: z62.z.string(),
|
|
14813
|
+
output_index: z62.z.number(),
|
|
14814
|
+
delta: z62.z.string()
|
|
14435
14815
|
});
|
|
14436
|
-
var responseAnnotationAddedSchema2 =
|
|
14437
|
-
type:
|
|
14438
|
-
annotation:
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14816
|
+
var responseAnnotationAddedSchema2 = z62.z.object({
|
|
14817
|
+
type: z62.z.literal("response.output_text.annotation.added"),
|
|
14818
|
+
annotation: z62.z.discriminatedUnion("type", [
|
|
14819
|
+
z62.z.object({
|
|
14820
|
+
type: z62.z.literal("url_citation"),
|
|
14821
|
+
url: z62.z.string(),
|
|
14822
|
+
title: z62.z.string()
|
|
14823
|
+
}),
|
|
14824
|
+
z62.z.object({
|
|
14825
|
+
type: z62.z.literal("file_citation"),
|
|
14826
|
+
file_id: z62.z.string(),
|
|
14827
|
+
quote: z62.z.string()
|
|
14828
|
+
})
|
|
14829
|
+
])
|
|
14443
14830
|
});
|
|
14444
|
-
var responseReasoningSummaryPartAddedSchema =
|
|
14445
|
-
type:
|
|
14446
|
-
item_id:
|
|
14447
|
-
summary_index:
|
|
14831
|
+
var responseReasoningSummaryPartAddedSchema = z62.z.object({
|
|
14832
|
+
type: z62.z.literal("response.reasoning_summary_part.added"),
|
|
14833
|
+
item_id: z62.z.string(),
|
|
14834
|
+
summary_index: z62.z.number()
|
|
14448
14835
|
});
|
|
14449
|
-
var responseReasoningSummaryTextDeltaSchema2 =
|
|
14450
|
-
type:
|
|
14451
|
-
item_id:
|
|
14452
|
-
summary_index:
|
|
14453
|
-
delta:
|
|
14836
|
+
var responseReasoningSummaryTextDeltaSchema2 = z62.z.object({
|
|
14837
|
+
type: z62.z.literal("response.reasoning_summary_text.delta"),
|
|
14838
|
+
item_id: z62.z.string(),
|
|
14839
|
+
summary_index: z62.z.number(),
|
|
14840
|
+
delta: z62.z.string()
|
|
14454
14841
|
});
|
|
14455
|
-
var openaiResponsesChunkSchema2 =
|
|
14842
|
+
var openaiResponsesChunkSchema2 = z62.z.union([
|
|
14456
14843
|
textDeltaChunkSchema2,
|
|
14457
14844
|
responseFinishedChunkSchema2,
|
|
14458
14845
|
responseCreatedChunkSchema2,
|
|
@@ -14463,7 +14850,7 @@ var openaiResponsesChunkSchema2 = z52.z.union([
|
|
|
14463
14850
|
responseReasoningSummaryPartAddedSchema,
|
|
14464
14851
|
responseReasoningSummaryTextDeltaSchema2,
|
|
14465
14852
|
errorChunkSchema2,
|
|
14466
|
-
|
|
14853
|
+
z62.z.object({ type: z62.z.string() }).loose()
|
|
14467
14854
|
// fallback for unknown chunks
|
|
14468
14855
|
]);
|
|
14469
14856
|
function isTextDeltaChunk2(chunk) {
|
|
@@ -14503,48 +14890,77 @@ function isErrorChunk2(chunk) {
|
|
|
14503
14890
|
return chunk.type === "error";
|
|
14504
14891
|
}
|
|
14505
14892
|
function getResponsesModelConfig2(modelId) {
|
|
14506
|
-
|
|
14893
|
+
const supportsFlexProcessing2 = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
14894
|
+
const supportsPriorityProcessing2 = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
14895
|
+
const defaults = {
|
|
14896
|
+
requiredAutoTruncation: false,
|
|
14897
|
+
systemMessageMode: "system",
|
|
14898
|
+
supportsFlexProcessing: supportsFlexProcessing2,
|
|
14899
|
+
supportsPriorityProcessing: supportsPriorityProcessing2
|
|
14900
|
+
};
|
|
14901
|
+
if (modelId.startsWith("gpt-5-chat")) {
|
|
14902
|
+
return {
|
|
14903
|
+
...defaults,
|
|
14904
|
+
isReasoningModel: false
|
|
14905
|
+
};
|
|
14906
|
+
}
|
|
14907
|
+
if (modelId.startsWith("o") || modelId.startsWith("gpt-5") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
14507
14908
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
14508
14909
|
return {
|
|
14910
|
+
...defaults,
|
|
14509
14911
|
isReasoningModel: true,
|
|
14510
|
-
systemMessageMode: "remove"
|
|
14511
|
-
requiredAutoTruncation: false
|
|
14912
|
+
systemMessageMode: "remove"
|
|
14512
14913
|
};
|
|
14513
14914
|
}
|
|
14514
14915
|
return {
|
|
14916
|
+
...defaults,
|
|
14515
14917
|
isReasoningModel: true,
|
|
14516
|
-
systemMessageMode: "developer"
|
|
14517
|
-
requiredAutoTruncation: false
|
|
14918
|
+
systemMessageMode: "developer"
|
|
14518
14919
|
};
|
|
14519
14920
|
}
|
|
14520
14921
|
return {
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
requiredAutoTruncation: false
|
|
14922
|
+
...defaults,
|
|
14923
|
+
isReasoningModel: false
|
|
14524
14924
|
};
|
|
14525
14925
|
}
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14926
|
+
var openaiResponsesProviderOptionsSchema2 = z62.z.object({
|
|
14927
|
+
metadata: z62.z.any().nullish(),
|
|
14928
|
+
parallelToolCalls: z62.z.boolean().nullish(),
|
|
14929
|
+
previousResponseId: z62.z.string().nullish(),
|
|
14930
|
+
store: z62.z.boolean().nullish(),
|
|
14931
|
+
user: z62.z.string().nullish(),
|
|
14932
|
+
reasoningEffort: z62.z.string().nullish(),
|
|
14933
|
+
strictJsonSchema: z62.z.boolean().nullish(),
|
|
14934
|
+
instructions: z62.z.string().nullish(),
|
|
14935
|
+
reasoningSummary: z62.z.string().nullish(),
|
|
14936
|
+
serviceTier: z62.z.enum(["auto", "flex", "priority"]).nullish(),
|
|
14937
|
+
include: z62.z.array(
|
|
14938
|
+
z62.z.enum([
|
|
14939
|
+
"reasoning.encrypted_content",
|
|
14940
|
+
"file_search_call.results",
|
|
14941
|
+
"message.output_text.logprobs"
|
|
14942
|
+
])
|
|
14943
|
+
).nullish(),
|
|
14944
|
+
textVerbosity: z62.z.enum(["low", "medium", "high"]).nullish(),
|
|
14945
|
+
promptCacheKey: z62.z.string().nullish(),
|
|
14946
|
+
safetyIdentifier: z62.z.string().nullish(),
|
|
14947
|
+
/**
|
|
14948
|
+
* Return the log probabilities of the tokens.
|
|
14949
|
+
*
|
|
14950
|
+
* Setting to true will return the log probabilities of the tokens that
|
|
14951
|
+
* were generated.
|
|
14952
|
+
*
|
|
14953
|
+
* Setting to a number will return the log probabilities of the top n
|
|
14954
|
+
* tokens that were generated.
|
|
14955
|
+
*
|
|
14956
|
+
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
14957
|
+
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
14958
|
+
*/
|
|
14959
|
+
logprobs: z62.z.union([z62.z.boolean(), z62.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
|
|
14544
14960
|
});
|
|
14545
|
-
var OpenAIProviderOptionsSchema2 =
|
|
14546
|
-
instructions:
|
|
14547
|
-
speed:
|
|
14961
|
+
var OpenAIProviderOptionsSchema2 = z62.z.object({
|
|
14962
|
+
instructions: z62.z.string().nullish(),
|
|
14963
|
+
speed: z62.z.number().min(0.25).max(4).default(1).nullish()
|
|
14548
14964
|
});
|
|
14549
14965
|
var OpenAISpeechModel2 = class {
|
|
14550
14966
|
constructor(modelId, config) {
|
|
@@ -14645,6 +15061,206 @@ var OpenAISpeechModel2 = class {
|
|
|
14645
15061
|
};
|
|
14646
15062
|
}
|
|
14647
15063
|
};
|
|
15064
|
+
var openAITranscriptionProviderOptions = z62.z.object({
|
|
15065
|
+
/**
|
|
15066
|
+
* Additional information to include in the transcription response.
|
|
15067
|
+
*/
|
|
15068
|
+
include: z62.z.array(z62.z.string()).optional(),
|
|
15069
|
+
/**
|
|
15070
|
+
* The language of the input audio in ISO-639-1 format.
|
|
15071
|
+
*/
|
|
15072
|
+
language: z62.z.string().optional(),
|
|
15073
|
+
/**
|
|
15074
|
+
* An optional text to guide the model's style or continue a previous audio segment.
|
|
15075
|
+
*/
|
|
15076
|
+
prompt: z62.z.string().optional(),
|
|
15077
|
+
/**
|
|
15078
|
+
* The sampling temperature, between 0 and 1.
|
|
15079
|
+
* @default 0
|
|
15080
|
+
*/
|
|
15081
|
+
temperature: z62.z.number().min(0).max(1).default(0).optional(),
|
|
15082
|
+
/**
|
|
15083
|
+
* The timestamp granularities to populate for this transcription.
|
|
15084
|
+
* @default ['segment']
|
|
15085
|
+
*/
|
|
15086
|
+
timestampGranularities: z62.z.array(z62.z.enum(["word", "segment"])).default(["segment"]).optional()
|
|
15087
|
+
});
|
|
15088
|
+
var languageMap2 = {
|
|
15089
|
+
afrikaans: "af",
|
|
15090
|
+
arabic: "ar",
|
|
15091
|
+
armenian: "hy",
|
|
15092
|
+
azerbaijani: "az",
|
|
15093
|
+
belarusian: "be",
|
|
15094
|
+
bosnian: "bs",
|
|
15095
|
+
bulgarian: "bg",
|
|
15096
|
+
catalan: "ca",
|
|
15097
|
+
chinese: "zh",
|
|
15098
|
+
croatian: "hr",
|
|
15099
|
+
czech: "cs",
|
|
15100
|
+
danish: "da",
|
|
15101
|
+
dutch: "nl",
|
|
15102
|
+
english: "en",
|
|
15103
|
+
estonian: "et",
|
|
15104
|
+
finnish: "fi",
|
|
15105
|
+
french: "fr",
|
|
15106
|
+
galician: "gl",
|
|
15107
|
+
german: "de",
|
|
15108
|
+
greek: "el",
|
|
15109
|
+
hebrew: "he",
|
|
15110
|
+
hindi: "hi",
|
|
15111
|
+
hungarian: "hu",
|
|
15112
|
+
icelandic: "is",
|
|
15113
|
+
indonesian: "id",
|
|
15114
|
+
italian: "it",
|
|
15115
|
+
japanese: "ja",
|
|
15116
|
+
kannada: "kn",
|
|
15117
|
+
kazakh: "kk",
|
|
15118
|
+
korean: "ko",
|
|
15119
|
+
latvian: "lv",
|
|
15120
|
+
lithuanian: "lt",
|
|
15121
|
+
macedonian: "mk",
|
|
15122
|
+
malay: "ms",
|
|
15123
|
+
marathi: "mr",
|
|
15124
|
+
maori: "mi",
|
|
15125
|
+
nepali: "ne",
|
|
15126
|
+
norwegian: "no",
|
|
15127
|
+
persian: "fa",
|
|
15128
|
+
polish: "pl",
|
|
15129
|
+
portuguese: "pt",
|
|
15130
|
+
romanian: "ro",
|
|
15131
|
+
russian: "ru",
|
|
15132
|
+
serbian: "sr",
|
|
15133
|
+
slovak: "sk",
|
|
15134
|
+
slovenian: "sl",
|
|
15135
|
+
spanish: "es",
|
|
15136
|
+
swahili: "sw",
|
|
15137
|
+
swedish: "sv",
|
|
15138
|
+
tagalog: "tl",
|
|
15139
|
+
tamil: "ta",
|
|
15140
|
+
thai: "th",
|
|
15141
|
+
turkish: "tr",
|
|
15142
|
+
ukrainian: "uk",
|
|
15143
|
+
urdu: "ur",
|
|
15144
|
+
vietnamese: "vi",
|
|
15145
|
+
welsh: "cy"
|
|
15146
|
+
};
|
|
15147
|
+
var OpenAITranscriptionModel2 = class {
|
|
15148
|
+
constructor(modelId, config) {
|
|
15149
|
+
this.modelId = modelId;
|
|
15150
|
+
this.config = config;
|
|
15151
|
+
this.specificationVersion = "v2";
|
|
15152
|
+
}
|
|
15153
|
+
get provider() {
|
|
15154
|
+
return this.config.provider;
|
|
15155
|
+
}
|
|
15156
|
+
async getArgs({
|
|
15157
|
+
audio,
|
|
15158
|
+
mediaType,
|
|
15159
|
+
providerOptions
|
|
15160
|
+
}) {
|
|
15161
|
+
const warnings = [];
|
|
15162
|
+
const openAIOptions = await parseProviderOptions2({
|
|
15163
|
+
provider: "openai",
|
|
15164
|
+
providerOptions,
|
|
15165
|
+
schema: openAITranscriptionProviderOptions
|
|
15166
|
+
});
|
|
15167
|
+
const formData = new FormData();
|
|
15168
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array2(audio)]);
|
|
15169
|
+
formData.append("model", this.modelId);
|
|
15170
|
+
formData.append("file", new File([blob], "audio", { type: mediaType }));
|
|
15171
|
+
if (openAIOptions) {
|
|
15172
|
+
const transcriptionModelOptions = {
|
|
15173
|
+
include: openAIOptions.include,
|
|
15174
|
+
language: openAIOptions.language,
|
|
15175
|
+
prompt: openAIOptions.prompt,
|
|
15176
|
+
response_format: "verbose_json",
|
|
15177
|
+
// always use verbose_json to get segments
|
|
15178
|
+
temperature: openAIOptions.temperature,
|
|
15179
|
+
timestamp_granularities: openAIOptions.timestampGranularities
|
|
15180
|
+
};
|
|
15181
|
+
for (const [key, value] of Object.entries(transcriptionModelOptions)) {
|
|
15182
|
+
if (value != null) {
|
|
15183
|
+
formData.append(key, String(value));
|
|
15184
|
+
}
|
|
15185
|
+
}
|
|
15186
|
+
}
|
|
15187
|
+
return {
|
|
15188
|
+
formData,
|
|
15189
|
+
warnings
|
|
15190
|
+
};
|
|
15191
|
+
}
|
|
15192
|
+
async doGenerate(options) {
|
|
15193
|
+
var _a16, _b, _c, _d, _e, _f, _g, _h;
|
|
15194
|
+
const currentDate = (_c = (_b = (_a16 = this.config._internal) == null ? void 0 : _a16.currentDate) == null ? void 0 : _b.call(_a16)) != null ? _c : /* @__PURE__ */ new Date();
|
|
15195
|
+
const { formData, warnings } = await this.getArgs(options);
|
|
15196
|
+
const {
|
|
15197
|
+
value: response,
|
|
15198
|
+
responseHeaders,
|
|
15199
|
+
rawValue: rawResponse
|
|
15200
|
+
} = await postFormDataToApi2({
|
|
15201
|
+
url: this.config.url({
|
|
15202
|
+
path: "/audio/transcriptions",
|
|
15203
|
+
modelId: this.modelId
|
|
15204
|
+
}),
|
|
15205
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
15206
|
+
formData,
|
|
15207
|
+
failedResponseHandler: openaiFailedResponseHandler2,
|
|
15208
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
15209
|
+
openaiTranscriptionResponseSchema2
|
|
15210
|
+
),
|
|
15211
|
+
abortSignal: options.abortSignal,
|
|
15212
|
+
fetch: this.config.fetch
|
|
15213
|
+
});
|
|
15214
|
+
const language = response.language != null && response.language in languageMap2 ? languageMap2[response.language] : void 0;
|
|
15215
|
+
return {
|
|
15216
|
+
text: response.text,
|
|
15217
|
+
segments: (_g = (_f = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
|
|
15218
|
+
text: segment.text,
|
|
15219
|
+
startSecond: segment.start,
|
|
15220
|
+
endSecond: segment.end
|
|
15221
|
+
}))) != null ? _f : (_e = response.words) == null ? void 0 : _e.map((word) => ({
|
|
15222
|
+
text: word.word,
|
|
15223
|
+
startSecond: word.start,
|
|
15224
|
+
endSecond: word.end
|
|
15225
|
+
}))) != null ? _g : [],
|
|
15226
|
+
language,
|
|
15227
|
+
durationInSeconds: (_h = response.duration) != null ? _h : void 0,
|
|
15228
|
+
warnings,
|
|
15229
|
+
response: {
|
|
15230
|
+
timestamp: currentDate,
|
|
15231
|
+
modelId: this.modelId,
|
|
15232
|
+
headers: responseHeaders,
|
|
15233
|
+
body: rawResponse
|
|
15234
|
+
}
|
|
15235
|
+
};
|
|
15236
|
+
}
|
|
15237
|
+
};
|
|
15238
|
+
var openaiTranscriptionResponseSchema2 = z62.z.object({
|
|
15239
|
+
text: z62.z.string(),
|
|
15240
|
+
language: z62.z.string().nullish(),
|
|
15241
|
+
duration: z62.z.number().nullish(),
|
|
15242
|
+
words: z62.z.array(
|
|
15243
|
+
z62.z.object({
|
|
15244
|
+
word: z62.z.string(),
|
|
15245
|
+
start: z62.z.number(),
|
|
15246
|
+
end: z62.z.number()
|
|
15247
|
+
})
|
|
15248
|
+
).nullish(),
|
|
15249
|
+
segments: z62.z.array(
|
|
15250
|
+
z62.z.object({
|
|
15251
|
+
id: z62.z.number(),
|
|
15252
|
+
seek: z62.z.number(),
|
|
15253
|
+
start: z62.z.number(),
|
|
15254
|
+
end: z62.z.number(),
|
|
15255
|
+
text: z62.z.string(),
|
|
15256
|
+
tokens: z62.z.array(z62.z.number()),
|
|
15257
|
+
temperature: z62.z.number(),
|
|
15258
|
+
avg_logprob: z62.z.number(),
|
|
15259
|
+
compression_ratio: z62.z.number(),
|
|
15260
|
+
no_speech_prob: z62.z.number()
|
|
15261
|
+
})
|
|
15262
|
+
).nullish()
|
|
15263
|
+
});
|
|
14648
15264
|
function createOpenAI2(options = {}) {
|
|
14649
15265
|
var _a16, _b;
|
|
14650
15266
|
const baseURL = (_a16 = withoutTrailingSlash2(options.baseURL)) != null ? _a16 : "https://api.openai.com/v1";
|
|
@@ -14708,7 +15324,8 @@ function createOpenAI2(options = {}) {
|
|
|
14708
15324
|
provider: `${providerName}.responses`,
|
|
14709
15325
|
url: ({ path }) => `${baseURL}${path}`,
|
|
14710
15326
|
headers: getHeaders,
|
|
14711
|
-
fetch: options.fetch
|
|
15327
|
+
fetch: options.fetch,
|
|
15328
|
+
fileIdPrefixes: ["file-"]
|
|
14712
15329
|
});
|
|
14713
15330
|
};
|
|
14714
15331
|
const provider = function(modelId) {
|
|
@@ -14875,7 +15492,7 @@ var defaultOpenAICompatibleErrorStructure = {
|
|
|
14875
15492
|
errorSchema: openaiCompatibleErrorDataSchema,
|
|
14876
15493
|
errorToMessage: (data) => data.error.message
|
|
14877
15494
|
};
|
|
14878
|
-
function
|
|
15495
|
+
function prepareTools8({
|
|
14879
15496
|
mode,
|
|
14880
15497
|
structuredOutputs
|
|
14881
15498
|
}) {
|
|
@@ -15011,7 +15628,7 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
15011
15628
|
};
|
|
15012
15629
|
switch (type) {
|
|
15013
15630
|
case "regular": {
|
|
15014
|
-
const { tools, tool_choice, toolWarnings } =
|
|
15631
|
+
const { tools, tool_choice, toolWarnings } = prepareTools8({
|
|
15015
15632
|
mode,
|
|
15016
15633
|
structuredOutputs: this.supportsStructuredOutputs
|
|
15017
15634
|
});
|
|
@@ -15649,124 +16266,126 @@ function createXai(options = {}) {
|
|
|
15649
16266
|
return provider;
|
|
15650
16267
|
}
|
|
15651
16268
|
var xai = createXai();
|
|
15652
|
-
|
|
16269
|
+
z62.z.object({
|
|
15653
16270
|
/**
|
|
15654
16271
|
* A unique identifier representing your end-user, which can help the provider to
|
|
15655
16272
|
* monitor and detect abuse.
|
|
15656
16273
|
*/
|
|
15657
|
-
user:
|
|
16274
|
+
user: z62.z.string().optional(),
|
|
15658
16275
|
/**
|
|
15659
16276
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
15660
16277
|
*/
|
|
15661
|
-
reasoningEffort:
|
|
16278
|
+
reasoningEffort: z62.z.string().optional()
|
|
15662
16279
|
});
|
|
15663
|
-
var openaiCompatibleErrorDataSchema2 =
|
|
15664
|
-
error:
|
|
15665
|
-
message:
|
|
16280
|
+
var openaiCompatibleErrorDataSchema2 = z62.z.object({
|
|
16281
|
+
error: z62.z.object({
|
|
16282
|
+
message: z62.z.string(),
|
|
15666
16283
|
// The additional information below is handled loosely to support
|
|
15667
16284
|
// OpenAI-compatible providers that have slightly different error
|
|
15668
16285
|
// responses:
|
|
15669
|
-
type:
|
|
15670
|
-
param:
|
|
15671
|
-
code:
|
|
16286
|
+
type: z62.z.string().nullish(),
|
|
16287
|
+
param: z62.z.any().nullish(),
|
|
16288
|
+
code: z62.z.union([z62.z.string(), z62.z.number()]).nullish()
|
|
15672
16289
|
})
|
|
15673
16290
|
});
|
|
15674
16291
|
var defaultOpenAICompatibleErrorStructure2 = {
|
|
15675
16292
|
errorSchema: openaiCompatibleErrorDataSchema2,
|
|
15676
16293
|
errorToMessage: (data) => data.error.message
|
|
15677
16294
|
};
|
|
15678
|
-
var openaiCompatibleTokenUsageSchema2 =
|
|
15679
|
-
prompt_tokens:
|
|
15680
|
-
completion_tokens:
|
|
15681
|
-
total_tokens:
|
|
15682
|
-
prompt_tokens_details:
|
|
15683
|
-
cached_tokens:
|
|
16295
|
+
var openaiCompatibleTokenUsageSchema2 = z62.z.object({
|
|
16296
|
+
prompt_tokens: z62.z.number().nullish(),
|
|
16297
|
+
completion_tokens: z62.z.number().nullish(),
|
|
16298
|
+
total_tokens: z62.z.number().nullish(),
|
|
16299
|
+
prompt_tokens_details: z62.z.object({
|
|
16300
|
+
cached_tokens: z62.z.number().nullish()
|
|
15684
16301
|
}).nullish(),
|
|
15685
|
-
completion_tokens_details:
|
|
15686
|
-
reasoning_tokens:
|
|
15687
|
-
accepted_prediction_tokens:
|
|
15688
|
-
rejected_prediction_tokens:
|
|
16302
|
+
completion_tokens_details: z62.z.object({
|
|
16303
|
+
reasoning_tokens: z62.z.number().nullish(),
|
|
16304
|
+
accepted_prediction_tokens: z62.z.number().nullish(),
|
|
16305
|
+
rejected_prediction_tokens: z62.z.number().nullish()
|
|
15689
16306
|
}).nullish()
|
|
15690
16307
|
}).nullish();
|
|
15691
|
-
|
|
15692
|
-
id:
|
|
15693
|
-
created:
|
|
15694
|
-
model:
|
|
15695
|
-
choices:
|
|
15696
|
-
|
|
15697
|
-
message:
|
|
15698
|
-
role:
|
|
15699
|
-
content:
|
|
15700
|
-
reasoning_content:
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
16308
|
+
z62.z.object({
|
|
16309
|
+
id: z62.z.string().nullish(),
|
|
16310
|
+
created: z62.z.number().nullish(),
|
|
16311
|
+
model: z62.z.string().nullish(),
|
|
16312
|
+
choices: z62.z.array(
|
|
16313
|
+
z62.z.object({
|
|
16314
|
+
message: z62.z.object({
|
|
16315
|
+
role: z62.z.literal("assistant").nullish(),
|
|
16316
|
+
content: z62.z.string().nullish(),
|
|
16317
|
+
reasoning_content: z62.z.string().nullish(),
|
|
16318
|
+
reasoning: z62.z.string().nullish(),
|
|
16319
|
+
tool_calls: z62.z.array(
|
|
16320
|
+
z62.z.object({
|
|
16321
|
+
id: z62.z.string().nullish(),
|
|
16322
|
+
function: z62.z.object({
|
|
16323
|
+
name: z62.z.string(),
|
|
16324
|
+
arguments: z62.z.string()
|
|
15707
16325
|
})
|
|
15708
16326
|
})
|
|
15709
16327
|
).nullish()
|
|
15710
16328
|
}),
|
|
15711
|
-
finish_reason:
|
|
16329
|
+
finish_reason: z62.z.string().nullish()
|
|
15712
16330
|
})
|
|
15713
16331
|
),
|
|
15714
16332
|
usage: openaiCompatibleTokenUsageSchema2
|
|
15715
16333
|
});
|
|
15716
|
-
|
|
16334
|
+
z62.z.object({
|
|
15717
16335
|
/**
|
|
15718
16336
|
* Echo back the prompt in addition to the completion.
|
|
15719
16337
|
*/
|
|
15720
|
-
echo:
|
|
16338
|
+
echo: z62.z.boolean().optional(),
|
|
15721
16339
|
/**
|
|
15722
16340
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
15723
16341
|
*
|
|
15724
16342
|
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
15725
16343
|
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
15726
16344
|
*/
|
|
15727
|
-
logitBias:
|
|
16345
|
+
logitBias: z62.z.record(z62.z.string(), z62.z.number()).optional(),
|
|
15728
16346
|
/**
|
|
15729
16347
|
* The suffix that comes after a completion of inserted text.
|
|
15730
16348
|
*/
|
|
15731
|
-
suffix:
|
|
16349
|
+
suffix: z62.z.string().optional(),
|
|
15732
16350
|
/**
|
|
15733
16351
|
* A unique identifier representing your end-user, which can help providers to
|
|
15734
16352
|
* monitor and detect abuse.
|
|
15735
16353
|
*/
|
|
15736
|
-
user:
|
|
16354
|
+
user: z62.z.string().optional()
|
|
15737
16355
|
});
|
|
15738
|
-
var usageSchema4 =
|
|
15739
|
-
prompt_tokens:
|
|
15740
|
-
completion_tokens:
|
|
15741
|
-
total_tokens:
|
|
16356
|
+
var usageSchema4 = z62.z.object({
|
|
16357
|
+
prompt_tokens: z62.z.number(),
|
|
16358
|
+
completion_tokens: z62.z.number(),
|
|
16359
|
+
total_tokens: z62.z.number()
|
|
15742
16360
|
});
|
|
15743
|
-
|
|
15744
|
-
id:
|
|
15745
|
-
created:
|
|
15746
|
-
model:
|
|
15747
|
-
choices:
|
|
15748
|
-
|
|
15749
|
-
text:
|
|
15750
|
-
finish_reason:
|
|
16361
|
+
z62.z.object({
|
|
16362
|
+
id: z62.z.string().nullish(),
|
|
16363
|
+
created: z62.z.number().nullish(),
|
|
16364
|
+
model: z62.z.string().nullish(),
|
|
16365
|
+
choices: z62.z.array(
|
|
16366
|
+
z62.z.object({
|
|
16367
|
+
text: z62.z.string(),
|
|
16368
|
+
finish_reason: z62.z.string()
|
|
15751
16369
|
})
|
|
15752
16370
|
),
|
|
15753
16371
|
usage: usageSchema4.nullish()
|
|
15754
16372
|
});
|
|
15755
|
-
|
|
16373
|
+
z62.z.object({
|
|
15756
16374
|
/**
|
|
15757
16375
|
* The number of dimensions the resulting output embeddings should have.
|
|
15758
16376
|
* Only supported in text-embedding-3 and later models.
|
|
15759
16377
|
*/
|
|
15760
|
-
dimensions:
|
|
16378
|
+
dimensions: z62.z.number().optional(),
|
|
15761
16379
|
/**
|
|
15762
16380
|
* A unique identifier representing your end-user, which can help providers to
|
|
15763
16381
|
* monitor and detect abuse.
|
|
15764
16382
|
*/
|
|
15765
|
-
user:
|
|
16383
|
+
user: z62.z.string().optional()
|
|
15766
16384
|
});
|
|
15767
|
-
|
|
15768
|
-
data:
|
|
15769
|
-
usage:
|
|
16385
|
+
z62.z.object({
|
|
16386
|
+
data: z62.z.array(z62.z.object({ embedding: z62.z.array(z62.z.number()) })),
|
|
16387
|
+
usage: z62.z.object({ prompt_tokens: z62.z.number() }).nullish(),
|
|
16388
|
+
providerMetadata: z62.z.record(z62.z.string(), z62.z.record(z62.z.string(), z62.z.any())).optional()
|
|
15770
16389
|
});
|
|
15771
16390
|
var OpenAICompatibleImageModel2 = class {
|
|
15772
16391
|
constructor(modelId, config) {
|
|
@@ -15835,8 +16454,8 @@ var OpenAICompatibleImageModel2 = class {
|
|
|
15835
16454
|
};
|
|
15836
16455
|
}
|
|
15837
16456
|
};
|
|
15838
|
-
var openaiCompatibleImageResponseSchema2 =
|
|
15839
|
-
data:
|
|
16457
|
+
var openaiCompatibleImageResponseSchema2 = z62.z.object({
|
|
16458
|
+
data: z62.z.array(z62.z.object({ b64_json: z62.z.string() }))
|
|
15840
16459
|
});
|
|
15841
16460
|
function convertToXaiChatMessages(prompt) {
|
|
15842
16461
|
const messages = [];
|
|
@@ -15965,86 +16584,86 @@ function mapXaiFinishReason(finishReason) {
|
|
|
15965
16584
|
return "unknown";
|
|
15966
16585
|
}
|
|
15967
16586
|
}
|
|
15968
|
-
var webSourceSchema =
|
|
15969
|
-
type:
|
|
15970
|
-
country:
|
|
15971
|
-
excludedWebsites:
|
|
15972
|
-
allowedWebsites:
|
|
15973
|
-
safeSearch:
|
|
16587
|
+
var webSourceSchema = z62.z.object({
|
|
16588
|
+
type: z62.z.literal("web"),
|
|
16589
|
+
country: z62.z.string().length(2).optional(),
|
|
16590
|
+
excludedWebsites: z62.z.array(z62.z.string()).max(5).optional(),
|
|
16591
|
+
allowedWebsites: z62.z.array(z62.z.string()).max(5).optional(),
|
|
16592
|
+
safeSearch: z62.z.boolean().optional()
|
|
15974
16593
|
});
|
|
15975
|
-
var xSourceSchema =
|
|
15976
|
-
type:
|
|
15977
|
-
xHandles:
|
|
16594
|
+
var xSourceSchema = z62.z.object({
|
|
16595
|
+
type: z62.z.literal("x"),
|
|
16596
|
+
xHandles: z62.z.array(z62.z.string()).optional()
|
|
15978
16597
|
});
|
|
15979
|
-
var newsSourceSchema =
|
|
15980
|
-
type:
|
|
15981
|
-
country:
|
|
15982
|
-
excludedWebsites:
|
|
15983
|
-
safeSearch:
|
|
16598
|
+
var newsSourceSchema = z62.z.object({
|
|
16599
|
+
type: z62.z.literal("news"),
|
|
16600
|
+
country: z62.z.string().length(2).optional(),
|
|
16601
|
+
excludedWebsites: z62.z.array(z62.z.string()).max(5).optional(),
|
|
16602
|
+
safeSearch: z62.z.boolean().optional()
|
|
15984
16603
|
});
|
|
15985
|
-
var rssSourceSchema =
|
|
15986
|
-
type:
|
|
15987
|
-
links:
|
|
16604
|
+
var rssSourceSchema = z62.z.object({
|
|
16605
|
+
type: z62.z.literal("rss"),
|
|
16606
|
+
links: z62.z.array(z62.z.string().url()).max(1)
|
|
15988
16607
|
// currently only supports one RSS link
|
|
15989
16608
|
});
|
|
15990
|
-
var searchSourceSchema =
|
|
16609
|
+
var searchSourceSchema = z62.z.discriminatedUnion("type", [
|
|
15991
16610
|
webSourceSchema,
|
|
15992
16611
|
xSourceSchema,
|
|
15993
16612
|
newsSourceSchema,
|
|
15994
16613
|
rssSourceSchema
|
|
15995
16614
|
]);
|
|
15996
|
-
var xaiProviderOptions =
|
|
16615
|
+
var xaiProviderOptions = z62.z.object({
|
|
15997
16616
|
/**
|
|
15998
16617
|
* reasoning effort for reasoning models
|
|
15999
16618
|
* only supported by grok-3-mini and grok-3-mini-fast models
|
|
16000
16619
|
*/
|
|
16001
|
-
reasoningEffort:
|
|
16002
|
-
searchParameters:
|
|
16620
|
+
reasoningEffort: z62.z.enum(["low", "high"]).optional(),
|
|
16621
|
+
searchParameters: z62.z.object({
|
|
16003
16622
|
/**
|
|
16004
16623
|
* search mode preference
|
|
16005
16624
|
* - "off": disables search completely
|
|
16006
16625
|
* - "auto": model decides whether to search (default)
|
|
16007
16626
|
* - "on": always enables search
|
|
16008
16627
|
*/
|
|
16009
|
-
mode:
|
|
16628
|
+
mode: z62.z.enum(["off", "auto", "on"]),
|
|
16010
16629
|
/**
|
|
16011
16630
|
* whether to return citations in the response
|
|
16012
16631
|
* defaults to true
|
|
16013
16632
|
*/
|
|
16014
|
-
returnCitations:
|
|
16633
|
+
returnCitations: z62.z.boolean().optional(),
|
|
16015
16634
|
/**
|
|
16016
16635
|
* start date for search data (ISO8601 format: YYYY-MM-DD)
|
|
16017
16636
|
*/
|
|
16018
|
-
fromDate:
|
|
16637
|
+
fromDate: z62.z.string().optional(),
|
|
16019
16638
|
/**
|
|
16020
16639
|
* end date for search data (ISO8601 format: YYYY-MM-DD)
|
|
16021
16640
|
*/
|
|
16022
|
-
toDate:
|
|
16641
|
+
toDate: z62.z.string().optional(),
|
|
16023
16642
|
/**
|
|
16024
16643
|
* maximum number of search results to consider
|
|
16025
16644
|
* defaults to 20
|
|
16026
16645
|
*/
|
|
16027
|
-
maxSearchResults:
|
|
16646
|
+
maxSearchResults: z62.z.number().min(1).max(50).optional(),
|
|
16028
16647
|
/**
|
|
16029
16648
|
* data sources to search from
|
|
16030
16649
|
* defaults to ["web", "x"] if not specified
|
|
16031
16650
|
*/
|
|
16032
|
-
sources:
|
|
16651
|
+
sources: z62.z.array(searchSourceSchema).optional()
|
|
16033
16652
|
}).optional()
|
|
16034
16653
|
});
|
|
16035
|
-
var xaiErrorDataSchema =
|
|
16036
|
-
error:
|
|
16037
|
-
message:
|
|
16038
|
-
type:
|
|
16039
|
-
param:
|
|
16040
|
-
code:
|
|
16654
|
+
var xaiErrorDataSchema = z62.z.object({
|
|
16655
|
+
error: z62.z.object({
|
|
16656
|
+
message: z62.z.string(),
|
|
16657
|
+
type: z62.z.string().nullish(),
|
|
16658
|
+
param: z62.z.any().nullish(),
|
|
16659
|
+
code: z62.z.union([z62.z.string(), z62.z.number()]).nullish()
|
|
16041
16660
|
})
|
|
16042
16661
|
});
|
|
16043
16662
|
var xaiFailedResponseHandler = createJsonErrorResponseHandler2({
|
|
16044
16663
|
errorSchema: xaiErrorDataSchema,
|
|
16045
16664
|
errorToMessage: (data) => data.error.message
|
|
16046
16665
|
});
|
|
16047
|
-
function
|
|
16666
|
+
function prepareTools9({
|
|
16048
16667
|
tools,
|
|
16049
16668
|
toolChoice
|
|
16050
16669
|
}) {
|
|
@@ -16166,7 +16785,7 @@ var XaiChatLanguageModel = class {
|
|
|
16166
16785
|
tools: xaiTools,
|
|
16167
16786
|
toolChoice: xaiToolChoice,
|
|
16168
16787
|
toolWarnings
|
|
16169
|
-
} =
|
|
16788
|
+
} = prepareTools9({
|
|
16170
16789
|
tools,
|
|
16171
16790
|
toolChoice
|
|
16172
16791
|
});
|
|
@@ -16460,70 +17079,70 @@ var XaiChatLanguageModel = class {
|
|
|
16460
17079
|
};
|
|
16461
17080
|
}
|
|
16462
17081
|
};
|
|
16463
|
-
var xaiUsageSchema =
|
|
16464
|
-
prompt_tokens:
|
|
16465
|
-
completion_tokens:
|
|
16466
|
-
total_tokens:
|
|
16467
|
-
completion_tokens_details:
|
|
16468
|
-
reasoning_tokens:
|
|
17082
|
+
var xaiUsageSchema = z62.z.object({
|
|
17083
|
+
prompt_tokens: z62.z.number(),
|
|
17084
|
+
completion_tokens: z62.z.number(),
|
|
17085
|
+
total_tokens: z62.z.number(),
|
|
17086
|
+
completion_tokens_details: z62.z.object({
|
|
17087
|
+
reasoning_tokens: z62.z.number().nullish()
|
|
16469
17088
|
}).nullish()
|
|
16470
17089
|
});
|
|
16471
|
-
var xaiChatResponseSchema =
|
|
16472
|
-
id:
|
|
16473
|
-
created:
|
|
16474
|
-
model:
|
|
16475
|
-
choices:
|
|
16476
|
-
|
|
16477
|
-
message:
|
|
16478
|
-
role:
|
|
16479
|
-
content:
|
|
16480
|
-
reasoning_content:
|
|
16481
|
-
tool_calls:
|
|
16482
|
-
|
|
16483
|
-
id:
|
|
16484
|
-
type:
|
|
16485
|
-
function:
|
|
16486
|
-
name:
|
|
16487
|
-
arguments:
|
|
17090
|
+
var xaiChatResponseSchema = z62.z.object({
|
|
17091
|
+
id: z62.z.string().nullish(),
|
|
17092
|
+
created: z62.z.number().nullish(),
|
|
17093
|
+
model: z62.z.string().nullish(),
|
|
17094
|
+
choices: z62.z.array(
|
|
17095
|
+
z62.z.object({
|
|
17096
|
+
message: z62.z.object({
|
|
17097
|
+
role: z62.z.literal("assistant"),
|
|
17098
|
+
content: z62.z.string().nullish(),
|
|
17099
|
+
reasoning_content: z62.z.string().nullish(),
|
|
17100
|
+
tool_calls: z62.z.array(
|
|
17101
|
+
z62.z.object({
|
|
17102
|
+
id: z62.z.string(),
|
|
17103
|
+
type: z62.z.literal("function"),
|
|
17104
|
+
function: z62.z.object({
|
|
17105
|
+
name: z62.z.string(),
|
|
17106
|
+
arguments: z62.z.string()
|
|
16488
17107
|
})
|
|
16489
17108
|
})
|
|
16490
17109
|
).nullish()
|
|
16491
17110
|
}),
|
|
16492
|
-
index:
|
|
16493
|
-
finish_reason:
|
|
17111
|
+
index: z62.z.number(),
|
|
17112
|
+
finish_reason: z62.z.string().nullish()
|
|
16494
17113
|
})
|
|
16495
17114
|
),
|
|
16496
|
-
object:
|
|
17115
|
+
object: z62.z.literal("chat.completion"),
|
|
16497
17116
|
usage: xaiUsageSchema,
|
|
16498
|
-
citations:
|
|
17117
|
+
citations: z62.z.array(z62.z.string().url()).nullish()
|
|
16499
17118
|
});
|
|
16500
|
-
var xaiChatChunkSchema =
|
|
16501
|
-
id:
|
|
16502
|
-
created:
|
|
16503
|
-
model:
|
|
16504
|
-
choices:
|
|
16505
|
-
|
|
16506
|
-
delta:
|
|
16507
|
-
role:
|
|
16508
|
-
content:
|
|
16509
|
-
reasoning_content:
|
|
16510
|
-
tool_calls:
|
|
16511
|
-
|
|
16512
|
-
id:
|
|
16513
|
-
type:
|
|
16514
|
-
function:
|
|
16515
|
-
name:
|
|
16516
|
-
arguments:
|
|
17119
|
+
var xaiChatChunkSchema = z62.z.object({
|
|
17120
|
+
id: z62.z.string().nullish(),
|
|
17121
|
+
created: z62.z.number().nullish(),
|
|
17122
|
+
model: z62.z.string().nullish(),
|
|
17123
|
+
choices: z62.z.array(
|
|
17124
|
+
z62.z.object({
|
|
17125
|
+
delta: z62.z.object({
|
|
17126
|
+
role: z62.z.enum(["assistant"]).optional(),
|
|
17127
|
+
content: z62.z.string().nullish(),
|
|
17128
|
+
reasoning_content: z62.z.string().nullish(),
|
|
17129
|
+
tool_calls: z62.z.array(
|
|
17130
|
+
z62.z.object({
|
|
17131
|
+
id: z62.z.string(),
|
|
17132
|
+
type: z62.z.literal("function"),
|
|
17133
|
+
function: z62.z.object({
|
|
17134
|
+
name: z62.z.string(),
|
|
17135
|
+
arguments: z62.z.string()
|
|
16517
17136
|
})
|
|
16518
17137
|
})
|
|
16519
17138
|
).nullish()
|
|
16520
17139
|
}),
|
|
16521
|
-
finish_reason:
|
|
16522
|
-
index:
|
|
17140
|
+
finish_reason: z62.z.string().nullish(),
|
|
17141
|
+
index: z62.z.number()
|
|
16523
17142
|
})
|
|
16524
17143
|
),
|
|
16525
17144
|
usage: xaiUsageSchema.nullish(),
|
|
16526
|
-
citations:
|
|
17145
|
+
citations: z62.z.array(z62.z.string().url()).nullish()
|
|
16527
17146
|
});
|
|
16528
17147
|
var xaiErrorStructure2 = {
|
|
16529
17148
|
errorSchema: xaiErrorDataSchema,
|
|
@@ -16985,5 +17604,5 @@ exports.streamGenerateHandler = streamGenerateHandler;
|
|
|
16985
17604
|
exports.streamVNextGenerateHandler = streamVNextGenerateHandler;
|
|
16986
17605
|
exports.streamVNextUIMessageHandler = streamVNextUIMessageHandler;
|
|
16987
17606
|
exports.updateAgentModelHandler = updateAgentModelHandler;
|
|
16988
|
-
//# sourceMappingURL=chunk-
|
|
16989
|
-
//# sourceMappingURL=chunk-
|
|
17607
|
+
//# sourceMappingURL=chunk-WPGDPPF2.cjs.map
|
|
17608
|
+
//# sourceMappingURL=chunk-WPGDPPF2.cjs.map
|