@ai-sdk/openai 1.3.7 → 2.0.0-canary.1
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/CHANGELOG.md +17 -3
- package/dist/index.d.mts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +122 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -122
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +13 -13
- package/internal/dist/index.d.ts +13 -13
- package/internal/dist/index.js +3 -3
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +3 -3
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -360,7 +360,7 @@ function prepareTools({
|
|
|
360
360
|
// src/openai-chat-language-model.ts
|
|
361
361
|
var OpenAIChatLanguageModel = class {
|
|
362
362
|
constructor(modelId, settings, config) {
|
|
363
|
-
this.specificationVersion = "
|
|
363
|
+
this.specificationVersion = "v2";
|
|
364
364
|
this.modelId = modelId;
|
|
365
365
|
this.settings = settings;
|
|
366
366
|
this.config = config;
|
|
@@ -1183,7 +1183,7 @@ function mapOpenAICompletionLogProbs(logprobs) {
|
|
|
1183
1183
|
// src/openai-completion-language-model.ts
|
|
1184
1184
|
var OpenAICompletionLanguageModel = class {
|
|
1185
1185
|
constructor(modelId, settings, config) {
|
|
1186
|
-
this.specificationVersion = "
|
|
1186
|
+
this.specificationVersion = "v2";
|
|
1187
1187
|
this.defaultObjectGenerationMode = void 0;
|
|
1188
1188
|
this.modelId = modelId;
|
|
1189
1189
|
this.settings = settings;
|
|
@@ -1611,6 +1611,27 @@ var openaiImageResponseSchema = z5.object({
|
|
|
1611
1611
|
data: z5.array(z5.object({ b64_json: z5.string() }))
|
|
1612
1612
|
});
|
|
1613
1613
|
|
|
1614
|
+
// src/openai-tools.ts
|
|
1615
|
+
import { z as z6 } from "zod";
|
|
1616
|
+
var WebSearchPreviewParameters = z6.object({});
|
|
1617
|
+
function webSearchPreviewTool({
|
|
1618
|
+
searchContextSize,
|
|
1619
|
+
userLocation
|
|
1620
|
+
} = {}) {
|
|
1621
|
+
return {
|
|
1622
|
+
type: "provider-defined",
|
|
1623
|
+
id: "openai.web_search_preview",
|
|
1624
|
+
args: {
|
|
1625
|
+
searchContextSize,
|
|
1626
|
+
userLocation
|
|
1627
|
+
},
|
|
1628
|
+
parameters: WebSearchPreviewParameters
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
var openaiTools = {
|
|
1632
|
+
webSearchPreview: webSearchPreviewTool
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1614
1635
|
// src/responses/openai-responses-language-model.ts
|
|
1615
1636
|
import {
|
|
1616
1637
|
combineHeaders as combineHeaders5,
|
|
@@ -1620,7 +1641,7 @@ import {
|
|
|
1620
1641
|
parseProviderOptions,
|
|
1621
1642
|
postJsonToApi as postJsonToApi5
|
|
1622
1643
|
} from "@ai-sdk/provider-utils";
|
|
1623
|
-
import { z as
|
|
1644
|
+
import { z as z7 } from "zod";
|
|
1624
1645
|
|
|
1625
1646
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1626
1647
|
import {
|
|
@@ -1850,7 +1871,7 @@ function prepareResponsesTools({
|
|
|
1850
1871
|
// src/responses/openai-responses-language-model.ts
|
|
1851
1872
|
var OpenAIResponsesLanguageModel = class {
|
|
1852
1873
|
constructor(modelId, config) {
|
|
1853
|
-
this.specificationVersion = "
|
|
1874
|
+
this.specificationVersion = "v2";
|
|
1854
1875
|
this.defaultObjectGenerationMode = "json";
|
|
1855
1876
|
this.modelId = modelId;
|
|
1856
1877
|
this.config = config;
|
|
@@ -2040,49 +2061,49 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2040
2061
|
body,
|
|
2041
2062
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2042
2063
|
successfulResponseHandler: createJsonResponseHandler5(
|
|
2043
|
-
|
|
2044
|
-
id:
|
|
2045
|
-
created_at:
|
|
2046
|
-
model:
|
|
2047
|
-
output:
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
type:
|
|
2051
|
-
role:
|
|
2052
|
-
content:
|
|
2053
|
-
|
|
2054
|
-
type:
|
|
2055
|
-
text:
|
|
2056
|
-
annotations:
|
|
2057
|
-
|
|
2058
|
-
type:
|
|
2059
|
-
start_index:
|
|
2060
|
-
end_index:
|
|
2061
|
-
url:
|
|
2062
|
-
title:
|
|
2064
|
+
z7.object({
|
|
2065
|
+
id: z7.string(),
|
|
2066
|
+
created_at: z7.number(),
|
|
2067
|
+
model: z7.string(),
|
|
2068
|
+
output: z7.array(
|
|
2069
|
+
z7.discriminatedUnion("type", [
|
|
2070
|
+
z7.object({
|
|
2071
|
+
type: z7.literal("message"),
|
|
2072
|
+
role: z7.literal("assistant"),
|
|
2073
|
+
content: z7.array(
|
|
2074
|
+
z7.object({
|
|
2075
|
+
type: z7.literal("output_text"),
|
|
2076
|
+
text: z7.string(),
|
|
2077
|
+
annotations: z7.array(
|
|
2078
|
+
z7.object({
|
|
2079
|
+
type: z7.literal("url_citation"),
|
|
2080
|
+
start_index: z7.number(),
|
|
2081
|
+
end_index: z7.number(),
|
|
2082
|
+
url: z7.string(),
|
|
2083
|
+
title: z7.string()
|
|
2063
2084
|
})
|
|
2064
2085
|
)
|
|
2065
2086
|
})
|
|
2066
2087
|
)
|
|
2067
2088
|
}),
|
|
2068
|
-
|
|
2069
|
-
type:
|
|
2070
|
-
call_id:
|
|
2071
|
-
name:
|
|
2072
|
-
arguments:
|
|
2089
|
+
z7.object({
|
|
2090
|
+
type: z7.literal("function_call"),
|
|
2091
|
+
call_id: z7.string(),
|
|
2092
|
+
name: z7.string(),
|
|
2093
|
+
arguments: z7.string()
|
|
2073
2094
|
}),
|
|
2074
|
-
|
|
2075
|
-
type:
|
|
2095
|
+
z7.object({
|
|
2096
|
+
type: z7.literal("web_search_call")
|
|
2076
2097
|
}),
|
|
2077
|
-
|
|
2078
|
-
type:
|
|
2098
|
+
z7.object({
|
|
2099
|
+
type: z7.literal("computer_call")
|
|
2079
2100
|
}),
|
|
2080
|
-
|
|
2081
|
-
type:
|
|
2101
|
+
z7.object({
|
|
2102
|
+
type: z7.literal("reasoning")
|
|
2082
2103
|
})
|
|
2083
2104
|
])
|
|
2084
2105
|
),
|
|
2085
|
-
incomplete_details:
|
|
2106
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullable(),
|
|
2086
2107
|
usage: usageSchema
|
|
2087
2108
|
})
|
|
2088
2109
|
),
|
|
@@ -2280,79 +2301,79 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2280
2301
|
};
|
|
2281
2302
|
}
|
|
2282
2303
|
};
|
|
2283
|
-
var usageSchema =
|
|
2284
|
-
input_tokens:
|
|
2285
|
-
input_tokens_details:
|
|
2286
|
-
output_tokens:
|
|
2287
|
-
output_tokens_details:
|
|
2304
|
+
var usageSchema = z7.object({
|
|
2305
|
+
input_tokens: z7.number(),
|
|
2306
|
+
input_tokens_details: z7.object({ cached_tokens: z7.number().nullish() }).nullish(),
|
|
2307
|
+
output_tokens: z7.number(),
|
|
2308
|
+
output_tokens_details: z7.object({ reasoning_tokens: z7.number().nullish() }).nullish()
|
|
2288
2309
|
});
|
|
2289
|
-
var textDeltaChunkSchema =
|
|
2290
|
-
type:
|
|
2291
|
-
delta:
|
|
2310
|
+
var textDeltaChunkSchema = z7.object({
|
|
2311
|
+
type: z7.literal("response.output_text.delta"),
|
|
2312
|
+
delta: z7.string()
|
|
2292
2313
|
});
|
|
2293
|
-
var responseFinishedChunkSchema =
|
|
2294
|
-
type:
|
|
2295
|
-
response:
|
|
2296
|
-
incomplete_details:
|
|
2314
|
+
var responseFinishedChunkSchema = z7.object({
|
|
2315
|
+
type: z7.enum(["response.completed", "response.incomplete"]),
|
|
2316
|
+
response: z7.object({
|
|
2317
|
+
incomplete_details: z7.object({ reason: z7.string() }).nullish(),
|
|
2297
2318
|
usage: usageSchema
|
|
2298
2319
|
})
|
|
2299
2320
|
});
|
|
2300
|
-
var responseCreatedChunkSchema =
|
|
2301
|
-
type:
|
|
2302
|
-
response:
|
|
2303
|
-
id:
|
|
2304
|
-
created_at:
|
|
2305
|
-
model:
|
|
2321
|
+
var responseCreatedChunkSchema = z7.object({
|
|
2322
|
+
type: z7.literal("response.created"),
|
|
2323
|
+
response: z7.object({
|
|
2324
|
+
id: z7.string(),
|
|
2325
|
+
created_at: z7.number(),
|
|
2326
|
+
model: z7.string()
|
|
2306
2327
|
})
|
|
2307
2328
|
});
|
|
2308
|
-
var responseOutputItemDoneSchema =
|
|
2309
|
-
type:
|
|
2310
|
-
output_index:
|
|
2311
|
-
item:
|
|
2312
|
-
|
|
2313
|
-
type:
|
|
2329
|
+
var responseOutputItemDoneSchema = z7.object({
|
|
2330
|
+
type: z7.literal("response.output_item.done"),
|
|
2331
|
+
output_index: z7.number(),
|
|
2332
|
+
item: z7.discriminatedUnion("type", [
|
|
2333
|
+
z7.object({
|
|
2334
|
+
type: z7.literal("message")
|
|
2314
2335
|
}),
|
|
2315
|
-
|
|
2316
|
-
type:
|
|
2317
|
-
id:
|
|
2318
|
-
call_id:
|
|
2319
|
-
name:
|
|
2320
|
-
arguments:
|
|
2321
|
-
status:
|
|
2336
|
+
z7.object({
|
|
2337
|
+
type: z7.literal("function_call"),
|
|
2338
|
+
id: z7.string(),
|
|
2339
|
+
call_id: z7.string(),
|
|
2340
|
+
name: z7.string(),
|
|
2341
|
+
arguments: z7.string(),
|
|
2342
|
+
status: z7.literal("completed")
|
|
2322
2343
|
})
|
|
2323
2344
|
])
|
|
2324
2345
|
});
|
|
2325
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2326
|
-
type:
|
|
2327
|
-
item_id:
|
|
2328
|
-
output_index:
|
|
2329
|
-
delta:
|
|
2346
|
+
var responseFunctionCallArgumentsDeltaSchema = z7.object({
|
|
2347
|
+
type: z7.literal("response.function_call_arguments.delta"),
|
|
2348
|
+
item_id: z7.string(),
|
|
2349
|
+
output_index: z7.number(),
|
|
2350
|
+
delta: z7.string()
|
|
2330
2351
|
});
|
|
2331
|
-
var responseOutputItemAddedSchema =
|
|
2332
|
-
type:
|
|
2333
|
-
output_index:
|
|
2334
|
-
item:
|
|
2335
|
-
|
|
2336
|
-
type:
|
|
2352
|
+
var responseOutputItemAddedSchema = z7.object({
|
|
2353
|
+
type: z7.literal("response.output_item.added"),
|
|
2354
|
+
output_index: z7.number(),
|
|
2355
|
+
item: z7.discriminatedUnion("type", [
|
|
2356
|
+
z7.object({
|
|
2357
|
+
type: z7.literal("message")
|
|
2337
2358
|
}),
|
|
2338
|
-
|
|
2339
|
-
type:
|
|
2340
|
-
id:
|
|
2341
|
-
call_id:
|
|
2342
|
-
name:
|
|
2343
|
-
arguments:
|
|
2359
|
+
z7.object({
|
|
2360
|
+
type: z7.literal("function_call"),
|
|
2361
|
+
id: z7.string(),
|
|
2362
|
+
call_id: z7.string(),
|
|
2363
|
+
name: z7.string(),
|
|
2364
|
+
arguments: z7.string()
|
|
2344
2365
|
})
|
|
2345
2366
|
])
|
|
2346
2367
|
});
|
|
2347
|
-
var responseAnnotationAddedSchema =
|
|
2348
|
-
type:
|
|
2349
|
-
annotation:
|
|
2350
|
-
type:
|
|
2351
|
-
url:
|
|
2352
|
-
title:
|
|
2368
|
+
var responseAnnotationAddedSchema = z7.object({
|
|
2369
|
+
type: z7.literal("response.output_text.annotation.added"),
|
|
2370
|
+
annotation: z7.object({
|
|
2371
|
+
type: z7.literal("url_citation"),
|
|
2372
|
+
url: z7.string(),
|
|
2373
|
+
title: z7.string()
|
|
2353
2374
|
})
|
|
2354
2375
|
});
|
|
2355
|
-
var openaiResponsesChunkSchema =
|
|
2376
|
+
var openaiResponsesChunkSchema = z7.union([
|
|
2356
2377
|
textDeltaChunkSchema,
|
|
2357
2378
|
responseFinishedChunkSchema,
|
|
2358
2379
|
responseCreatedChunkSchema,
|
|
@@ -2360,7 +2381,7 @@ var openaiResponsesChunkSchema = z6.union([
|
|
|
2360
2381
|
responseFunctionCallArgumentsDeltaSchema,
|
|
2361
2382
|
responseOutputItemAddedSchema,
|
|
2362
2383
|
responseAnnotationAddedSchema,
|
|
2363
|
-
|
|
2384
|
+
z7.object({ type: z7.string() }).passthrough()
|
|
2364
2385
|
// fallback for unknown chunks
|
|
2365
2386
|
]);
|
|
2366
2387
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2405,38 +2426,17 @@ function getResponsesModelConfig(modelId) {
|
|
|
2405
2426
|
requiredAutoTruncation: false
|
|
2406
2427
|
};
|
|
2407
2428
|
}
|
|
2408
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2409
|
-
metadata:
|
|
2410
|
-
parallelToolCalls:
|
|
2411
|
-
previousResponseId:
|
|
2412
|
-
store:
|
|
2413
|
-
user:
|
|
2414
|
-
reasoningEffort:
|
|
2415
|
-
strictSchemas:
|
|
2416
|
-
instructions:
|
|
2429
|
+
var openaiResponsesProviderOptionsSchema = z7.object({
|
|
2430
|
+
metadata: z7.any().nullish(),
|
|
2431
|
+
parallelToolCalls: z7.boolean().nullish(),
|
|
2432
|
+
previousResponseId: z7.string().nullish(),
|
|
2433
|
+
store: z7.boolean().nullish(),
|
|
2434
|
+
user: z7.string().nullish(),
|
|
2435
|
+
reasoningEffort: z7.string().nullish(),
|
|
2436
|
+
strictSchemas: z7.boolean().nullish(),
|
|
2437
|
+
instructions: z7.string().nullish()
|
|
2417
2438
|
});
|
|
2418
2439
|
|
|
2419
|
-
// src/openai-tools.ts
|
|
2420
|
-
import { z as z7 } from "zod";
|
|
2421
|
-
var WebSearchPreviewParameters = z7.object({});
|
|
2422
|
-
function webSearchPreviewTool({
|
|
2423
|
-
searchContextSize,
|
|
2424
|
-
userLocation
|
|
2425
|
-
} = {}) {
|
|
2426
|
-
return {
|
|
2427
|
-
type: "provider-defined",
|
|
2428
|
-
id: "openai.web_search_preview",
|
|
2429
|
-
args: {
|
|
2430
|
-
searchContextSize,
|
|
2431
|
-
userLocation
|
|
2432
|
-
},
|
|
2433
|
-
parameters: WebSearchPreviewParameters
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
var openaiTools = {
|
|
2437
|
-
webSearchPreview: webSearchPreviewTool
|
|
2438
|
-
};
|
|
2439
|
-
|
|
2440
2440
|
// src/openai-provider.ts
|
|
2441
2441
|
function createOpenAI(options = {}) {
|
|
2442
2442
|
var _a, _b, _c;
|