@ai-sdk/openai 2.1.0-beta.1 → 2.1.0-beta.10
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 +88 -0
- package/dist/index.d.mts +67 -14
- package/dist/index.d.ts +67 -14
- package/dist/index.js +616 -399
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +586 -368
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +333 -23
- package/dist/internal/index.d.ts +333 -23
- package/dist/internal/index.js +632 -407
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +600 -386
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -20,13 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
VERSION: () => VERSION,
|
|
23
24
|
createOpenAI: () => createOpenAI,
|
|
24
25
|
openai: () => openai
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(src_exports);
|
|
27
28
|
|
|
28
29
|
// src/openai-provider.ts
|
|
29
|
-
var
|
|
30
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
30
31
|
|
|
31
32
|
// src/chat/openai-chat-language-model.ts
|
|
32
33
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -262,7 +263,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
262
263
|
|
|
263
264
|
// src/chat/openai-chat-options.ts
|
|
264
265
|
var import_v42 = require("zod/v4");
|
|
265
|
-
var
|
|
266
|
+
var openaiChatLanguageModelOptions = import_v42.z.object({
|
|
266
267
|
/**
|
|
267
268
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
268
269
|
*
|
|
@@ -414,7 +415,7 @@ function prepareChatTools({
|
|
|
414
415
|
// src/chat/openai-chat-language-model.ts
|
|
415
416
|
var OpenAIChatLanguageModel = class {
|
|
416
417
|
constructor(modelId, config) {
|
|
417
|
-
this.specificationVersion = "
|
|
418
|
+
this.specificationVersion = "v3";
|
|
418
419
|
this.supportedUrls = {
|
|
419
420
|
"image/*": [/^https?:\/\/.*$/]
|
|
420
421
|
};
|
|
@@ -444,7 +445,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
444
445
|
const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
|
|
445
446
|
provider: "openai",
|
|
446
447
|
providerOptions,
|
|
447
|
-
schema:
|
|
448
|
+
schema: openaiChatLanguageModelOptions
|
|
448
449
|
})) != null ? _a : {};
|
|
449
450
|
const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
|
|
450
451
|
if (topK != null) {
|
|
@@ -1223,7 +1224,7 @@ var openaiCompletionProviderOptions = import_v44.z.object({
|
|
|
1223
1224
|
// src/completion/openai-completion-language-model.ts
|
|
1224
1225
|
var OpenAICompletionLanguageModel = class {
|
|
1225
1226
|
constructor(modelId, config) {
|
|
1226
|
-
this.specificationVersion = "
|
|
1227
|
+
this.specificationVersion = "v3";
|
|
1227
1228
|
this.supportedUrls = {
|
|
1228
1229
|
// No URLs are supported for completion models.
|
|
1229
1230
|
};
|
|
@@ -1516,7 +1517,7 @@ var openaiEmbeddingProviderOptions = import_v46.z.object({
|
|
|
1516
1517
|
// src/embedding/openai-embedding-model.ts
|
|
1517
1518
|
var OpenAIEmbeddingModel = class {
|
|
1518
1519
|
constructor(modelId, config) {
|
|
1519
|
-
this.specificationVersion = "
|
|
1520
|
+
this.specificationVersion = "v3";
|
|
1520
1521
|
this.maxEmbeddingsPerCall = 2048;
|
|
1521
1522
|
this.supportsParallelCalls = true;
|
|
1522
1523
|
this.modelId = modelId;
|
|
@@ -1598,7 +1599,7 @@ var OpenAIImageModel = class {
|
|
|
1598
1599
|
constructor(modelId, config) {
|
|
1599
1600
|
this.modelId = modelId;
|
|
1600
1601
|
this.config = config;
|
|
1601
|
-
this.specificationVersion = "
|
|
1602
|
+
this.specificationVersion = "v3";
|
|
1602
1603
|
}
|
|
1603
1604
|
get maxImagesPerCall() {
|
|
1604
1605
|
var _a;
|
|
@@ -1782,39 +1783,62 @@ var imageGeneration = (args = {}) => {
|
|
|
1782
1783
|
return imageGenerationToolFactory(args);
|
|
1783
1784
|
};
|
|
1784
1785
|
|
|
1785
|
-
// src/tool/
|
|
1786
|
+
// src/tool/local-shell.ts
|
|
1786
1787
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1787
1788
|
var import_v412 = require("zod/v4");
|
|
1788
|
-
var
|
|
1789
|
-
|
|
1790
|
-
|
|
1789
|
+
var localShellInputSchema = import_v412.z.object({
|
|
1790
|
+
action: import_v412.z.object({
|
|
1791
|
+
type: import_v412.z.literal("exec"),
|
|
1792
|
+
command: import_v412.z.array(import_v412.z.string()),
|
|
1793
|
+
timeoutMs: import_v412.z.number().optional(),
|
|
1794
|
+
user: import_v412.z.string().optional(),
|
|
1795
|
+
workingDirectory: import_v412.z.string().optional(),
|
|
1796
|
+
env: import_v412.z.record(import_v412.z.string(), import_v412.z.string()).optional()
|
|
1797
|
+
})
|
|
1798
|
+
});
|
|
1799
|
+
var localShellOutputSchema = import_v412.z.object({
|
|
1800
|
+
output: import_v412.z.string()
|
|
1801
|
+
});
|
|
1802
|
+
var localShell = (0, import_provider_utils10.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
1803
|
+
id: "openai.local_shell",
|
|
1804
|
+
name: "local_shell",
|
|
1805
|
+
inputSchema: localShellInputSchema,
|
|
1806
|
+
outputSchema: localShellOutputSchema
|
|
1807
|
+
});
|
|
1808
|
+
|
|
1809
|
+
// src/tool/web-search.ts
|
|
1810
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1811
|
+
var import_v413 = require("zod/v4");
|
|
1812
|
+
var webSearchArgsSchema = import_v413.z.object({
|
|
1813
|
+
filters: import_v413.z.object({
|
|
1814
|
+
allowedDomains: import_v413.z.array(import_v413.z.string()).optional()
|
|
1791
1815
|
}).optional(),
|
|
1792
|
-
searchContextSize:
|
|
1793
|
-
userLocation:
|
|
1794
|
-
type:
|
|
1795
|
-
country:
|
|
1796
|
-
city:
|
|
1797
|
-
region:
|
|
1798
|
-
timezone:
|
|
1816
|
+
searchContextSize: import_v413.z.enum(["low", "medium", "high"]).optional(),
|
|
1817
|
+
userLocation: import_v413.z.object({
|
|
1818
|
+
type: import_v413.z.literal("approximate"),
|
|
1819
|
+
country: import_v413.z.string().optional(),
|
|
1820
|
+
city: import_v413.z.string().optional(),
|
|
1821
|
+
region: import_v413.z.string().optional(),
|
|
1822
|
+
timezone: import_v413.z.string().optional()
|
|
1799
1823
|
}).optional()
|
|
1800
1824
|
});
|
|
1801
|
-
var webSearchToolFactory = (0,
|
|
1825
|
+
var webSearchToolFactory = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1802
1826
|
id: "openai.web_search",
|
|
1803
1827
|
name: "web_search",
|
|
1804
|
-
inputSchema:
|
|
1805
|
-
action:
|
|
1806
|
-
|
|
1807
|
-
type:
|
|
1808
|
-
query:
|
|
1828
|
+
inputSchema: import_v413.z.object({
|
|
1829
|
+
action: import_v413.z.discriminatedUnion("type", [
|
|
1830
|
+
import_v413.z.object({
|
|
1831
|
+
type: import_v413.z.literal("search"),
|
|
1832
|
+
query: import_v413.z.string().nullish()
|
|
1809
1833
|
}),
|
|
1810
|
-
|
|
1811
|
-
type:
|
|
1812
|
-
url:
|
|
1834
|
+
import_v413.z.object({
|
|
1835
|
+
type: import_v413.z.literal("open_page"),
|
|
1836
|
+
url: import_v413.z.string()
|
|
1813
1837
|
}),
|
|
1814
|
-
|
|
1815
|
-
type:
|
|
1816
|
-
url:
|
|
1817
|
-
pattern:
|
|
1838
|
+
import_v413.z.object({
|
|
1839
|
+
type: import_v413.z.literal("find"),
|
|
1840
|
+
url: import_v413.z.string(),
|
|
1841
|
+
pattern: import_v413.z.string()
|
|
1818
1842
|
})
|
|
1819
1843
|
]).nullish()
|
|
1820
1844
|
})
|
|
@@ -1824,59 +1848,59 @@ var webSearch = (args = {}) => {
|
|
|
1824
1848
|
};
|
|
1825
1849
|
|
|
1826
1850
|
// src/tool/web-search-preview.ts
|
|
1827
|
-
var
|
|
1828
|
-
var
|
|
1829
|
-
var webSearchPreviewArgsSchema =
|
|
1851
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1852
|
+
var import_v414 = require("zod/v4");
|
|
1853
|
+
var webSearchPreviewArgsSchema = import_v414.z.object({
|
|
1830
1854
|
/**
|
|
1831
1855
|
* Search context size to use for the web search.
|
|
1832
1856
|
* - high: Most comprehensive context, highest cost, slower response
|
|
1833
1857
|
* - medium: Balanced context, cost, and latency (default)
|
|
1834
1858
|
* - low: Least context, lowest cost, fastest response
|
|
1835
1859
|
*/
|
|
1836
|
-
searchContextSize:
|
|
1860
|
+
searchContextSize: import_v414.z.enum(["low", "medium", "high"]).optional(),
|
|
1837
1861
|
/**
|
|
1838
1862
|
* User location information to provide geographically relevant search results.
|
|
1839
1863
|
*/
|
|
1840
|
-
userLocation:
|
|
1864
|
+
userLocation: import_v414.z.object({
|
|
1841
1865
|
/**
|
|
1842
1866
|
* Type of location (always 'approximate')
|
|
1843
1867
|
*/
|
|
1844
|
-
type:
|
|
1868
|
+
type: import_v414.z.literal("approximate"),
|
|
1845
1869
|
/**
|
|
1846
1870
|
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
1847
1871
|
*/
|
|
1848
|
-
country:
|
|
1872
|
+
country: import_v414.z.string().optional(),
|
|
1849
1873
|
/**
|
|
1850
1874
|
* City name (free text, e.g., 'Minneapolis')
|
|
1851
1875
|
*/
|
|
1852
|
-
city:
|
|
1876
|
+
city: import_v414.z.string().optional(),
|
|
1853
1877
|
/**
|
|
1854
1878
|
* Region name (free text, e.g., 'Minnesota')
|
|
1855
1879
|
*/
|
|
1856
|
-
region:
|
|
1880
|
+
region: import_v414.z.string().optional(),
|
|
1857
1881
|
/**
|
|
1858
1882
|
* IANA timezone (e.g., 'America/Chicago')
|
|
1859
1883
|
*/
|
|
1860
|
-
timezone:
|
|
1884
|
+
timezone: import_v414.z.string().optional()
|
|
1861
1885
|
}).optional()
|
|
1862
1886
|
});
|
|
1863
|
-
var webSearchPreview = (0,
|
|
1887
|
+
var webSearchPreview = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
1864
1888
|
id: "openai.web_search_preview",
|
|
1865
1889
|
name: "web_search_preview",
|
|
1866
|
-
inputSchema:
|
|
1867
|
-
action:
|
|
1868
|
-
|
|
1869
|
-
type:
|
|
1870
|
-
query:
|
|
1890
|
+
inputSchema: import_v414.z.object({
|
|
1891
|
+
action: import_v414.z.discriminatedUnion("type", [
|
|
1892
|
+
import_v414.z.object({
|
|
1893
|
+
type: import_v414.z.literal("search"),
|
|
1894
|
+
query: import_v414.z.string().nullish()
|
|
1871
1895
|
}),
|
|
1872
|
-
|
|
1873
|
-
type:
|
|
1874
|
-
url:
|
|
1896
|
+
import_v414.z.object({
|
|
1897
|
+
type: import_v414.z.literal("open_page"),
|
|
1898
|
+
url: import_v414.z.string()
|
|
1875
1899
|
}),
|
|
1876
|
-
|
|
1877
|
-
type:
|
|
1878
|
-
url:
|
|
1879
|
-
pattern:
|
|
1900
|
+
import_v414.z.object({
|
|
1901
|
+
type: import_v414.z.literal("find"),
|
|
1902
|
+
url: import_v414.z.string(),
|
|
1903
|
+
pattern: import_v414.z.string()
|
|
1880
1904
|
})
|
|
1881
1905
|
]).nullish()
|
|
1882
1906
|
})
|
|
@@ -1921,6 +1945,15 @@ var openaiTools = {
|
|
|
1921
1945
|
* @param background - Transparent or opaque
|
|
1922
1946
|
*/
|
|
1923
1947
|
imageGeneration,
|
|
1948
|
+
/**
|
|
1949
|
+
* Local shell is a tool that allows agents to run shell commands locally
|
|
1950
|
+
* on a machine you or the user provides.
|
|
1951
|
+
*
|
|
1952
|
+
* Supported models: `gpt-5-codex` and `codex-mini-latest`
|
|
1953
|
+
*
|
|
1954
|
+
* Must have name `local_shell`.
|
|
1955
|
+
*/
|
|
1956
|
+
localShell,
|
|
1924
1957
|
/**
|
|
1925
1958
|
* Web search allows models to access up-to-date information from the internet
|
|
1926
1959
|
* and provide answers with sourced citations.
|
|
@@ -1948,13 +1981,13 @@ var openaiTools = {
|
|
|
1948
1981
|
|
|
1949
1982
|
// src/responses/openai-responses-language-model.ts
|
|
1950
1983
|
var import_provider8 = require("@ai-sdk/provider");
|
|
1951
|
-
var
|
|
1952
|
-
var
|
|
1984
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
1985
|
+
var import_v416 = require("zod/v4");
|
|
1953
1986
|
|
|
1954
1987
|
// src/responses/convert-to-openai-responses-input.ts
|
|
1955
1988
|
var import_provider6 = require("@ai-sdk/provider");
|
|
1956
|
-
var
|
|
1957
|
-
var
|
|
1989
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
1990
|
+
var import_v415 = require("zod/v4");
|
|
1958
1991
|
function isFileId(data, prefixes) {
|
|
1959
1992
|
if (!prefixes) return false;
|
|
1960
1993
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -1963,9 +1996,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
1963
1996
|
prompt,
|
|
1964
1997
|
systemMessageMode,
|
|
1965
1998
|
fileIdPrefixes,
|
|
1966
|
-
store
|
|
1999
|
+
store,
|
|
2000
|
+
hasLocalShellTool = false
|
|
1967
2001
|
}) {
|
|
1968
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2002
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1969
2003
|
const input = [];
|
|
1970
2004
|
const warnings = [];
|
|
1971
2005
|
for (const { role, content } of prompt) {
|
|
@@ -2011,7 +2045,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2011
2045
|
return {
|
|
2012
2046
|
type: "input_image",
|
|
2013
2047
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2014
|
-
image_url: `data:${mediaType};base64,${(0,
|
|
2048
|
+
image_url: `data:${mediaType};base64,${(0, import_provider_utils13.convertToBase64)(part.data)}`
|
|
2015
2049
|
},
|
|
2016
2050
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
2017
2051
|
};
|
|
@@ -2026,7 +2060,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2026
2060
|
type: "input_file",
|
|
2027
2061
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2028
2062
|
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2029
|
-
file_data: `data:application/pdf;base64,${(0,
|
|
2063
|
+
file_data: `data:application/pdf;base64,${(0, import_provider_utils13.convertToBase64)(part.data)}`
|
|
2030
2064
|
}
|
|
2031
2065
|
};
|
|
2032
2066
|
} else {
|
|
@@ -2058,12 +2092,29 @@ async function convertToOpenAIResponsesInput({
|
|
|
2058
2092
|
if (part.providerExecuted) {
|
|
2059
2093
|
break;
|
|
2060
2094
|
}
|
|
2095
|
+
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2096
|
+
const parsedInput = localShellInputSchema.parse(part.input);
|
|
2097
|
+
input.push({
|
|
2098
|
+
type: "local_shell_call",
|
|
2099
|
+
call_id: part.toolCallId,
|
|
2100
|
+
id: (_f = (_e = (_d = part.providerOptions) == null ? void 0 : _d.openai) == null ? void 0 : _e.itemId) != null ? _f : void 0,
|
|
2101
|
+
action: {
|
|
2102
|
+
type: "exec",
|
|
2103
|
+
command: parsedInput.action.command,
|
|
2104
|
+
timeout_ms: parsedInput.action.timeoutMs,
|
|
2105
|
+
user: parsedInput.action.user,
|
|
2106
|
+
working_directory: parsedInput.action.workingDirectory,
|
|
2107
|
+
env: parsedInput.action.env
|
|
2108
|
+
}
|
|
2109
|
+
});
|
|
2110
|
+
break;
|
|
2111
|
+
}
|
|
2061
2112
|
input.push({
|
|
2062
2113
|
type: "function_call",
|
|
2063
2114
|
call_id: part.toolCallId,
|
|
2064
2115
|
name: part.toolName,
|
|
2065
2116
|
arguments: JSON.stringify(part.input),
|
|
2066
|
-
id: (
|
|
2117
|
+
id: (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.itemId) != null ? _i : void 0
|
|
2067
2118
|
});
|
|
2068
2119
|
break;
|
|
2069
2120
|
}
|
|
@@ -2080,33 +2131,47 @@ async function convertToOpenAIResponsesInput({
|
|
|
2080
2131
|
break;
|
|
2081
2132
|
}
|
|
2082
2133
|
case "reasoning": {
|
|
2083
|
-
const providerOptions = await (0,
|
|
2134
|
+
const providerOptions = await (0, import_provider_utils13.parseProviderOptions)({
|
|
2084
2135
|
provider: "openai",
|
|
2085
2136
|
providerOptions: part.providerOptions,
|
|
2086
2137
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
2087
2138
|
});
|
|
2088
2139
|
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2089
2140
|
if (reasoningId != null) {
|
|
2090
|
-
const
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
if (existingReasoningMessage === void 0) {
|
|
2101
|
-
reasoningMessages[reasoningId] = {
|
|
2102
|
-
type: "reasoning",
|
|
2103
|
-
id: reasoningId,
|
|
2104
|
-
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2105
|
-
summary: summaryParts
|
|
2106
|
-
};
|
|
2107
|
-
input.push(reasoningMessages[reasoningId]);
|
|
2141
|
+
const reasoningMessage = reasoningMessages[reasoningId];
|
|
2142
|
+
if (store) {
|
|
2143
|
+
if (reasoningMessage === void 0) {
|
|
2144
|
+
input.push({ type: "item_reference", id: reasoningId });
|
|
2145
|
+
reasoningMessages[reasoningId] = {
|
|
2146
|
+
type: "reasoning",
|
|
2147
|
+
id: reasoningId,
|
|
2148
|
+
summary: []
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2108
2151
|
} else {
|
|
2109
|
-
|
|
2152
|
+
const summaryParts = [];
|
|
2153
|
+
if (part.text.length > 0) {
|
|
2154
|
+
summaryParts.push({
|
|
2155
|
+
type: "summary_text",
|
|
2156
|
+
text: part.text
|
|
2157
|
+
});
|
|
2158
|
+
} else if (reasoningMessage !== void 0) {
|
|
2159
|
+
warnings.push({
|
|
2160
|
+
type: "other",
|
|
2161
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
if (reasoningMessage === void 0) {
|
|
2165
|
+
reasoningMessages[reasoningId] = {
|
|
2166
|
+
type: "reasoning",
|
|
2167
|
+
id: reasoningId,
|
|
2168
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2169
|
+
summary: summaryParts
|
|
2170
|
+
};
|
|
2171
|
+
input.push(reasoningMessages[reasoningId]);
|
|
2172
|
+
} else {
|
|
2173
|
+
reasoningMessage.summary.push(...summaryParts);
|
|
2174
|
+
}
|
|
2110
2175
|
}
|
|
2111
2176
|
} else {
|
|
2112
2177
|
warnings.push({
|
|
@@ -2123,6 +2188,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2123
2188
|
case "tool": {
|
|
2124
2189
|
for (const part of content) {
|
|
2125
2190
|
const output = part.output;
|
|
2191
|
+
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2192
|
+
input.push({
|
|
2193
|
+
type: "local_shell_call_output",
|
|
2194
|
+
call_id: part.toolCallId,
|
|
2195
|
+
output: localShellOutputSchema.parse(output.value).output
|
|
2196
|
+
});
|
|
2197
|
+
break;
|
|
2198
|
+
}
|
|
2126
2199
|
let contentValue;
|
|
2127
2200
|
switch (output.type) {
|
|
2128
2201
|
case "text":
|
|
@@ -2151,9 +2224,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2151
2224
|
}
|
|
2152
2225
|
return { input, warnings };
|
|
2153
2226
|
}
|
|
2154
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
2155
|
-
itemId:
|
|
2156
|
-
reasoningEncryptedContent:
|
|
2227
|
+
var openaiResponsesReasoningProviderOptionsSchema = import_v415.z.object({
|
|
2228
|
+
itemId: import_v415.z.string().nullish(),
|
|
2229
|
+
reasoningEncryptedContent: import_v415.z.string().nullish()
|
|
2157
2230
|
});
|
|
2158
2231
|
|
|
2159
2232
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -2214,6 +2287,12 @@ function prepareResponsesTools({
|
|
|
2214
2287
|
});
|
|
2215
2288
|
break;
|
|
2216
2289
|
}
|
|
2290
|
+
case "openai.local_shell": {
|
|
2291
|
+
openaiTools2.push({
|
|
2292
|
+
type: "local_shell"
|
|
2293
|
+
});
|
|
2294
|
+
break;
|
|
2295
|
+
}
|
|
2217
2296
|
case "openai.web_search_preview": {
|
|
2218
2297
|
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
2219
2298
|
openaiTools2.push({
|
|
@@ -2293,73 +2372,86 @@ function prepareResponsesTools({
|
|
|
2293
2372
|
}
|
|
2294
2373
|
|
|
2295
2374
|
// src/responses/openai-responses-language-model.ts
|
|
2296
|
-
var webSearchCallItem =
|
|
2297
|
-
type:
|
|
2298
|
-
id:
|
|
2299
|
-
status:
|
|
2300
|
-
action:
|
|
2301
|
-
|
|
2302
|
-
type:
|
|
2303
|
-
query:
|
|
2375
|
+
var webSearchCallItem = import_v416.z.object({
|
|
2376
|
+
type: import_v416.z.literal("web_search_call"),
|
|
2377
|
+
id: import_v416.z.string(),
|
|
2378
|
+
status: import_v416.z.string(),
|
|
2379
|
+
action: import_v416.z.discriminatedUnion("type", [
|
|
2380
|
+
import_v416.z.object({
|
|
2381
|
+
type: import_v416.z.literal("search"),
|
|
2382
|
+
query: import_v416.z.string().nullish()
|
|
2304
2383
|
}),
|
|
2305
|
-
|
|
2306
|
-
type:
|
|
2307
|
-
url:
|
|
2384
|
+
import_v416.z.object({
|
|
2385
|
+
type: import_v416.z.literal("open_page"),
|
|
2386
|
+
url: import_v416.z.string()
|
|
2308
2387
|
}),
|
|
2309
|
-
|
|
2310
|
-
type:
|
|
2311
|
-
url:
|
|
2312
|
-
pattern:
|
|
2388
|
+
import_v416.z.object({
|
|
2389
|
+
type: import_v416.z.literal("find"),
|
|
2390
|
+
url: import_v416.z.string(),
|
|
2391
|
+
pattern: import_v416.z.string()
|
|
2313
2392
|
})
|
|
2314
2393
|
]).nullish()
|
|
2315
2394
|
});
|
|
2316
|
-
var fileSearchCallItem =
|
|
2317
|
-
type:
|
|
2318
|
-
id:
|
|
2319
|
-
queries:
|
|
2320
|
-
results:
|
|
2321
|
-
|
|
2322
|
-
attributes:
|
|
2323
|
-
file_id:
|
|
2324
|
-
filename:
|
|
2325
|
-
score:
|
|
2326
|
-
text:
|
|
2395
|
+
var fileSearchCallItem = import_v416.z.object({
|
|
2396
|
+
type: import_v416.z.literal("file_search_call"),
|
|
2397
|
+
id: import_v416.z.string(),
|
|
2398
|
+
queries: import_v416.z.array(import_v416.z.string()),
|
|
2399
|
+
results: import_v416.z.array(
|
|
2400
|
+
import_v416.z.object({
|
|
2401
|
+
attributes: import_v416.z.record(import_v416.z.string(), import_v416.z.unknown()),
|
|
2402
|
+
file_id: import_v416.z.string(),
|
|
2403
|
+
filename: import_v416.z.string(),
|
|
2404
|
+
score: import_v416.z.number(),
|
|
2405
|
+
text: import_v416.z.string()
|
|
2327
2406
|
})
|
|
2328
2407
|
).nullish()
|
|
2329
2408
|
});
|
|
2330
|
-
var codeInterpreterCallItem =
|
|
2331
|
-
type:
|
|
2332
|
-
id:
|
|
2333
|
-
code:
|
|
2334
|
-
container_id:
|
|
2335
|
-
outputs:
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2409
|
+
var codeInterpreterCallItem = import_v416.z.object({
|
|
2410
|
+
type: import_v416.z.literal("code_interpreter_call"),
|
|
2411
|
+
id: import_v416.z.string(),
|
|
2412
|
+
code: import_v416.z.string().nullable(),
|
|
2413
|
+
container_id: import_v416.z.string(),
|
|
2414
|
+
outputs: import_v416.z.array(
|
|
2415
|
+
import_v416.z.discriminatedUnion("type", [
|
|
2416
|
+
import_v416.z.object({ type: import_v416.z.literal("logs"), logs: import_v416.z.string() }),
|
|
2417
|
+
import_v416.z.object({ type: import_v416.z.literal("image"), url: import_v416.z.string() })
|
|
2339
2418
|
])
|
|
2340
2419
|
).nullable()
|
|
2341
2420
|
});
|
|
2342
|
-
var
|
|
2343
|
-
type:
|
|
2344
|
-
id:
|
|
2345
|
-
|
|
2421
|
+
var localShellCallItem = import_v416.z.object({
|
|
2422
|
+
type: import_v416.z.literal("local_shell_call"),
|
|
2423
|
+
id: import_v416.z.string(),
|
|
2424
|
+
call_id: import_v416.z.string(),
|
|
2425
|
+
action: import_v416.z.object({
|
|
2426
|
+
type: import_v416.z.literal("exec"),
|
|
2427
|
+
command: import_v416.z.array(import_v416.z.string()),
|
|
2428
|
+
timeout_ms: import_v416.z.number().optional(),
|
|
2429
|
+
user: import_v416.z.string().optional(),
|
|
2430
|
+
working_directory: import_v416.z.string().optional(),
|
|
2431
|
+
env: import_v416.z.record(import_v416.z.string(), import_v416.z.string()).optional()
|
|
2432
|
+
})
|
|
2433
|
+
});
|
|
2434
|
+
var imageGenerationCallItem = import_v416.z.object({
|
|
2435
|
+
type: import_v416.z.literal("image_generation_call"),
|
|
2436
|
+
id: import_v416.z.string(),
|
|
2437
|
+
result: import_v416.z.string()
|
|
2346
2438
|
});
|
|
2347
2439
|
var TOP_LOGPROBS_MAX = 20;
|
|
2348
|
-
var LOGPROBS_SCHEMA =
|
|
2349
|
-
|
|
2350
|
-
token:
|
|
2351
|
-
logprob:
|
|
2352
|
-
top_logprobs:
|
|
2353
|
-
|
|
2354
|
-
token:
|
|
2355
|
-
logprob:
|
|
2440
|
+
var LOGPROBS_SCHEMA = import_v416.z.array(
|
|
2441
|
+
import_v416.z.object({
|
|
2442
|
+
token: import_v416.z.string(),
|
|
2443
|
+
logprob: import_v416.z.number(),
|
|
2444
|
+
top_logprobs: import_v416.z.array(
|
|
2445
|
+
import_v416.z.object({
|
|
2446
|
+
token: import_v416.z.string(),
|
|
2447
|
+
logprob: import_v416.z.number()
|
|
2356
2448
|
})
|
|
2357
2449
|
)
|
|
2358
2450
|
})
|
|
2359
2451
|
);
|
|
2360
2452
|
var OpenAIResponsesLanguageModel = class {
|
|
2361
2453
|
constructor(modelId, config) {
|
|
2362
|
-
this.specificationVersion = "
|
|
2454
|
+
this.specificationVersion = "v3";
|
|
2363
2455
|
this.supportedUrls = {
|
|
2364
2456
|
"image/*": [/^https?:\/\/.*$/],
|
|
2365
2457
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
@@ -2409,7 +2501,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2409
2501
|
if (stopSequences != null) {
|
|
2410
2502
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
2411
2503
|
}
|
|
2412
|
-
const openaiOptions = await (0,
|
|
2504
|
+
const openaiOptions = await (0, import_provider_utils14.parseProviderOptions)({
|
|
2413
2505
|
provider: "openai",
|
|
2414
2506
|
providerOptions,
|
|
2415
2507
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -2418,7 +2510,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2418
2510
|
prompt,
|
|
2419
2511
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
2420
2512
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
2421
|
-
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
|
|
2513
|
+
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
|
|
2514
|
+
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
2422
2515
|
});
|
|
2423
2516
|
warnings.push(...inputWarnings);
|
|
2424
2517
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
@@ -2577,51 +2670,51 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2577
2670
|
responseHeaders,
|
|
2578
2671
|
value: response,
|
|
2579
2672
|
rawValue: rawResponse
|
|
2580
|
-
} = await (0,
|
|
2673
|
+
} = await (0, import_provider_utils14.postJsonToApi)({
|
|
2581
2674
|
url,
|
|
2582
|
-
headers: (0,
|
|
2675
|
+
headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
|
|
2583
2676
|
body,
|
|
2584
2677
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2585
|
-
successfulResponseHandler: (0,
|
|
2586
|
-
|
|
2587
|
-
id:
|
|
2588
|
-
created_at:
|
|
2589
|
-
error:
|
|
2590
|
-
code:
|
|
2591
|
-
message:
|
|
2678
|
+
successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
|
|
2679
|
+
import_v416.z.object({
|
|
2680
|
+
id: import_v416.z.string(),
|
|
2681
|
+
created_at: import_v416.z.number(),
|
|
2682
|
+
error: import_v416.z.object({
|
|
2683
|
+
code: import_v416.z.string(),
|
|
2684
|
+
message: import_v416.z.string()
|
|
2592
2685
|
}).nullish(),
|
|
2593
|
-
model:
|
|
2594
|
-
output:
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
type:
|
|
2598
|
-
role:
|
|
2599
|
-
id:
|
|
2600
|
-
content:
|
|
2601
|
-
|
|
2602
|
-
type:
|
|
2603
|
-
text:
|
|
2686
|
+
model: import_v416.z.string(),
|
|
2687
|
+
output: import_v416.z.array(
|
|
2688
|
+
import_v416.z.discriminatedUnion("type", [
|
|
2689
|
+
import_v416.z.object({
|
|
2690
|
+
type: import_v416.z.literal("message"),
|
|
2691
|
+
role: import_v416.z.literal("assistant"),
|
|
2692
|
+
id: import_v416.z.string(),
|
|
2693
|
+
content: import_v416.z.array(
|
|
2694
|
+
import_v416.z.object({
|
|
2695
|
+
type: import_v416.z.literal("output_text"),
|
|
2696
|
+
text: import_v416.z.string(),
|
|
2604
2697
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2605
|
-
annotations:
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
type:
|
|
2609
|
-
start_index:
|
|
2610
|
-
end_index:
|
|
2611
|
-
url:
|
|
2612
|
-
title:
|
|
2698
|
+
annotations: import_v416.z.array(
|
|
2699
|
+
import_v416.z.discriminatedUnion("type", [
|
|
2700
|
+
import_v416.z.object({
|
|
2701
|
+
type: import_v416.z.literal("url_citation"),
|
|
2702
|
+
start_index: import_v416.z.number(),
|
|
2703
|
+
end_index: import_v416.z.number(),
|
|
2704
|
+
url: import_v416.z.string(),
|
|
2705
|
+
title: import_v416.z.string()
|
|
2613
2706
|
}),
|
|
2614
|
-
|
|
2615
|
-
type:
|
|
2616
|
-
file_id:
|
|
2617
|
-
filename:
|
|
2618
|
-
index:
|
|
2619
|
-
start_index:
|
|
2620
|
-
end_index:
|
|
2621
|
-
quote:
|
|
2707
|
+
import_v416.z.object({
|
|
2708
|
+
type: import_v416.z.literal("file_citation"),
|
|
2709
|
+
file_id: import_v416.z.string(),
|
|
2710
|
+
filename: import_v416.z.string().nullish(),
|
|
2711
|
+
index: import_v416.z.number().nullish(),
|
|
2712
|
+
start_index: import_v416.z.number().nullish(),
|
|
2713
|
+
end_index: import_v416.z.number().nullish(),
|
|
2714
|
+
quote: import_v416.z.string().nullish()
|
|
2622
2715
|
}),
|
|
2623
|
-
|
|
2624
|
-
type:
|
|
2716
|
+
import_v416.z.object({
|
|
2717
|
+
type: import_v416.z.literal("container_file_citation")
|
|
2625
2718
|
})
|
|
2626
2719
|
])
|
|
2627
2720
|
)
|
|
@@ -2632,33 +2725,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2632
2725
|
fileSearchCallItem,
|
|
2633
2726
|
codeInterpreterCallItem,
|
|
2634
2727
|
imageGenerationCallItem,
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2728
|
+
localShellCallItem,
|
|
2729
|
+
import_v416.z.object({
|
|
2730
|
+
type: import_v416.z.literal("function_call"),
|
|
2731
|
+
call_id: import_v416.z.string(),
|
|
2732
|
+
name: import_v416.z.string(),
|
|
2733
|
+
arguments: import_v416.z.string(),
|
|
2734
|
+
id: import_v416.z.string()
|
|
2641
2735
|
}),
|
|
2642
|
-
|
|
2643
|
-
type:
|
|
2644
|
-
id:
|
|
2645
|
-
status:
|
|
2736
|
+
import_v416.z.object({
|
|
2737
|
+
type: import_v416.z.literal("computer_call"),
|
|
2738
|
+
id: import_v416.z.string(),
|
|
2739
|
+
status: import_v416.z.string().optional()
|
|
2646
2740
|
}),
|
|
2647
|
-
|
|
2648
|
-
type:
|
|
2649
|
-
id:
|
|
2650
|
-
encrypted_content:
|
|
2651
|
-
summary:
|
|
2652
|
-
|
|
2653
|
-
type:
|
|
2654
|
-
text:
|
|
2741
|
+
import_v416.z.object({
|
|
2742
|
+
type: import_v416.z.literal("reasoning"),
|
|
2743
|
+
id: import_v416.z.string(),
|
|
2744
|
+
encrypted_content: import_v416.z.string().nullish(),
|
|
2745
|
+
summary: import_v416.z.array(
|
|
2746
|
+
import_v416.z.object({
|
|
2747
|
+
type: import_v416.z.literal("summary_text"),
|
|
2748
|
+
text: import_v416.z.string()
|
|
2655
2749
|
})
|
|
2656
2750
|
)
|
|
2657
2751
|
})
|
|
2658
2752
|
])
|
|
2659
2753
|
),
|
|
2660
|
-
service_tier:
|
|
2661
|
-
incomplete_details:
|
|
2754
|
+
service_tier: import_v416.z.string().nullish(),
|
|
2755
|
+
incomplete_details: import_v416.z.object({ reason: import_v416.z.string() }).nullish(),
|
|
2662
2756
|
usage: usageSchema2
|
|
2663
2757
|
})
|
|
2664
2758
|
),
|
|
@@ -2718,6 +2812,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2718
2812
|
});
|
|
2719
2813
|
break;
|
|
2720
2814
|
}
|
|
2815
|
+
case "local_shell_call": {
|
|
2816
|
+
content.push({
|
|
2817
|
+
type: "tool-call",
|
|
2818
|
+
toolCallId: part.call_id,
|
|
2819
|
+
toolName: "local_shell",
|
|
2820
|
+
input: JSON.stringify({ action: part.action }),
|
|
2821
|
+
providerMetadata: {
|
|
2822
|
+
openai: {
|
|
2823
|
+
itemId: part.id
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
break;
|
|
2828
|
+
}
|
|
2721
2829
|
case "message": {
|
|
2722
2830
|
for (const contentPart of part.content) {
|
|
2723
2831
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
@@ -2737,7 +2845,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2737
2845
|
content.push({
|
|
2738
2846
|
type: "source",
|
|
2739
2847
|
sourceType: "url",
|
|
2740
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0,
|
|
2848
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils14.generateId)(),
|
|
2741
2849
|
url: annotation.url,
|
|
2742
2850
|
title: annotation.title
|
|
2743
2851
|
});
|
|
@@ -2745,7 +2853,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2745
2853
|
content.push({
|
|
2746
2854
|
type: "source",
|
|
2747
2855
|
sourceType: "document",
|
|
2748
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0,
|
|
2856
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils14.generateId)(),
|
|
2749
2857
|
mediaType: "text/plain",
|
|
2750
2858
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
2751
2859
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id
|
|
@@ -2897,18 +3005,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2897
3005
|
warnings,
|
|
2898
3006
|
webSearchToolName
|
|
2899
3007
|
} = await this.getArgs(options);
|
|
2900
|
-
const { responseHeaders, value: response } = await (0,
|
|
3008
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
|
|
2901
3009
|
url: this.config.url({
|
|
2902
3010
|
path: "/responses",
|
|
2903
3011
|
modelId: this.modelId
|
|
2904
3012
|
}),
|
|
2905
|
-
headers: (0,
|
|
3013
|
+
headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
|
|
2906
3014
|
body: {
|
|
2907
3015
|
...body,
|
|
2908
3016
|
stream: true
|
|
2909
3017
|
},
|
|
2910
3018
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2911
|
-
successfulResponseHandler: (0,
|
|
3019
|
+
successfulResponseHandler: (0, import_provider_utils14.createEventSourceResponseHandler)(
|
|
2912
3020
|
openaiResponsesChunkSchema
|
|
2913
3021
|
),
|
|
2914
3022
|
abortSignal: options.abortSignal,
|
|
@@ -2975,6 +3083,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2975
3083
|
id: value.item.id,
|
|
2976
3084
|
toolName: "computer_use"
|
|
2977
3085
|
});
|
|
3086
|
+
} else if (value.item.type === "code_interpreter_call") {
|
|
3087
|
+
ongoingToolCalls[value.output_index] = {
|
|
3088
|
+
toolName: "code_interpreter",
|
|
3089
|
+
toolCallId: value.item.id,
|
|
3090
|
+
codeInterpreter: {
|
|
3091
|
+
containerId: value.item.container_id
|
|
3092
|
+
}
|
|
3093
|
+
};
|
|
3094
|
+
controller.enqueue({
|
|
3095
|
+
type: "tool-input-start",
|
|
3096
|
+
id: value.item.id,
|
|
3097
|
+
toolName: "code_interpreter"
|
|
3098
|
+
});
|
|
3099
|
+
controller.enqueue({
|
|
3100
|
+
type: "tool-input-delta",
|
|
3101
|
+
id: value.item.id,
|
|
3102
|
+
delta: `{"containerId":"${value.item.container_id}","code":"`
|
|
3103
|
+
});
|
|
2978
3104
|
} else if (value.item.type === "file_search_call") {
|
|
2979
3105
|
controller.enqueue({
|
|
2980
3106
|
type: "tool-call",
|
|
@@ -3098,16 +3224,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3098
3224
|
providerExecuted: true
|
|
3099
3225
|
});
|
|
3100
3226
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3101
|
-
|
|
3102
|
-
type: "tool-call",
|
|
3103
|
-
toolCallId: value.item.id,
|
|
3104
|
-
toolName: "code_interpreter",
|
|
3105
|
-
input: JSON.stringify({
|
|
3106
|
-
code: value.item.code,
|
|
3107
|
-
containerId: value.item.container_id
|
|
3108
|
-
}),
|
|
3109
|
-
providerExecuted: true
|
|
3110
|
-
});
|
|
3227
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3111
3228
|
controller.enqueue({
|
|
3112
3229
|
type: "tool-result",
|
|
3113
3230
|
toolCallId: value.item.id,
|
|
@@ -3127,6 +3244,26 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3127
3244
|
},
|
|
3128
3245
|
providerExecuted: true
|
|
3129
3246
|
});
|
|
3247
|
+
} else if (value.item.type === "local_shell_call") {
|
|
3248
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3249
|
+
controller.enqueue({
|
|
3250
|
+
type: "tool-call",
|
|
3251
|
+
toolCallId: value.item.call_id,
|
|
3252
|
+
toolName: "local_shell",
|
|
3253
|
+
input: JSON.stringify({
|
|
3254
|
+
action: {
|
|
3255
|
+
type: "exec",
|
|
3256
|
+
command: value.item.action.command,
|
|
3257
|
+
timeoutMs: value.item.action.timeout_ms,
|
|
3258
|
+
user: value.item.action.user,
|
|
3259
|
+
workingDirectory: value.item.action.working_directory,
|
|
3260
|
+
env: value.item.action.env
|
|
3261
|
+
}
|
|
3262
|
+
}),
|
|
3263
|
+
providerMetadata: {
|
|
3264
|
+
openai: { itemId: value.item.id }
|
|
3265
|
+
}
|
|
3266
|
+
});
|
|
3130
3267
|
} else if (value.item.type === "message") {
|
|
3131
3268
|
controller.enqueue({
|
|
3132
3269
|
type: "text-end",
|
|
@@ -3157,6 +3294,40 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3157
3294
|
delta: value.delta
|
|
3158
3295
|
});
|
|
3159
3296
|
}
|
|
3297
|
+
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3298
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3299
|
+
if (toolCall != null) {
|
|
3300
|
+
controller.enqueue({
|
|
3301
|
+
type: "tool-input-delta",
|
|
3302
|
+
id: toolCall.toolCallId,
|
|
3303
|
+
// The delta is code, which is embedding in a JSON string.
|
|
3304
|
+
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
3305
|
+
delta: JSON.stringify(value.delta).slice(1, -1)
|
|
3306
|
+
});
|
|
3307
|
+
}
|
|
3308
|
+
} else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
3309
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3310
|
+
if (toolCall != null) {
|
|
3311
|
+
controller.enqueue({
|
|
3312
|
+
type: "tool-input-delta",
|
|
3313
|
+
id: toolCall.toolCallId,
|
|
3314
|
+
delta: '"}'
|
|
3315
|
+
});
|
|
3316
|
+
controller.enqueue({
|
|
3317
|
+
type: "tool-input-end",
|
|
3318
|
+
id: toolCall.toolCallId
|
|
3319
|
+
});
|
|
3320
|
+
controller.enqueue({
|
|
3321
|
+
type: "tool-call",
|
|
3322
|
+
toolCallId: toolCall.toolCallId,
|
|
3323
|
+
toolName: "code_interpreter",
|
|
3324
|
+
input: JSON.stringify({
|
|
3325
|
+
code: value.code,
|
|
3326
|
+
containerId: toolCall.codeInterpreter.containerId
|
|
3327
|
+
}),
|
|
3328
|
+
providerExecuted: true
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3160
3331
|
} else if (isResponseCreatedChunk(value)) {
|
|
3161
3332
|
responseId = value.response.id;
|
|
3162
3333
|
controller.enqueue({
|
|
@@ -3219,7 +3390,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3219
3390
|
controller.enqueue({
|
|
3220
3391
|
type: "source",
|
|
3221
3392
|
sourceType: "url",
|
|
3222
|
-
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0,
|
|
3393
|
+
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils14.generateId)(),
|
|
3223
3394
|
url: value.annotation.url,
|
|
3224
3395
|
title: value.annotation.title
|
|
3225
3396
|
});
|
|
@@ -3227,7 +3398,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3227
3398
|
controller.enqueue({
|
|
3228
3399
|
type: "source",
|
|
3229
3400
|
sourceType: "document",
|
|
3230
|
-
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0,
|
|
3401
|
+
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils14.generateId)(),
|
|
3231
3402
|
mediaType: "text/plain",
|
|
3232
3403
|
title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
|
|
3233
3404
|
filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id
|
|
@@ -3263,166 +3434,194 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3263
3434
|
};
|
|
3264
3435
|
}
|
|
3265
3436
|
};
|
|
3266
|
-
var usageSchema2 =
|
|
3267
|
-
input_tokens:
|
|
3268
|
-
input_tokens_details:
|
|
3269
|
-
output_tokens:
|
|
3270
|
-
output_tokens_details:
|
|
3437
|
+
var usageSchema2 = import_v416.z.object({
|
|
3438
|
+
input_tokens: import_v416.z.number(),
|
|
3439
|
+
input_tokens_details: import_v416.z.object({ cached_tokens: import_v416.z.number().nullish() }).nullish(),
|
|
3440
|
+
output_tokens: import_v416.z.number(),
|
|
3441
|
+
output_tokens_details: import_v416.z.object({ reasoning_tokens: import_v416.z.number().nullish() }).nullish()
|
|
3271
3442
|
});
|
|
3272
|
-
var textDeltaChunkSchema =
|
|
3273
|
-
type:
|
|
3274
|
-
item_id:
|
|
3275
|
-
delta:
|
|
3443
|
+
var textDeltaChunkSchema = import_v416.z.object({
|
|
3444
|
+
type: import_v416.z.literal("response.output_text.delta"),
|
|
3445
|
+
item_id: import_v416.z.string(),
|
|
3446
|
+
delta: import_v416.z.string(),
|
|
3276
3447
|
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3277
3448
|
});
|
|
3278
|
-
var errorChunkSchema =
|
|
3279
|
-
type:
|
|
3280
|
-
code:
|
|
3281
|
-
message:
|
|
3282
|
-
param:
|
|
3283
|
-
sequence_number:
|
|
3449
|
+
var errorChunkSchema = import_v416.z.object({
|
|
3450
|
+
type: import_v416.z.literal("error"),
|
|
3451
|
+
code: import_v416.z.string(),
|
|
3452
|
+
message: import_v416.z.string(),
|
|
3453
|
+
param: import_v416.z.string().nullish(),
|
|
3454
|
+
sequence_number: import_v416.z.number()
|
|
3284
3455
|
});
|
|
3285
|
-
var responseFinishedChunkSchema =
|
|
3286
|
-
type:
|
|
3287
|
-
response:
|
|
3288
|
-
incomplete_details:
|
|
3456
|
+
var responseFinishedChunkSchema = import_v416.z.object({
|
|
3457
|
+
type: import_v416.z.enum(["response.completed", "response.incomplete"]),
|
|
3458
|
+
response: import_v416.z.object({
|
|
3459
|
+
incomplete_details: import_v416.z.object({ reason: import_v416.z.string() }).nullish(),
|
|
3289
3460
|
usage: usageSchema2,
|
|
3290
|
-
service_tier:
|
|
3461
|
+
service_tier: import_v416.z.string().nullish()
|
|
3291
3462
|
})
|
|
3292
3463
|
});
|
|
3293
|
-
var responseCreatedChunkSchema =
|
|
3294
|
-
type:
|
|
3295
|
-
response:
|
|
3296
|
-
id:
|
|
3297
|
-
created_at:
|
|
3298
|
-
model:
|
|
3299
|
-
service_tier:
|
|
3464
|
+
var responseCreatedChunkSchema = import_v416.z.object({
|
|
3465
|
+
type: import_v416.z.literal("response.created"),
|
|
3466
|
+
response: import_v416.z.object({
|
|
3467
|
+
id: import_v416.z.string(),
|
|
3468
|
+
created_at: import_v416.z.number(),
|
|
3469
|
+
model: import_v416.z.string(),
|
|
3470
|
+
service_tier: import_v416.z.string().nullish()
|
|
3300
3471
|
})
|
|
3301
3472
|
});
|
|
3302
|
-
var responseOutputItemAddedSchema =
|
|
3303
|
-
type:
|
|
3304
|
-
output_index:
|
|
3305
|
-
item:
|
|
3306
|
-
|
|
3307
|
-
type:
|
|
3308
|
-
id:
|
|
3473
|
+
var responseOutputItemAddedSchema = import_v416.z.object({
|
|
3474
|
+
type: import_v416.z.literal("response.output_item.added"),
|
|
3475
|
+
output_index: import_v416.z.number(),
|
|
3476
|
+
item: import_v416.z.discriminatedUnion("type", [
|
|
3477
|
+
import_v416.z.object({
|
|
3478
|
+
type: import_v416.z.literal("message"),
|
|
3479
|
+
id: import_v416.z.string()
|
|
3309
3480
|
}),
|
|
3310
|
-
|
|
3311
|
-
type:
|
|
3312
|
-
id:
|
|
3313
|
-
encrypted_content:
|
|
3481
|
+
import_v416.z.object({
|
|
3482
|
+
type: import_v416.z.literal("reasoning"),
|
|
3483
|
+
id: import_v416.z.string(),
|
|
3484
|
+
encrypted_content: import_v416.z.string().nullish()
|
|
3314
3485
|
}),
|
|
3315
|
-
|
|
3316
|
-
type:
|
|
3317
|
-
id:
|
|
3318
|
-
call_id:
|
|
3319
|
-
name:
|
|
3320
|
-
arguments:
|
|
3486
|
+
import_v416.z.object({
|
|
3487
|
+
type: import_v416.z.literal("function_call"),
|
|
3488
|
+
id: import_v416.z.string(),
|
|
3489
|
+
call_id: import_v416.z.string(),
|
|
3490
|
+
name: import_v416.z.string(),
|
|
3491
|
+
arguments: import_v416.z.string()
|
|
3321
3492
|
}),
|
|
3322
|
-
|
|
3323
|
-
type:
|
|
3324
|
-
id:
|
|
3325
|
-
status:
|
|
3326
|
-
action:
|
|
3327
|
-
type:
|
|
3328
|
-
query:
|
|
3493
|
+
import_v416.z.object({
|
|
3494
|
+
type: import_v416.z.literal("web_search_call"),
|
|
3495
|
+
id: import_v416.z.string(),
|
|
3496
|
+
status: import_v416.z.string(),
|
|
3497
|
+
action: import_v416.z.object({
|
|
3498
|
+
type: import_v416.z.literal("search"),
|
|
3499
|
+
query: import_v416.z.string().optional()
|
|
3329
3500
|
}).nullish()
|
|
3330
3501
|
}),
|
|
3331
|
-
|
|
3332
|
-
type:
|
|
3333
|
-
id:
|
|
3334
|
-
status:
|
|
3502
|
+
import_v416.z.object({
|
|
3503
|
+
type: import_v416.z.literal("computer_call"),
|
|
3504
|
+
id: import_v416.z.string(),
|
|
3505
|
+
status: import_v416.z.string()
|
|
3506
|
+
}),
|
|
3507
|
+
import_v416.z.object({
|
|
3508
|
+
type: import_v416.z.literal("file_search_call"),
|
|
3509
|
+
id: import_v416.z.string()
|
|
3335
3510
|
}),
|
|
3336
|
-
|
|
3337
|
-
type:
|
|
3338
|
-
id:
|
|
3511
|
+
import_v416.z.object({
|
|
3512
|
+
type: import_v416.z.literal("image_generation_call"),
|
|
3513
|
+
id: import_v416.z.string()
|
|
3339
3514
|
}),
|
|
3340
|
-
|
|
3341
|
-
type:
|
|
3342
|
-
id:
|
|
3515
|
+
import_v416.z.object({
|
|
3516
|
+
type: import_v416.z.literal("code_interpreter_call"),
|
|
3517
|
+
id: import_v416.z.string(),
|
|
3518
|
+
container_id: import_v416.z.string(),
|
|
3519
|
+
code: import_v416.z.string().nullable(),
|
|
3520
|
+
outputs: import_v416.z.array(
|
|
3521
|
+
import_v416.z.discriminatedUnion("type", [
|
|
3522
|
+
import_v416.z.object({ type: import_v416.z.literal("logs"), logs: import_v416.z.string() }),
|
|
3523
|
+
import_v416.z.object({ type: import_v416.z.literal("image"), url: import_v416.z.string() })
|
|
3524
|
+
])
|
|
3525
|
+
).nullable(),
|
|
3526
|
+
status: import_v416.z.string()
|
|
3343
3527
|
})
|
|
3344
3528
|
])
|
|
3345
3529
|
});
|
|
3346
|
-
var responseOutputItemDoneSchema =
|
|
3347
|
-
type:
|
|
3348
|
-
output_index:
|
|
3349
|
-
item:
|
|
3350
|
-
|
|
3351
|
-
type:
|
|
3352
|
-
id:
|
|
3530
|
+
var responseOutputItemDoneSchema = import_v416.z.object({
|
|
3531
|
+
type: import_v416.z.literal("response.output_item.done"),
|
|
3532
|
+
output_index: import_v416.z.number(),
|
|
3533
|
+
item: import_v416.z.discriminatedUnion("type", [
|
|
3534
|
+
import_v416.z.object({
|
|
3535
|
+
type: import_v416.z.literal("message"),
|
|
3536
|
+
id: import_v416.z.string()
|
|
3353
3537
|
}),
|
|
3354
|
-
|
|
3355
|
-
type:
|
|
3356
|
-
id:
|
|
3357
|
-
encrypted_content:
|
|
3538
|
+
import_v416.z.object({
|
|
3539
|
+
type: import_v416.z.literal("reasoning"),
|
|
3540
|
+
id: import_v416.z.string(),
|
|
3541
|
+
encrypted_content: import_v416.z.string().nullish()
|
|
3358
3542
|
}),
|
|
3359
|
-
|
|
3360
|
-
type:
|
|
3361
|
-
id:
|
|
3362
|
-
call_id:
|
|
3363
|
-
name:
|
|
3364
|
-
arguments:
|
|
3365
|
-
status:
|
|
3543
|
+
import_v416.z.object({
|
|
3544
|
+
type: import_v416.z.literal("function_call"),
|
|
3545
|
+
id: import_v416.z.string(),
|
|
3546
|
+
call_id: import_v416.z.string(),
|
|
3547
|
+
name: import_v416.z.string(),
|
|
3548
|
+
arguments: import_v416.z.string(),
|
|
3549
|
+
status: import_v416.z.literal("completed")
|
|
3366
3550
|
}),
|
|
3367
3551
|
codeInterpreterCallItem,
|
|
3368
3552
|
imageGenerationCallItem,
|
|
3369
3553
|
webSearchCallItem,
|
|
3370
3554
|
fileSearchCallItem,
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3555
|
+
localShellCallItem,
|
|
3556
|
+
import_v416.z.object({
|
|
3557
|
+
type: import_v416.z.literal("computer_call"),
|
|
3558
|
+
id: import_v416.z.string(),
|
|
3559
|
+
status: import_v416.z.literal("completed")
|
|
3375
3560
|
})
|
|
3376
3561
|
])
|
|
3377
3562
|
});
|
|
3378
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
3379
|
-
type:
|
|
3380
|
-
item_id:
|
|
3381
|
-
output_index:
|
|
3382
|
-
delta:
|
|
3563
|
+
var responseFunctionCallArgumentsDeltaSchema = import_v416.z.object({
|
|
3564
|
+
type: import_v416.z.literal("response.function_call_arguments.delta"),
|
|
3565
|
+
item_id: import_v416.z.string(),
|
|
3566
|
+
output_index: import_v416.z.number(),
|
|
3567
|
+
delta: import_v416.z.string()
|
|
3568
|
+
});
|
|
3569
|
+
var responseCodeInterpreterCallCodeDeltaSchema = import_v416.z.object({
|
|
3570
|
+
type: import_v416.z.literal("response.code_interpreter_call_code.delta"),
|
|
3571
|
+
item_id: import_v416.z.string(),
|
|
3572
|
+
output_index: import_v416.z.number(),
|
|
3573
|
+
delta: import_v416.z.string()
|
|
3383
3574
|
});
|
|
3384
|
-
var
|
|
3385
|
-
type:
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3575
|
+
var responseCodeInterpreterCallCodeDoneSchema = import_v416.z.object({
|
|
3576
|
+
type: import_v416.z.literal("response.code_interpreter_call_code.done"),
|
|
3577
|
+
item_id: import_v416.z.string(),
|
|
3578
|
+
output_index: import_v416.z.number(),
|
|
3579
|
+
code: import_v416.z.string()
|
|
3580
|
+
});
|
|
3581
|
+
var responseAnnotationAddedSchema = import_v416.z.object({
|
|
3582
|
+
type: import_v416.z.literal("response.output_text.annotation.added"),
|
|
3583
|
+
annotation: import_v416.z.discriminatedUnion("type", [
|
|
3584
|
+
import_v416.z.object({
|
|
3585
|
+
type: import_v416.z.literal("url_citation"),
|
|
3586
|
+
url: import_v416.z.string(),
|
|
3587
|
+
title: import_v416.z.string()
|
|
3391
3588
|
}),
|
|
3392
|
-
|
|
3393
|
-
type:
|
|
3394
|
-
file_id:
|
|
3395
|
-
filename:
|
|
3396
|
-
index:
|
|
3397
|
-
start_index:
|
|
3398
|
-
end_index:
|
|
3399
|
-
quote:
|
|
3589
|
+
import_v416.z.object({
|
|
3590
|
+
type: import_v416.z.literal("file_citation"),
|
|
3591
|
+
file_id: import_v416.z.string(),
|
|
3592
|
+
filename: import_v416.z.string().nullish(),
|
|
3593
|
+
index: import_v416.z.number().nullish(),
|
|
3594
|
+
start_index: import_v416.z.number().nullish(),
|
|
3595
|
+
end_index: import_v416.z.number().nullish(),
|
|
3596
|
+
quote: import_v416.z.string().nullish()
|
|
3400
3597
|
})
|
|
3401
3598
|
])
|
|
3402
3599
|
});
|
|
3403
|
-
var responseReasoningSummaryPartAddedSchema =
|
|
3404
|
-
type:
|
|
3405
|
-
item_id:
|
|
3406
|
-
summary_index:
|
|
3600
|
+
var responseReasoningSummaryPartAddedSchema = import_v416.z.object({
|
|
3601
|
+
type: import_v416.z.literal("response.reasoning_summary_part.added"),
|
|
3602
|
+
item_id: import_v416.z.string(),
|
|
3603
|
+
summary_index: import_v416.z.number()
|
|
3407
3604
|
});
|
|
3408
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
3409
|
-
type:
|
|
3410
|
-
item_id:
|
|
3411
|
-
summary_index:
|
|
3412
|
-
delta:
|
|
3605
|
+
var responseReasoningSummaryTextDeltaSchema = import_v416.z.object({
|
|
3606
|
+
type: import_v416.z.literal("response.reasoning_summary_text.delta"),
|
|
3607
|
+
item_id: import_v416.z.string(),
|
|
3608
|
+
summary_index: import_v416.z.number(),
|
|
3609
|
+
delta: import_v416.z.string()
|
|
3413
3610
|
});
|
|
3414
|
-
var openaiResponsesChunkSchema =
|
|
3611
|
+
var openaiResponsesChunkSchema = import_v416.z.union([
|
|
3415
3612
|
textDeltaChunkSchema,
|
|
3416
3613
|
responseFinishedChunkSchema,
|
|
3417
3614
|
responseCreatedChunkSchema,
|
|
3418
3615
|
responseOutputItemAddedSchema,
|
|
3419
3616
|
responseOutputItemDoneSchema,
|
|
3420
3617
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3618
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3619
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
3421
3620
|
responseAnnotationAddedSchema,
|
|
3422
3621
|
responseReasoningSummaryPartAddedSchema,
|
|
3423
3622
|
responseReasoningSummaryTextDeltaSchema,
|
|
3424
3623
|
errorChunkSchema,
|
|
3425
|
-
|
|
3624
|
+
import_v416.z.object({ type: import_v416.z.string() }).loose()
|
|
3426
3625
|
// fallback for unknown chunks
|
|
3427
3626
|
]);
|
|
3428
3627
|
function isTextDeltaChunk(chunk) {
|
|
@@ -3443,6 +3642,12 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3443
3642
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3444
3643
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3445
3644
|
}
|
|
3645
|
+
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
3646
|
+
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
3647
|
+
}
|
|
3648
|
+
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
3649
|
+
return chunk.type === "response.code_interpreter_call_code.done";
|
|
3650
|
+
}
|
|
3446
3651
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3447
3652
|
return chunk.type === "response.output_item.added";
|
|
3448
3653
|
}
|
|
@@ -3495,15 +3700,15 @@ function getResponsesModelConfig(modelId) {
|
|
|
3495
3700
|
isReasoningModel: false
|
|
3496
3701
|
};
|
|
3497
3702
|
}
|
|
3498
|
-
var openaiResponsesProviderOptionsSchema =
|
|
3499
|
-
include:
|
|
3500
|
-
|
|
3703
|
+
var openaiResponsesProviderOptionsSchema = import_v416.z.object({
|
|
3704
|
+
include: import_v416.z.array(
|
|
3705
|
+
import_v416.z.enum([
|
|
3501
3706
|
"reasoning.encrypted_content",
|
|
3502
3707
|
"file_search_call.results",
|
|
3503
3708
|
"message.output_text.logprobs"
|
|
3504
3709
|
])
|
|
3505
3710
|
).nullish(),
|
|
3506
|
-
instructions:
|
|
3711
|
+
instructions: import_v416.z.string().nullish(),
|
|
3507
3712
|
/**
|
|
3508
3713
|
* Return the log probabilities of the tokens.
|
|
3509
3714
|
*
|
|
@@ -3516,33 +3721,33 @@ var openaiResponsesProviderOptionsSchema = import_v415.z.object({
|
|
|
3516
3721
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3517
3722
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3518
3723
|
*/
|
|
3519
|
-
logprobs:
|
|
3724
|
+
logprobs: import_v416.z.union([import_v416.z.boolean(), import_v416.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3520
3725
|
/**
|
|
3521
3726
|
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3522
3727
|
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3523
3728
|
* Any further attempts to call a tool by the model will be ignored.
|
|
3524
3729
|
*/
|
|
3525
|
-
maxToolCalls:
|
|
3526
|
-
metadata:
|
|
3527
|
-
parallelToolCalls:
|
|
3528
|
-
previousResponseId:
|
|
3529
|
-
promptCacheKey:
|
|
3530
|
-
reasoningEffort:
|
|
3531
|
-
reasoningSummary:
|
|
3532
|
-
safetyIdentifier:
|
|
3533
|
-
serviceTier:
|
|
3534
|
-
store:
|
|
3535
|
-
strictJsonSchema:
|
|
3536
|
-
textVerbosity:
|
|
3537
|
-
user:
|
|
3730
|
+
maxToolCalls: import_v416.z.number().nullish(),
|
|
3731
|
+
metadata: import_v416.z.any().nullish(),
|
|
3732
|
+
parallelToolCalls: import_v416.z.boolean().nullish(),
|
|
3733
|
+
previousResponseId: import_v416.z.string().nullish(),
|
|
3734
|
+
promptCacheKey: import_v416.z.string().nullish(),
|
|
3735
|
+
reasoningEffort: import_v416.z.string().nullish(),
|
|
3736
|
+
reasoningSummary: import_v416.z.string().nullish(),
|
|
3737
|
+
safetyIdentifier: import_v416.z.string().nullish(),
|
|
3738
|
+
serviceTier: import_v416.z.enum(["auto", "flex", "priority"]).nullish(),
|
|
3739
|
+
store: import_v416.z.boolean().nullish(),
|
|
3740
|
+
strictJsonSchema: import_v416.z.boolean().nullish(),
|
|
3741
|
+
textVerbosity: import_v416.z.enum(["low", "medium", "high"]).nullish(),
|
|
3742
|
+
user: import_v416.z.string().nullish()
|
|
3538
3743
|
});
|
|
3539
3744
|
|
|
3540
3745
|
// src/speech/openai-speech-model.ts
|
|
3541
|
-
var
|
|
3542
|
-
var
|
|
3543
|
-
var OpenAIProviderOptionsSchema =
|
|
3544
|
-
instructions:
|
|
3545
|
-
speed:
|
|
3746
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
3747
|
+
var import_v417 = require("zod/v4");
|
|
3748
|
+
var OpenAIProviderOptionsSchema = import_v417.z.object({
|
|
3749
|
+
instructions: import_v417.z.string().nullish(),
|
|
3750
|
+
speed: import_v417.z.number().min(0.25).max(4).default(1).nullish()
|
|
3546
3751
|
});
|
|
3547
3752
|
var OpenAISpeechModel = class {
|
|
3548
3753
|
constructor(modelId, config) {
|
|
@@ -3563,7 +3768,7 @@ var OpenAISpeechModel = class {
|
|
|
3563
3768
|
providerOptions
|
|
3564
3769
|
}) {
|
|
3565
3770
|
const warnings = [];
|
|
3566
|
-
const openAIOptions = await (0,
|
|
3771
|
+
const openAIOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
3567
3772
|
provider: "openai",
|
|
3568
3773
|
providerOptions,
|
|
3569
3774
|
schema: OpenAIProviderOptionsSchema
|
|
@@ -3616,15 +3821,15 @@ var OpenAISpeechModel = class {
|
|
|
3616
3821
|
value: audio,
|
|
3617
3822
|
responseHeaders,
|
|
3618
3823
|
rawValue: rawResponse
|
|
3619
|
-
} = await (0,
|
|
3824
|
+
} = await (0, import_provider_utils15.postJsonToApi)({
|
|
3620
3825
|
url: this.config.url({
|
|
3621
3826
|
path: "/audio/speech",
|
|
3622
3827
|
modelId: this.modelId
|
|
3623
3828
|
}),
|
|
3624
|
-
headers: (0,
|
|
3829
|
+
headers: (0, import_provider_utils15.combineHeaders)(this.config.headers(), options.headers),
|
|
3625
3830
|
body: requestBody,
|
|
3626
3831
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3627
|
-
successfulResponseHandler: (0,
|
|
3832
|
+
successfulResponseHandler: (0, import_provider_utils15.createBinaryResponseHandler)(),
|
|
3628
3833
|
abortSignal: options.abortSignal,
|
|
3629
3834
|
fetch: this.config.fetch
|
|
3630
3835
|
});
|
|
@@ -3645,34 +3850,34 @@ var OpenAISpeechModel = class {
|
|
|
3645
3850
|
};
|
|
3646
3851
|
|
|
3647
3852
|
// src/transcription/openai-transcription-model.ts
|
|
3648
|
-
var
|
|
3649
|
-
var
|
|
3853
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
3854
|
+
var import_v419 = require("zod/v4");
|
|
3650
3855
|
|
|
3651
3856
|
// src/transcription/openai-transcription-options.ts
|
|
3652
|
-
var
|
|
3653
|
-
var openAITranscriptionProviderOptions =
|
|
3857
|
+
var import_v418 = require("zod/v4");
|
|
3858
|
+
var openAITranscriptionProviderOptions = import_v418.z.object({
|
|
3654
3859
|
/**
|
|
3655
3860
|
* Additional information to include in the transcription response.
|
|
3656
3861
|
*/
|
|
3657
|
-
include:
|
|
3862
|
+
include: import_v418.z.array(import_v418.z.string()).optional(),
|
|
3658
3863
|
/**
|
|
3659
3864
|
* The language of the input audio in ISO-639-1 format.
|
|
3660
3865
|
*/
|
|
3661
|
-
language:
|
|
3866
|
+
language: import_v418.z.string().optional(),
|
|
3662
3867
|
/**
|
|
3663
3868
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
3664
3869
|
*/
|
|
3665
|
-
prompt:
|
|
3870
|
+
prompt: import_v418.z.string().optional(),
|
|
3666
3871
|
/**
|
|
3667
3872
|
* The sampling temperature, between 0 and 1.
|
|
3668
3873
|
* @default 0
|
|
3669
3874
|
*/
|
|
3670
|
-
temperature:
|
|
3875
|
+
temperature: import_v418.z.number().min(0).max(1).default(0).optional(),
|
|
3671
3876
|
/**
|
|
3672
3877
|
* The timestamp granularities to populate for this transcription.
|
|
3673
3878
|
* @default ['segment']
|
|
3674
3879
|
*/
|
|
3675
|
-
timestampGranularities:
|
|
3880
|
+
timestampGranularities: import_v418.z.array(import_v418.z.enum(["word", "segment"])).default(["segment"]).optional()
|
|
3676
3881
|
});
|
|
3677
3882
|
|
|
3678
3883
|
// src/transcription/openai-transcription-model.ts
|
|
@@ -3750,15 +3955,15 @@ var OpenAITranscriptionModel = class {
|
|
|
3750
3955
|
providerOptions
|
|
3751
3956
|
}) {
|
|
3752
3957
|
const warnings = [];
|
|
3753
|
-
const openAIOptions = await (0,
|
|
3958
|
+
const openAIOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
3754
3959
|
provider: "openai",
|
|
3755
3960
|
providerOptions,
|
|
3756
3961
|
schema: openAITranscriptionProviderOptions
|
|
3757
3962
|
});
|
|
3758
3963
|
const formData = new FormData();
|
|
3759
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0,
|
|
3964
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils16.convertBase64ToUint8Array)(audio)]);
|
|
3760
3965
|
formData.append("model", this.modelId);
|
|
3761
|
-
const fileExtension = (0,
|
|
3966
|
+
const fileExtension = (0, import_provider_utils16.mediaTypeToExtension)(mediaType);
|
|
3762
3967
|
formData.append(
|
|
3763
3968
|
"file",
|
|
3764
3969
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -3803,15 +4008,15 @@ var OpenAITranscriptionModel = class {
|
|
|
3803
4008
|
value: response,
|
|
3804
4009
|
responseHeaders,
|
|
3805
4010
|
rawValue: rawResponse
|
|
3806
|
-
} = await (0,
|
|
4011
|
+
} = await (0, import_provider_utils16.postFormDataToApi)({
|
|
3807
4012
|
url: this.config.url({
|
|
3808
4013
|
path: "/audio/transcriptions",
|
|
3809
4014
|
modelId: this.modelId
|
|
3810
4015
|
}),
|
|
3811
|
-
headers: (0,
|
|
4016
|
+
headers: (0, import_provider_utils16.combineHeaders)(this.config.headers(), options.headers),
|
|
3812
4017
|
formData,
|
|
3813
4018
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3814
|
-
successfulResponseHandler: (0,
|
|
4019
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3815
4020
|
openaiTranscriptionResponseSchema
|
|
3816
4021
|
),
|
|
3817
4022
|
abortSignal: options.abortSignal,
|
|
@@ -3841,48 +4046,59 @@ var OpenAITranscriptionModel = class {
|
|
|
3841
4046
|
};
|
|
3842
4047
|
}
|
|
3843
4048
|
};
|
|
3844
|
-
var openaiTranscriptionResponseSchema =
|
|
3845
|
-
text:
|
|
3846
|
-
language:
|
|
3847
|
-
duration:
|
|
3848
|
-
words:
|
|
3849
|
-
|
|
3850
|
-
word:
|
|
3851
|
-
start:
|
|
3852
|
-
end:
|
|
4049
|
+
var openaiTranscriptionResponseSchema = import_v419.z.object({
|
|
4050
|
+
text: import_v419.z.string(),
|
|
4051
|
+
language: import_v419.z.string().nullish(),
|
|
4052
|
+
duration: import_v419.z.number().nullish(),
|
|
4053
|
+
words: import_v419.z.array(
|
|
4054
|
+
import_v419.z.object({
|
|
4055
|
+
word: import_v419.z.string(),
|
|
4056
|
+
start: import_v419.z.number(),
|
|
4057
|
+
end: import_v419.z.number()
|
|
3853
4058
|
})
|
|
3854
4059
|
).nullish(),
|
|
3855
|
-
segments:
|
|
3856
|
-
|
|
3857
|
-
id:
|
|
3858
|
-
seek:
|
|
3859
|
-
start:
|
|
3860
|
-
end:
|
|
3861
|
-
text:
|
|
3862
|
-
tokens:
|
|
3863
|
-
temperature:
|
|
3864
|
-
avg_logprob:
|
|
3865
|
-
compression_ratio:
|
|
3866
|
-
no_speech_prob:
|
|
4060
|
+
segments: import_v419.z.array(
|
|
4061
|
+
import_v419.z.object({
|
|
4062
|
+
id: import_v419.z.number(),
|
|
4063
|
+
seek: import_v419.z.number(),
|
|
4064
|
+
start: import_v419.z.number(),
|
|
4065
|
+
end: import_v419.z.number(),
|
|
4066
|
+
text: import_v419.z.string(),
|
|
4067
|
+
tokens: import_v419.z.array(import_v419.z.number()),
|
|
4068
|
+
temperature: import_v419.z.number(),
|
|
4069
|
+
avg_logprob: import_v419.z.number(),
|
|
4070
|
+
compression_ratio: import_v419.z.number(),
|
|
4071
|
+
no_speech_prob: import_v419.z.number()
|
|
3867
4072
|
})
|
|
3868
4073
|
).nullish()
|
|
3869
4074
|
});
|
|
3870
4075
|
|
|
4076
|
+
// src/version.ts
|
|
4077
|
+
var VERSION = true ? "2.1.0-beta.10" : "0.0.0-test";
|
|
4078
|
+
|
|
3871
4079
|
// src/openai-provider.ts
|
|
3872
4080
|
function createOpenAI(options = {}) {
|
|
3873
4081
|
var _a, _b;
|
|
3874
|
-
const baseURL = (_a = (0,
|
|
4082
|
+
const baseURL = (_a = (0, import_provider_utils17.withoutTrailingSlash)(
|
|
4083
|
+
(0, import_provider_utils17.loadOptionalSetting)({
|
|
4084
|
+
settingValue: options.baseURL,
|
|
4085
|
+
environmentVariableName: "OPENAI_BASE_URL"
|
|
4086
|
+
})
|
|
4087
|
+
)) != null ? _a : "https://api.openai.com/v1";
|
|
3875
4088
|
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
3876
|
-
const getHeaders = () => (
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
4089
|
+
const getHeaders = () => (0, import_provider_utils17.withUserAgentSuffix)(
|
|
4090
|
+
{
|
|
4091
|
+
Authorization: `Bearer ${(0, import_provider_utils17.loadApiKey)({
|
|
4092
|
+
apiKey: options.apiKey,
|
|
4093
|
+
environmentVariableName: "OPENAI_API_KEY",
|
|
4094
|
+
description: "OpenAI"
|
|
4095
|
+
})}`,
|
|
4096
|
+
"OpenAI-Organization": options.organization,
|
|
4097
|
+
"OpenAI-Project": options.project,
|
|
4098
|
+
...options.headers
|
|
4099
|
+
},
|
|
4100
|
+
`ai-sdk/openai/${VERSION}`
|
|
4101
|
+
);
|
|
3886
4102
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
3887
4103
|
provider: `${providerName}.chat`,
|
|
3888
4104
|
url: ({ path }) => `${baseURL}${path}`,
|
|
@@ -3958,6 +4174,7 @@ function createOpenAI(options = {}) {
|
|
|
3958
4174
|
var openai = createOpenAI();
|
|
3959
4175
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3960
4176
|
0 && (module.exports = {
|
|
4177
|
+
VERSION,
|
|
3961
4178
|
createOpenAI,
|
|
3962
4179
|
openai
|
|
3963
4180
|
});
|