@zenning/openai 1.4.2 → 1.4.4
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/index.d.mts +134 -122
- package/dist/index.d.ts +134 -122
- package/dist/index.js +575 -269
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +575 -269
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.js +500 -181
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +500 -181
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1795,7 +1795,7 @@ var openaiTranscriptionResponseSchema = import_zod6.z.object({
|
|
|
1795
1795
|
|
|
1796
1796
|
// src/responses/openai-responses-language-model.ts
|
|
1797
1797
|
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1798
|
-
var
|
|
1798
|
+
var import_zod11 = require("zod");
|
|
1799
1799
|
|
|
1800
1800
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1801
1801
|
var import_provider7 = require("@ai-sdk/provider");
|
|
@@ -1939,6 +1939,103 @@ function mapOpenAIResponseFinishReason({
|
|
|
1939
1939
|
|
|
1940
1940
|
// src/responses/openai-responses-prepare-tools.ts
|
|
1941
1941
|
var import_provider8 = require("@ai-sdk/provider");
|
|
1942
|
+
|
|
1943
|
+
// src/tool/code-interpreter.ts
|
|
1944
|
+
var import_zod7 = require("zod");
|
|
1945
|
+
var codeInterpreterArgsSchema = import_zod7.z.object({
|
|
1946
|
+
container: import_zod7.z.union([
|
|
1947
|
+
import_zod7.z.string(),
|
|
1948
|
+
import_zod7.z.object({
|
|
1949
|
+
fileIds: import_zod7.z.array(import_zod7.z.string()).optional()
|
|
1950
|
+
})
|
|
1951
|
+
]).optional()
|
|
1952
|
+
});
|
|
1953
|
+
function codeInterpreter(args = {}) {
|
|
1954
|
+
return {
|
|
1955
|
+
type: "provider-defined",
|
|
1956
|
+
id: "openai.code_interpreter",
|
|
1957
|
+
name: "code_interpreter",
|
|
1958
|
+
args
|
|
1959
|
+
};
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
// src/tool/file-search.ts
|
|
1963
|
+
var import_zod8 = require("zod");
|
|
1964
|
+
var comparisonFilterSchema = import_zod8.z.object({
|
|
1965
|
+
key: import_zod8.z.string(),
|
|
1966
|
+
type: import_zod8.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
1967
|
+
value: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number(), import_zod8.z.boolean()])
|
|
1968
|
+
});
|
|
1969
|
+
var compoundFilterSchema = import_zod8.z.object({
|
|
1970
|
+
type: import_zod8.z.enum(["and", "or"]),
|
|
1971
|
+
filters: import_zod8.z.array(
|
|
1972
|
+
import_zod8.z.union([comparisonFilterSchema, import_zod8.z.lazy(() => compoundFilterSchema)])
|
|
1973
|
+
)
|
|
1974
|
+
});
|
|
1975
|
+
var filtersSchema = import_zod8.z.union([comparisonFilterSchema, compoundFilterSchema]);
|
|
1976
|
+
var fileSearchArgsSchema = import_zod8.z.object({
|
|
1977
|
+
vectorStoreIds: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
1978
|
+
maxNumResults: import_zod8.z.number().optional(),
|
|
1979
|
+
ranking: import_zod8.z.object({
|
|
1980
|
+
ranker: import_zod8.z.enum(["auto", "default-2024-08-21"]).optional()
|
|
1981
|
+
}).optional(),
|
|
1982
|
+
filters: filtersSchema.optional()
|
|
1983
|
+
});
|
|
1984
|
+
function fileSearch(args = {}) {
|
|
1985
|
+
return {
|
|
1986
|
+
type: "provider-defined",
|
|
1987
|
+
id: "openai.file_search",
|
|
1988
|
+
name: "file_search",
|
|
1989
|
+
args
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
// src/tool/web-search.ts
|
|
1994
|
+
var import_zod9 = require("zod");
|
|
1995
|
+
var webSearchArgsSchema = import_zod9.z.object({
|
|
1996
|
+
filters: import_zod9.z.object({
|
|
1997
|
+
allowedDomains: import_zod9.z.array(import_zod9.z.string()).optional()
|
|
1998
|
+
}).optional(),
|
|
1999
|
+
searchContextSize: import_zod9.z.enum(["low", "medium", "high"]).optional(),
|
|
2000
|
+
userLocation: import_zod9.z.object({
|
|
2001
|
+
type: import_zod9.z.literal("approximate"),
|
|
2002
|
+
country: import_zod9.z.string().optional(),
|
|
2003
|
+
city: import_zod9.z.string().optional(),
|
|
2004
|
+
region: import_zod9.z.string().optional(),
|
|
2005
|
+
timezone: import_zod9.z.string().optional()
|
|
2006
|
+
}).optional()
|
|
2007
|
+
});
|
|
2008
|
+
function webSearch(args = {}) {
|
|
2009
|
+
return {
|
|
2010
|
+
type: "provider-defined",
|
|
2011
|
+
id: "openai.web_search",
|
|
2012
|
+
name: "web_search",
|
|
2013
|
+
args
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
// src/tool/web-search-preview.ts
|
|
2018
|
+
var import_zod10 = require("zod");
|
|
2019
|
+
var webSearchPreviewArgsSchema = import_zod10.z.object({
|
|
2020
|
+
searchContextSize: import_zod10.z.enum(["low", "medium", "high"]).optional(),
|
|
2021
|
+
userLocation: import_zod10.z.object({
|
|
2022
|
+
type: import_zod10.z.literal("approximate"),
|
|
2023
|
+
country: import_zod10.z.string().optional(),
|
|
2024
|
+
city: import_zod10.z.string().optional(),
|
|
2025
|
+
region: import_zod10.z.string().optional(),
|
|
2026
|
+
timezone: import_zod10.z.string().optional()
|
|
2027
|
+
}).optional()
|
|
2028
|
+
});
|
|
2029
|
+
function webSearchPreview(args = {}) {
|
|
2030
|
+
return {
|
|
2031
|
+
type: "provider-defined",
|
|
2032
|
+
id: "openai.web_search_preview",
|
|
2033
|
+
name: "web_search_preview",
|
|
2034
|
+
args
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
// src/responses/openai-responses-prepare-tools.ts
|
|
1942
2039
|
function prepareResponsesTools({
|
|
1943
2040
|
mode,
|
|
1944
2041
|
strict
|
|
@@ -1964,31 +2061,48 @@ function prepareResponsesTools({
|
|
|
1964
2061
|
break;
|
|
1965
2062
|
case "provider-defined":
|
|
1966
2063
|
switch (tool.id) {
|
|
1967
|
-
case "openai.file_search":
|
|
2064
|
+
case "openai.file_search": {
|
|
2065
|
+
const args = fileSearchArgsSchema.parse(tool.args);
|
|
1968
2066
|
openaiTools2.push({
|
|
1969
2067
|
type: "file_search",
|
|
1970
|
-
vector_store_ids:
|
|
1971
|
-
max_num_results:
|
|
1972
|
-
ranking:
|
|
1973
|
-
filters:
|
|
2068
|
+
vector_store_ids: args.vectorStoreIds,
|
|
2069
|
+
max_num_results: args.maxNumResults,
|
|
2070
|
+
ranking_options: args.ranking ? { ranker: args.ranking.ranker } : void 0,
|
|
2071
|
+
filters: args.filters
|
|
1974
2072
|
});
|
|
1975
2073
|
break;
|
|
1976
|
-
|
|
2074
|
+
}
|
|
2075
|
+
case "openai.web_search_preview": {
|
|
2076
|
+
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
1977
2077
|
openaiTools2.push({
|
|
1978
2078
|
type: "web_search_preview",
|
|
1979
|
-
search_context_size:
|
|
1980
|
-
user_location:
|
|
2079
|
+
search_context_size: args.searchContextSize,
|
|
2080
|
+
user_location: args.userLocation
|
|
1981
2081
|
});
|
|
1982
2082
|
break;
|
|
1983
|
-
|
|
2083
|
+
}
|
|
2084
|
+
case "openai.web_search": {
|
|
2085
|
+
const args = webSearchArgsSchema.parse(tool.args);
|
|
2086
|
+
openaiTools2.push({
|
|
2087
|
+
type: "web_search",
|
|
2088
|
+
filters: args.filters != null ? { allowed_domains: args.filters.allowedDomains } : void 0,
|
|
2089
|
+
search_context_size: args.searchContextSize,
|
|
2090
|
+
user_location: args.userLocation
|
|
2091
|
+
});
|
|
2092
|
+
break;
|
|
2093
|
+
}
|
|
2094
|
+
case "openai.code_interpreter": {
|
|
2095
|
+
const args = codeInterpreterArgsSchema.parse(tool.args);
|
|
1984
2096
|
openaiTools2.push({
|
|
1985
2097
|
type: "code_interpreter",
|
|
1986
|
-
container:
|
|
2098
|
+
container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
|
|
1987
2099
|
});
|
|
1988
2100
|
break;
|
|
1989
|
-
|
|
2101
|
+
}
|
|
2102
|
+
default: {
|
|
1990
2103
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
1991
2104
|
break;
|
|
2105
|
+
}
|
|
1992
2106
|
}
|
|
1993
2107
|
break;
|
|
1994
2108
|
default:
|
|
@@ -2005,34 +2119,12 @@ function prepareResponsesTools({
|
|
|
2005
2119
|
case "none":
|
|
2006
2120
|
case "required":
|
|
2007
2121
|
return { tools: openaiTools2, tool_choice: type, toolWarnings };
|
|
2008
|
-
case "tool":
|
|
2009
|
-
if (toolChoice.toolName === "web_search_preview") {
|
|
2010
|
-
return {
|
|
2011
|
-
tools: openaiTools2,
|
|
2012
|
-
tool_choice: {
|
|
2013
|
-
type: "web_search_preview"
|
|
2014
|
-
},
|
|
2015
|
-
toolWarnings
|
|
2016
|
-
};
|
|
2017
|
-
}
|
|
2018
|
-
if (toolChoice.toolName === "code_interpreter") {
|
|
2019
|
-
return {
|
|
2020
|
-
tools: openaiTools2,
|
|
2021
|
-
tool_choice: {
|
|
2022
|
-
type: "code_interpreter"
|
|
2023
|
-
},
|
|
2024
|
-
toolWarnings
|
|
2025
|
-
};
|
|
2026
|
-
}
|
|
2122
|
+
case "tool":
|
|
2027
2123
|
return {
|
|
2028
2124
|
tools: openaiTools2,
|
|
2029
|
-
tool_choice: {
|
|
2030
|
-
type: "function",
|
|
2031
|
-
name: toolChoice.toolName
|
|
2032
|
-
},
|
|
2125
|
+
tool_choice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
2033
2126
|
toolWarnings
|
|
2034
2127
|
};
|
|
2035
|
-
}
|
|
2036
2128
|
default: {
|
|
2037
2129
|
const _exhaustiveCheck = type;
|
|
2038
2130
|
throw new import_provider8.UnsupportedFunctionalityError({
|
|
@@ -2246,55 +2338,107 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2246
2338
|
body,
|
|
2247
2339
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2248
2340
|
successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
|
|
2249
|
-
|
|
2250
|
-
id:
|
|
2251
|
-
created_at:
|
|
2252
|
-
model:
|
|
2253
|
-
output:
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
type:
|
|
2257
|
-
role:
|
|
2258
|
-
content:
|
|
2259
|
-
|
|
2260
|
-
type:
|
|
2261
|
-
text:
|
|
2262
|
-
annotations:
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2341
|
+
import_zod11.z.object({
|
|
2342
|
+
id: import_zod11.z.string(),
|
|
2343
|
+
created_at: import_zod11.z.number(),
|
|
2344
|
+
model: import_zod11.z.string(),
|
|
2345
|
+
output: import_zod11.z.array(
|
|
2346
|
+
import_zod11.z.discriminatedUnion("type", [
|
|
2347
|
+
import_zod11.z.object({
|
|
2348
|
+
type: import_zod11.z.literal("message"),
|
|
2349
|
+
role: import_zod11.z.literal("assistant"),
|
|
2350
|
+
content: import_zod11.z.array(
|
|
2351
|
+
import_zod11.z.object({
|
|
2352
|
+
type: import_zod11.z.literal("output_text"),
|
|
2353
|
+
text: import_zod11.z.string(),
|
|
2354
|
+
annotations: import_zod11.z.array(
|
|
2355
|
+
import_zod11.z.discriminatedUnion("type", [
|
|
2356
|
+
import_zod11.z.object({
|
|
2357
|
+
type: import_zod11.z.literal("url_citation"),
|
|
2358
|
+
start_index: import_zod11.z.number(),
|
|
2359
|
+
end_index: import_zod11.z.number(),
|
|
2360
|
+
url: import_zod11.z.string(),
|
|
2361
|
+
title: import_zod11.z.string()
|
|
2362
|
+
}),
|
|
2363
|
+
import_zod11.z.object({
|
|
2364
|
+
type: import_zod11.z.literal("file_citation"),
|
|
2365
|
+
file_id: import_zod11.z.string(),
|
|
2366
|
+
filename: import_zod11.z.string().nullish(),
|
|
2367
|
+
index: import_zod11.z.number().nullish(),
|
|
2368
|
+
start_index: import_zod11.z.number().nullish(),
|
|
2369
|
+
end_index: import_zod11.z.number().nullish(),
|
|
2370
|
+
quote: import_zod11.z.string().nullish()
|
|
2371
|
+
}),
|
|
2372
|
+
import_zod11.z.object({
|
|
2373
|
+
type: import_zod11.z.literal("container_file_citation")
|
|
2374
|
+
})
|
|
2375
|
+
])
|
|
2270
2376
|
)
|
|
2271
2377
|
})
|
|
2272
2378
|
)
|
|
2273
2379
|
}),
|
|
2274
|
-
|
|
2275
|
-
type:
|
|
2276
|
-
call_id: import_zod7.z.string(),
|
|
2277
|
-
name: import_zod7.z.string(),
|
|
2278
|
-
arguments: import_zod7.z.string()
|
|
2380
|
+
import_zod11.z.object({
|
|
2381
|
+
type: import_zod11.z.literal("code_interpreter_call")
|
|
2279
2382
|
}),
|
|
2280
|
-
|
|
2281
|
-
type:
|
|
2383
|
+
import_zod11.z.object({
|
|
2384
|
+
type: import_zod11.z.literal("function_call"),
|
|
2385
|
+
call_id: import_zod11.z.string(),
|
|
2386
|
+
name: import_zod11.z.string(),
|
|
2387
|
+
arguments: import_zod11.z.string()
|
|
2282
2388
|
}),
|
|
2283
|
-
|
|
2284
|
-
type:
|
|
2389
|
+
import_zod11.z.object({
|
|
2390
|
+
type: import_zod11.z.literal("web_search_call"),
|
|
2391
|
+
id: import_zod11.z.string(),
|
|
2392
|
+
status: import_zod11.z.string().optional(),
|
|
2393
|
+
action: import_zod11.z.discriminatedUnion("type", [
|
|
2394
|
+
import_zod11.z.object({
|
|
2395
|
+
type: import_zod11.z.literal("search"),
|
|
2396
|
+
query: import_zod11.z.string().nullish()
|
|
2397
|
+
}),
|
|
2398
|
+
import_zod11.z.object({
|
|
2399
|
+
type: import_zod11.z.literal("open_page"),
|
|
2400
|
+
url: import_zod11.z.string()
|
|
2401
|
+
}),
|
|
2402
|
+
import_zod11.z.object({
|
|
2403
|
+
type: import_zod11.z.literal("find"),
|
|
2404
|
+
url: import_zod11.z.string(),
|
|
2405
|
+
pattern: import_zod11.z.string()
|
|
2406
|
+
})
|
|
2407
|
+
]).nullish()
|
|
2408
|
+
}),
|
|
2409
|
+
import_zod11.z.object({
|
|
2410
|
+
type: import_zod11.z.literal("computer_call"),
|
|
2411
|
+
id: import_zod11.z.string(),
|
|
2412
|
+
status: import_zod11.z.string().optional()
|
|
2413
|
+
}),
|
|
2414
|
+
import_zod11.z.object({
|
|
2415
|
+
type: import_zod11.z.literal("file_search_call"),
|
|
2416
|
+
id: import_zod11.z.string(),
|
|
2417
|
+
status: import_zod11.z.string().optional(),
|
|
2418
|
+
queries: import_zod11.z.array(import_zod11.z.string()).nullish(),
|
|
2419
|
+
results: import_zod11.z.array(
|
|
2420
|
+
import_zod11.z.object({
|
|
2421
|
+
attributes: import_zod11.z.object({
|
|
2422
|
+
file_id: import_zod11.z.string(),
|
|
2423
|
+
filename: import_zod11.z.string(),
|
|
2424
|
+
score: import_zod11.z.number(),
|
|
2425
|
+
text: import_zod11.z.string()
|
|
2426
|
+
})
|
|
2427
|
+
})
|
|
2428
|
+
).nullish()
|
|
2285
2429
|
}),
|
|
2286
|
-
|
|
2287
|
-
type:
|
|
2288
|
-
summary:
|
|
2289
|
-
|
|
2290
|
-
type:
|
|
2291
|
-
text:
|
|
2430
|
+
import_zod11.z.object({
|
|
2431
|
+
type: import_zod11.z.literal("reasoning"),
|
|
2432
|
+
summary: import_zod11.z.array(
|
|
2433
|
+
import_zod11.z.object({
|
|
2434
|
+
type: import_zod11.z.literal("summary_text"),
|
|
2435
|
+
text: import_zod11.z.string()
|
|
2292
2436
|
})
|
|
2293
2437
|
)
|
|
2294
2438
|
})
|
|
2295
2439
|
])
|
|
2296
2440
|
),
|
|
2297
|
-
incomplete_details:
|
|
2441
|
+
incomplete_details: import_zod11.z.object({ reason: import_zod11.z.string() }).nullable(),
|
|
2298
2442
|
usage: usageSchema
|
|
2299
2443
|
})
|
|
2300
2444
|
),
|
|
@@ -2302,12 +2446,38 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2302
2446
|
fetch: this.config.fetch
|
|
2303
2447
|
});
|
|
2304
2448
|
const outputTextElements = response.output.filter((output) => output.type === "message").flatMap((output) => output.content).filter((content) => content.type === "output_text");
|
|
2305
|
-
const toolCalls =
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2449
|
+
const toolCalls = [];
|
|
2450
|
+
for (const output of response.output) {
|
|
2451
|
+
if (output.type === "function_call") {
|
|
2452
|
+
toolCalls.push({
|
|
2453
|
+
toolCallType: "function",
|
|
2454
|
+
toolCallId: output.call_id,
|
|
2455
|
+
toolName: output.name,
|
|
2456
|
+
args: output.arguments
|
|
2457
|
+
});
|
|
2458
|
+
} else if (output.type === "web_search_call") {
|
|
2459
|
+
toolCalls.push({
|
|
2460
|
+
toolCallType: "function",
|
|
2461
|
+
toolCallId: output.id,
|
|
2462
|
+
toolName: "web_search_preview",
|
|
2463
|
+
args: JSON.stringify({ action: output.action })
|
|
2464
|
+
});
|
|
2465
|
+
} else if (output.type === "computer_call") {
|
|
2466
|
+
toolCalls.push({
|
|
2467
|
+
toolCallType: "function",
|
|
2468
|
+
toolCallId: output.id,
|
|
2469
|
+
toolName: "computer_use",
|
|
2470
|
+
args: ""
|
|
2471
|
+
});
|
|
2472
|
+
} else if (output.type === "file_search_call") {
|
|
2473
|
+
toolCalls.push({
|
|
2474
|
+
toolCallType: "function",
|
|
2475
|
+
toolCallId: output.id,
|
|
2476
|
+
toolName: "file_search",
|
|
2477
|
+
args: ""
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2311
2481
|
const reasoningSummary = (_b = (_a = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a.summary) != null ? _b : null;
|
|
2312
2482
|
console.log(JSON.stringify({
|
|
2313
2483
|
msg: "ai-sdk: content annotations",
|
|
@@ -2317,13 +2487,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2317
2487
|
text: outputTextElements.map((content) => content.text).join("\n"),
|
|
2318
2488
|
sources: outputTextElements.flatMap(
|
|
2319
2489
|
(content) => content.annotations.map((annotation) => {
|
|
2320
|
-
var _a2, _b2, _c2;
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2490
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h, _i, _j, _k;
|
|
2491
|
+
if (annotation.type === "url_citation") {
|
|
2492
|
+
return {
|
|
2493
|
+
sourceType: "url",
|
|
2494
|
+
id: (_c2 = (_b2 = (_a2 = this.config).generateId) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : (0, import_provider_utils9.generateId)(),
|
|
2495
|
+
url: annotation.url,
|
|
2496
|
+
title: annotation.title
|
|
2497
|
+
};
|
|
2498
|
+
} else if (annotation.type === "file_citation") {
|
|
2499
|
+
return {
|
|
2500
|
+
sourceType: "url",
|
|
2501
|
+
id: (_f2 = (_e2 = (_d2 = this.config).generateId) == null ? void 0 : _e2.call(_d2)) != null ? _f2 : (0, import_provider_utils9.generateId)(),
|
|
2502
|
+
url: `file://${annotation.file_id}`,
|
|
2503
|
+
title: (_h = (_g2 = annotation.quote) != null ? _g2 : annotation.filename) != null ? _h : "Document"
|
|
2504
|
+
};
|
|
2505
|
+
} else {
|
|
2506
|
+
return {
|
|
2507
|
+
sourceType: "url",
|
|
2508
|
+
id: (_k = (_j = (_i = this.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0, import_provider_utils9.generateId)(),
|
|
2509
|
+
url: "",
|
|
2510
|
+
title: "Unknown Source"
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2327
2513
|
})
|
|
2328
2514
|
),
|
|
2329
2515
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -2397,7 +2583,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2397
2583
|
stream: response.pipeThrough(
|
|
2398
2584
|
new TransformStream({
|
|
2399
2585
|
transform(chunk, controller) {
|
|
2400
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2586
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2401
2587
|
if (!chunk.success) {
|
|
2402
2588
|
finishReason = "error";
|
|
2403
2589
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
@@ -2417,6 +2603,42 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2417
2603
|
toolName: value.item.name,
|
|
2418
2604
|
argsTextDelta: value.item.arguments
|
|
2419
2605
|
});
|
|
2606
|
+
} else if (value.item.type === "web_search_call") {
|
|
2607
|
+
ongoingToolCalls[value.output_index] = {
|
|
2608
|
+
toolName: "web_search_preview",
|
|
2609
|
+
toolCallId: value.item.id
|
|
2610
|
+
};
|
|
2611
|
+
controller.enqueue({
|
|
2612
|
+
type: "tool-call-delta",
|
|
2613
|
+
toolCallType: "function",
|
|
2614
|
+
toolCallId: value.item.id,
|
|
2615
|
+
toolName: "web_search_preview",
|
|
2616
|
+
argsTextDelta: JSON.stringify({ action: value.item.action })
|
|
2617
|
+
});
|
|
2618
|
+
} else if (value.item.type === "computer_call") {
|
|
2619
|
+
ongoingToolCalls[value.output_index] = {
|
|
2620
|
+
toolName: "computer_use",
|
|
2621
|
+
toolCallId: value.item.id
|
|
2622
|
+
};
|
|
2623
|
+
controller.enqueue({
|
|
2624
|
+
type: "tool-call-delta",
|
|
2625
|
+
toolCallType: "function",
|
|
2626
|
+
toolCallId: value.item.id,
|
|
2627
|
+
toolName: "computer_use",
|
|
2628
|
+
argsTextDelta: ""
|
|
2629
|
+
});
|
|
2630
|
+
} else if (value.item.type === "file_search_call") {
|
|
2631
|
+
ongoingToolCalls[value.output_index] = {
|
|
2632
|
+
toolName: "file_search",
|
|
2633
|
+
toolCallId: value.item.id
|
|
2634
|
+
};
|
|
2635
|
+
controller.enqueue({
|
|
2636
|
+
type: "tool-call-delta",
|
|
2637
|
+
toolCallType: "function",
|
|
2638
|
+
toolCallId: value.item.id,
|
|
2639
|
+
toolName: "file_search",
|
|
2640
|
+
argsTextDelta: ""
|
|
2641
|
+
});
|
|
2420
2642
|
}
|
|
2421
2643
|
} else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
2422
2644
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
@@ -2447,16 +2669,51 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2447
2669
|
type: "reasoning",
|
|
2448
2670
|
textDelta: value.delta
|
|
2449
2671
|
});
|
|
2450
|
-
} else if (isResponseOutputItemDoneChunk(value)
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2672
|
+
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
2673
|
+
if (value.item.type === "function_call") {
|
|
2674
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2675
|
+
hasToolCalls = true;
|
|
2676
|
+
controller.enqueue({
|
|
2677
|
+
type: "tool-call",
|
|
2678
|
+
toolCallType: "function",
|
|
2679
|
+
toolCallId: value.item.call_id,
|
|
2680
|
+
toolName: value.item.name,
|
|
2681
|
+
args: value.item.arguments
|
|
2682
|
+
});
|
|
2683
|
+
} else if (value.item.type === "web_search_call") {
|
|
2684
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2685
|
+
hasToolCalls = true;
|
|
2686
|
+
controller.enqueue({
|
|
2687
|
+
type: "tool-call",
|
|
2688
|
+
toolCallType: "function",
|
|
2689
|
+
toolCallId: value.item.id,
|
|
2690
|
+
toolName: "web_search_preview",
|
|
2691
|
+
args: JSON.stringify({ action: value.item.action })
|
|
2692
|
+
});
|
|
2693
|
+
} else if (value.item.type === "computer_call") {
|
|
2694
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2695
|
+
hasToolCalls = true;
|
|
2696
|
+
controller.enqueue({
|
|
2697
|
+
type: "tool-call",
|
|
2698
|
+
toolCallType: "function",
|
|
2699
|
+
toolCallId: value.item.id,
|
|
2700
|
+
toolName: "computer_use",
|
|
2701
|
+
args: ""
|
|
2702
|
+
});
|
|
2703
|
+
} else if (value.item.type === "file_search_call") {
|
|
2704
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
2705
|
+
hasToolCalls = true;
|
|
2706
|
+
controller.enqueue({
|
|
2707
|
+
type: "tool-call",
|
|
2708
|
+
toolCallType: "function",
|
|
2709
|
+
toolCallId: value.item.id,
|
|
2710
|
+
toolName: "file_search",
|
|
2711
|
+
args: JSON.stringify({
|
|
2712
|
+
queries: value.item.queries,
|
|
2713
|
+
results: value.item.results
|
|
2714
|
+
})
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2460
2717
|
} else if (isResponseFinishedChunk(value)) {
|
|
2461
2718
|
finishReason = mapOpenAIResponseFinishReason({
|
|
2462
2719
|
finishReason: (_a = value.response.incomplete_details) == null ? void 0 : _a.reason,
|
|
@@ -2471,15 +2728,27 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2471
2728
|
msg: "ai-sdk: source (stream)",
|
|
2472
2729
|
source: value.annotation
|
|
2473
2730
|
}));
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2731
|
+
if (value.annotation.type === "url_citation") {
|
|
2732
|
+
controller.enqueue({
|
|
2733
|
+
type: "source",
|
|
2734
|
+
source: {
|
|
2735
|
+
sourceType: "url",
|
|
2736
|
+
id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils9.generateId)(),
|
|
2737
|
+
url: value.annotation.url,
|
|
2738
|
+
title: value.annotation.title
|
|
2739
|
+
}
|
|
2740
|
+
});
|
|
2741
|
+
} else if (value.annotation.type === "file_citation") {
|
|
2742
|
+
controller.enqueue({
|
|
2743
|
+
type: "source",
|
|
2744
|
+
source: {
|
|
2745
|
+
sourceType: "url",
|
|
2746
|
+
id: (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0, import_provider_utils9.generateId)(),
|
|
2747
|
+
url: `file://${value.annotation.file_id}`,
|
|
2748
|
+
title: (_m = (_l = value.annotation.quote) != null ? _l : value.annotation.filename) != null ? _m : "Document"
|
|
2749
|
+
}
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2483
2752
|
}
|
|
2484
2753
|
},
|
|
2485
2754
|
flush(controller) {
|
|
@@ -2510,86 +2779,168 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2510
2779
|
};
|
|
2511
2780
|
}
|
|
2512
2781
|
};
|
|
2513
|
-
var usageSchema =
|
|
2514
|
-
input_tokens:
|
|
2515
|
-
input_tokens_details:
|
|
2516
|
-
output_tokens:
|
|
2517
|
-
output_tokens_details:
|
|
2782
|
+
var usageSchema = import_zod11.z.object({
|
|
2783
|
+
input_tokens: import_zod11.z.number(),
|
|
2784
|
+
input_tokens_details: import_zod11.z.object({ cached_tokens: import_zod11.z.number().nullish() }).nullish(),
|
|
2785
|
+
output_tokens: import_zod11.z.number(),
|
|
2786
|
+
output_tokens_details: import_zod11.z.object({ reasoning_tokens: import_zod11.z.number().nullish() }).nullish()
|
|
2518
2787
|
});
|
|
2519
|
-
var textDeltaChunkSchema =
|
|
2520
|
-
type:
|
|
2521
|
-
delta:
|
|
2788
|
+
var textDeltaChunkSchema = import_zod11.z.object({
|
|
2789
|
+
type: import_zod11.z.literal("response.output_text.delta"),
|
|
2790
|
+
delta: import_zod11.z.string()
|
|
2522
2791
|
});
|
|
2523
|
-
var responseFinishedChunkSchema =
|
|
2524
|
-
type:
|
|
2525
|
-
response:
|
|
2526
|
-
incomplete_details:
|
|
2792
|
+
var responseFinishedChunkSchema = import_zod11.z.object({
|
|
2793
|
+
type: import_zod11.z.enum(["response.completed", "response.incomplete"]),
|
|
2794
|
+
response: import_zod11.z.object({
|
|
2795
|
+
incomplete_details: import_zod11.z.object({ reason: import_zod11.z.string() }).nullish(),
|
|
2527
2796
|
usage: usageSchema
|
|
2528
2797
|
})
|
|
2529
2798
|
});
|
|
2530
|
-
var responseCreatedChunkSchema =
|
|
2531
|
-
type:
|
|
2532
|
-
response:
|
|
2533
|
-
id:
|
|
2534
|
-
created_at:
|
|
2535
|
-
model:
|
|
2799
|
+
var responseCreatedChunkSchema = import_zod11.z.object({
|
|
2800
|
+
type: import_zod11.z.literal("response.created"),
|
|
2801
|
+
response: import_zod11.z.object({
|
|
2802
|
+
id: import_zod11.z.string(),
|
|
2803
|
+
created_at: import_zod11.z.number(),
|
|
2804
|
+
model: import_zod11.z.string()
|
|
2536
2805
|
})
|
|
2537
2806
|
});
|
|
2538
|
-
var responseOutputItemDoneSchema =
|
|
2539
|
-
type:
|
|
2540
|
-
output_index:
|
|
2541
|
-
item:
|
|
2542
|
-
|
|
2543
|
-
type:
|
|
2807
|
+
var responseOutputItemDoneSchema = import_zod11.z.object({
|
|
2808
|
+
type: import_zod11.z.literal("response.output_item.done"),
|
|
2809
|
+
output_index: import_zod11.z.number(),
|
|
2810
|
+
item: import_zod11.z.discriminatedUnion("type", [
|
|
2811
|
+
import_zod11.z.object({
|
|
2812
|
+
type: import_zod11.z.literal("message")
|
|
2544
2813
|
}),
|
|
2545
|
-
|
|
2546
|
-
type:
|
|
2547
|
-
id:
|
|
2548
|
-
call_id:
|
|
2549
|
-
name:
|
|
2550
|
-
arguments:
|
|
2551
|
-
status:
|
|
2814
|
+
import_zod11.z.object({
|
|
2815
|
+
type: import_zod11.z.literal("function_call"),
|
|
2816
|
+
id: import_zod11.z.string(),
|
|
2817
|
+
call_id: import_zod11.z.string(),
|
|
2818
|
+
name: import_zod11.z.string(),
|
|
2819
|
+
arguments: import_zod11.z.string(),
|
|
2820
|
+
status: import_zod11.z.literal("completed")
|
|
2821
|
+
}),
|
|
2822
|
+
import_zod11.z.object({
|
|
2823
|
+
type: import_zod11.z.literal("web_search_call"),
|
|
2824
|
+
id: import_zod11.z.string(),
|
|
2825
|
+
status: import_zod11.z.string(),
|
|
2826
|
+
action: import_zod11.z.discriminatedUnion("type", [
|
|
2827
|
+
import_zod11.z.object({
|
|
2828
|
+
type: import_zod11.z.literal("search"),
|
|
2829
|
+
query: import_zod11.z.string().nullish()
|
|
2830
|
+
}),
|
|
2831
|
+
import_zod11.z.object({
|
|
2832
|
+
type: import_zod11.z.literal("open_page"),
|
|
2833
|
+
url: import_zod11.z.string()
|
|
2834
|
+
}),
|
|
2835
|
+
import_zod11.z.object({
|
|
2836
|
+
type: import_zod11.z.literal("find"),
|
|
2837
|
+
url: import_zod11.z.string(),
|
|
2838
|
+
pattern: import_zod11.z.string()
|
|
2839
|
+
})
|
|
2840
|
+
]).nullish()
|
|
2841
|
+
}),
|
|
2842
|
+
import_zod11.z.object({
|
|
2843
|
+
type: import_zod11.z.literal("computer_call"),
|
|
2844
|
+
id: import_zod11.z.string(),
|
|
2845
|
+
status: import_zod11.z.literal("completed")
|
|
2846
|
+
}),
|
|
2847
|
+
import_zod11.z.object({
|
|
2848
|
+
type: import_zod11.z.literal("file_search_call"),
|
|
2849
|
+
id: import_zod11.z.string(),
|
|
2850
|
+
status: import_zod11.z.literal("completed"),
|
|
2851
|
+
queries: import_zod11.z.array(import_zod11.z.string()).nullish(),
|
|
2852
|
+
results: import_zod11.z.array(
|
|
2853
|
+
import_zod11.z.object({
|
|
2854
|
+
attributes: import_zod11.z.object({
|
|
2855
|
+
file_id: import_zod11.z.string(),
|
|
2856
|
+
filename: import_zod11.z.string(),
|
|
2857
|
+
score: import_zod11.z.number(),
|
|
2858
|
+
text: import_zod11.z.string()
|
|
2859
|
+
})
|
|
2860
|
+
})
|
|
2861
|
+
).nullish()
|
|
2552
2862
|
})
|
|
2553
2863
|
])
|
|
2554
2864
|
});
|
|
2555
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
2556
|
-
type:
|
|
2557
|
-
item_id:
|
|
2558
|
-
output_index:
|
|
2559
|
-
delta:
|
|
2865
|
+
var responseFunctionCallArgumentsDeltaSchema = import_zod11.z.object({
|
|
2866
|
+
type: import_zod11.z.literal("response.function_call_arguments.delta"),
|
|
2867
|
+
item_id: import_zod11.z.string(),
|
|
2868
|
+
output_index: import_zod11.z.number(),
|
|
2869
|
+
delta: import_zod11.z.string()
|
|
2560
2870
|
});
|
|
2561
|
-
var responseOutputItemAddedSchema =
|
|
2562
|
-
type:
|
|
2563
|
-
output_index:
|
|
2564
|
-
item:
|
|
2565
|
-
|
|
2566
|
-
type:
|
|
2871
|
+
var responseOutputItemAddedSchema = import_zod11.z.object({
|
|
2872
|
+
type: import_zod11.z.literal("response.output_item.added"),
|
|
2873
|
+
output_index: import_zod11.z.number(),
|
|
2874
|
+
item: import_zod11.z.discriminatedUnion("type", [
|
|
2875
|
+
import_zod11.z.object({
|
|
2876
|
+
type: import_zod11.z.literal("message")
|
|
2567
2877
|
}),
|
|
2568
|
-
|
|
2569
|
-
type:
|
|
2570
|
-
id:
|
|
2571
|
-
call_id:
|
|
2572
|
-
name:
|
|
2573
|
-
arguments:
|
|
2878
|
+
import_zod11.z.object({
|
|
2879
|
+
type: import_zod11.z.literal("function_call"),
|
|
2880
|
+
id: import_zod11.z.string(),
|
|
2881
|
+
call_id: import_zod11.z.string(),
|
|
2882
|
+
name: import_zod11.z.string(),
|
|
2883
|
+
arguments: import_zod11.z.string()
|
|
2884
|
+
}),
|
|
2885
|
+
import_zod11.z.object({
|
|
2886
|
+
type: import_zod11.z.literal("web_search_call"),
|
|
2887
|
+
id: import_zod11.z.string(),
|
|
2888
|
+
status: import_zod11.z.string(),
|
|
2889
|
+
action: import_zod11.z.object({
|
|
2890
|
+
type: import_zod11.z.literal("search"),
|
|
2891
|
+
query: import_zod11.z.string().optional()
|
|
2892
|
+
}).nullish()
|
|
2893
|
+
}),
|
|
2894
|
+
import_zod11.z.object({
|
|
2895
|
+
type: import_zod11.z.literal("computer_call"),
|
|
2896
|
+
id: import_zod11.z.string(),
|
|
2897
|
+
status: import_zod11.z.string()
|
|
2898
|
+
}),
|
|
2899
|
+
import_zod11.z.object({
|
|
2900
|
+
type: import_zod11.z.literal("file_search_call"),
|
|
2901
|
+
id: import_zod11.z.string(),
|
|
2902
|
+
status: import_zod11.z.string(),
|
|
2903
|
+
queries: import_zod11.z.array(import_zod11.z.string()).nullish(),
|
|
2904
|
+
results: import_zod11.z.array(
|
|
2905
|
+
import_zod11.z.object({
|
|
2906
|
+
attributes: import_zod11.z.object({
|
|
2907
|
+
file_id: import_zod11.z.string(),
|
|
2908
|
+
filename: import_zod11.z.string(),
|
|
2909
|
+
score: import_zod11.z.number(),
|
|
2910
|
+
text: import_zod11.z.string()
|
|
2911
|
+
})
|
|
2912
|
+
})
|
|
2913
|
+
).optional()
|
|
2574
2914
|
})
|
|
2575
2915
|
])
|
|
2576
2916
|
});
|
|
2577
|
-
var responseAnnotationAddedSchema =
|
|
2578
|
-
type:
|
|
2579
|
-
annotation:
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2917
|
+
var responseAnnotationAddedSchema = import_zod11.z.object({
|
|
2918
|
+
type: import_zod11.z.literal("response.output_text.annotation.added"),
|
|
2919
|
+
annotation: import_zod11.z.discriminatedUnion("type", [
|
|
2920
|
+
import_zod11.z.object({
|
|
2921
|
+
type: import_zod11.z.literal("url_citation"),
|
|
2922
|
+
url: import_zod11.z.string(),
|
|
2923
|
+
title: import_zod11.z.string()
|
|
2924
|
+
}),
|
|
2925
|
+
import_zod11.z.object({
|
|
2926
|
+
type: import_zod11.z.literal("file_citation"),
|
|
2927
|
+
file_id: import_zod11.z.string(),
|
|
2928
|
+
filename: import_zod11.z.string().nullish(),
|
|
2929
|
+
index: import_zod11.z.number().nullish(),
|
|
2930
|
+
start_index: import_zod11.z.number().nullish(),
|
|
2931
|
+
end_index: import_zod11.z.number().nullish(),
|
|
2932
|
+
quote: import_zod11.z.string().nullish()
|
|
2933
|
+
})
|
|
2934
|
+
])
|
|
2584
2935
|
});
|
|
2585
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
2586
|
-
type:
|
|
2587
|
-
item_id:
|
|
2588
|
-
output_index:
|
|
2589
|
-
summary_index:
|
|
2590
|
-
delta:
|
|
2936
|
+
var responseReasoningSummaryTextDeltaSchema = import_zod11.z.object({
|
|
2937
|
+
type: import_zod11.z.literal("response.reasoning_summary_text.delta"),
|
|
2938
|
+
item_id: import_zod11.z.string(),
|
|
2939
|
+
output_index: import_zod11.z.number(),
|
|
2940
|
+
summary_index: import_zod11.z.number(),
|
|
2941
|
+
delta: import_zod11.z.string()
|
|
2591
2942
|
});
|
|
2592
|
-
var openaiResponsesChunkSchema =
|
|
2943
|
+
var openaiResponsesChunkSchema = import_zod11.z.union([
|
|
2593
2944
|
textDeltaChunkSchema,
|
|
2594
2945
|
responseFinishedChunkSchema,
|
|
2595
2946
|
responseCreatedChunkSchema,
|
|
@@ -2598,7 +2949,7 @@ var openaiResponsesChunkSchema = import_zod7.z.union([
|
|
|
2598
2949
|
responseOutputItemAddedSchema,
|
|
2599
2950
|
responseAnnotationAddedSchema,
|
|
2600
2951
|
responseReasoningSummaryTextDeltaSchema,
|
|
2601
|
-
|
|
2952
|
+
import_zod11.z.object({ type: import_zod11.z.string() }).passthrough()
|
|
2602
2953
|
// fallback for unknown chunks
|
|
2603
2954
|
]);
|
|
2604
2955
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2646,121 +2997,76 @@ function getResponsesModelConfig(modelId) {
|
|
|
2646
2997
|
requiredAutoTruncation: false
|
|
2647
2998
|
};
|
|
2648
2999
|
}
|
|
2649
|
-
var openaiResponsesProviderOptionsSchema =
|
|
2650
|
-
metadata:
|
|
2651
|
-
parallelToolCalls:
|
|
2652
|
-
include:
|
|
2653
|
-
previousResponseId:
|
|
2654
|
-
forceNoTemperature:
|
|
2655
|
-
store:
|
|
2656
|
-
user:
|
|
2657
|
-
reasoningEffort:
|
|
2658
|
-
strictSchemas:
|
|
2659
|
-
instructions:
|
|
2660
|
-
reasoningSummary:
|
|
3000
|
+
var openaiResponsesProviderOptionsSchema = import_zod11.z.object({
|
|
3001
|
+
metadata: import_zod11.z.any().nullish(),
|
|
3002
|
+
parallelToolCalls: import_zod11.z.boolean().nullish(),
|
|
3003
|
+
include: import_zod11.z.array(import_zod11.z.string()).nullish(),
|
|
3004
|
+
previousResponseId: import_zod11.z.string().nullish(),
|
|
3005
|
+
forceNoTemperature: import_zod11.z.boolean().nullish(),
|
|
3006
|
+
store: import_zod11.z.boolean().nullish(),
|
|
3007
|
+
user: import_zod11.z.string().nullish(),
|
|
3008
|
+
reasoningEffort: import_zod11.z.string().nullish(),
|
|
3009
|
+
strictSchemas: import_zod11.z.boolean().nullish(),
|
|
3010
|
+
instructions: import_zod11.z.string().nullish(),
|
|
3011
|
+
reasoningSummary: import_zod11.z.string().nullish()
|
|
2661
3012
|
});
|
|
2662
3013
|
|
|
2663
3014
|
// src/openai-tools.ts
|
|
2664
|
-
var
|
|
2665
|
-
var WebSearchPreviewParameters = import_zod8.z.object({});
|
|
2666
|
-
function webSearchPreviewTool({
|
|
2667
|
-
searchContextSize,
|
|
2668
|
-
userLocation
|
|
2669
|
-
} = {}) {
|
|
2670
|
-
return {
|
|
2671
|
-
type: "provider-defined",
|
|
2672
|
-
id: "openai.web_search_preview",
|
|
2673
|
-
args: {
|
|
2674
|
-
searchContextSize,
|
|
2675
|
-
userLocation
|
|
2676
|
-
},
|
|
2677
|
-
parameters: WebSearchPreviewParameters
|
|
2678
|
-
};
|
|
2679
|
-
}
|
|
2680
|
-
var CodeInterpreterParameters = import_zod8.z.object({
|
|
2681
|
-
container: import_zod8.z.union([
|
|
2682
|
-
import_zod8.z.string(),
|
|
2683
|
-
import_zod8.z.object({
|
|
2684
|
-
containerId: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.null()]).transform((val) => val != null ? val : void 0),
|
|
2685
|
-
type: import_zod8.z.enum(["auto", "file", "code_interpreter"]),
|
|
2686
|
-
files: import_zod8.z.array(import_zod8.z.string())
|
|
2687
|
-
})
|
|
2688
|
-
])
|
|
2689
|
-
});
|
|
2690
|
-
function codeInterpreterTool({
|
|
2691
|
-
container
|
|
2692
|
-
}) {
|
|
2693
|
-
return {
|
|
2694
|
-
type: "provider-defined",
|
|
2695
|
-
id: "openai.code_interpreter",
|
|
2696
|
-
args: {
|
|
2697
|
-
container
|
|
2698
|
-
},
|
|
2699
|
-
parameters: CodeInterpreterParameters
|
|
2700
|
-
};
|
|
2701
|
-
}
|
|
2702
|
-
var comparisonFilterSchema = import_zod8.z.object({
|
|
2703
|
-
key: import_zod8.z.string(),
|
|
2704
|
-
type: import_zod8.z.enum(["eq", "ne", "gt", "gte", "lt", "lte"]),
|
|
2705
|
-
value: import_zod8.z.union([import_zod8.z.string(), import_zod8.z.number(), import_zod8.z.boolean()])
|
|
2706
|
-
});
|
|
2707
|
-
var compoundFilterSchema = import_zod8.z.object({
|
|
2708
|
-
type: import_zod8.z.enum(["and", "or"]),
|
|
2709
|
-
filters: import_zod8.z.array(
|
|
2710
|
-
import_zod8.z.union([comparisonFilterSchema, import_zod8.z.lazy(() => compoundFilterSchema)])
|
|
2711
|
-
)
|
|
2712
|
-
});
|
|
2713
|
-
var filtersSchema = import_zod8.z.union([comparisonFilterSchema, compoundFilterSchema]);
|
|
2714
|
-
var fileSearchArgsSchema = import_zod8.z.object({
|
|
3015
|
+
var openaiTools = {
|
|
2715
3016
|
/**
|
|
2716
|
-
*
|
|
3017
|
+
* The Code Interpreter tool allows models to write and run Python code in a
|
|
3018
|
+
* sandboxed environment to solve complex problems in domains like data analysis,
|
|
3019
|
+
* coding, and math.
|
|
3020
|
+
*
|
|
3021
|
+
* @param container - The container to use for the code interpreter.
|
|
3022
|
+
*
|
|
3023
|
+
* Must have name `code_interpreter`.
|
|
2717
3024
|
*/
|
|
2718
|
-
|
|
3025
|
+
codeInterpreter,
|
|
2719
3026
|
/**
|
|
2720
|
-
*
|
|
3027
|
+
* File search is a tool available in the Responses API. It enables models to
|
|
3028
|
+
* retrieve information in a knowledge base of previously uploaded files through
|
|
3029
|
+
* semantic and keyword search.
|
|
3030
|
+
*
|
|
3031
|
+
* Must have name `file_search`.
|
|
3032
|
+
*
|
|
3033
|
+
* @param vectorStoreIds - The vector store IDs to use for the file search.
|
|
3034
|
+
* @param maxNumResults - The maximum number of results to return.
|
|
3035
|
+
* @param ranking - The ranking options to use for the file search.
|
|
3036
|
+
* @param filters - The filters to use for the file search.
|
|
2721
3037
|
*/
|
|
2722
|
-
|
|
3038
|
+
fileSearch,
|
|
2723
3039
|
/**
|
|
2724
|
-
*
|
|
3040
|
+
* Web search allows models to access up-to-date information from the internet
|
|
3041
|
+
* and provide answers with sourced citations.
|
|
3042
|
+
*
|
|
3043
|
+
* Must have name `web_search_preview`.
|
|
3044
|
+
*
|
|
3045
|
+
* @param searchContextSize - The search context size to use for the web search.
|
|
3046
|
+
* @param userLocation - The user location to use for the web search.
|
|
3047
|
+
*
|
|
3048
|
+
* @deprecated Use `webSearch` instead.
|
|
2725
3049
|
*/
|
|
2726
|
-
|
|
2727
|
-
ranker: import_zod8.z.enum(["auto", "default-2024-08-21"]).optional()
|
|
2728
|
-
}).optional(),
|
|
3050
|
+
webSearchPreview,
|
|
2729
3051
|
/**
|
|
2730
|
-
*
|
|
3052
|
+
* Web search allows models to access up-to-date information from the internet
|
|
3053
|
+
* and provide answers with sourced citations.
|
|
3054
|
+
*
|
|
3055
|
+
* Must have name `web_search`.
|
|
3056
|
+
*
|
|
3057
|
+
* @param filters - The filters to use for the web search.
|
|
3058
|
+
* @param searchContextSize - The search context size to use for the web search.
|
|
3059
|
+
* @param userLocation - The user location to use for the web search.
|
|
2731
3060
|
*/
|
|
2732
|
-
|
|
2733
|
-
});
|
|
2734
|
-
function fileSearchTool({
|
|
2735
|
-
vectorStoreIds,
|
|
2736
|
-
maxNumResults,
|
|
2737
|
-
ranking,
|
|
2738
|
-
filters
|
|
2739
|
-
} = {}) {
|
|
2740
|
-
return {
|
|
2741
|
-
type: "provider-defined",
|
|
2742
|
-
id: "openai.file_search",
|
|
2743
|
-
args: {
|
|
2744
|
-
vectorStoreIds,
|
|
2745
|
-
maxNumResults,
|
|
2746
|
-
ranking,
|
|
2747
|
-
filters
|
|
2748
|
-
},
|
|
2749
|
-
parameters: import_zod8.z.object({})
|
|
2750
|
-
};
|
|
2751
|
-
}
|
|
2752
|
-
var openaiTools = {
|
|
2753
|
-
webSearchPreview: webSearchPreviewTool,
|
|
2754
|
-
codeInterpreter: codeInterpreterTool,
|
|
2755
|
-
fileSearch: fileSearchTool
|
|
3061
|
+
webSearch
|
|
2756
3062
|
};
|
|
2757
3063
|
|
|
2758
3064
|
// src/openai-speech-model.ts
|
|
2759
3065
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
2760
|
-
var
|
|
2761
|
-
var OpenAIProviderOptionsSchema =
|
|
2762
|
-
instructions:
|
|
2763
|
-
speed:
|
|
3066
|
+
var import_zod12 = require("zod");
|
|
3067
|
+
var OpenAIProviderOptionsSchema = import_zod12.z.object({
|
|
3068
|
+
instructions: import_zod12.z.string().nullish(),
|
|
3069
|
+
speed: import_zod12.z.number().min(0.25).max(4).default(1).nullish()
|
|
2764
3070
|
});
|
|
2765
3071
|
var OpenAISpeechModel = class {
|
|
2766
3072
|
constructor(modelId, config) {
|