@zenning/openai 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +108 -0
- package/dist/index.d.mts +86 -27
- package/dist/index.d.ts +86 -27
- package/dist/index.js +662 -417
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +638 -392
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +339 -24
- package/dist/internal/index.d.ts +339 -24
- package/dist/internal/index.js +667 -419
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +638 -401
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -20,22 +20,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
VERSION: () => VERSION,
|
|
23
24
|
createOpenAI: () => createOpenAI,
|
|
24
25
|
openai: () => openai
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
27
28
|
|
|
28
29
|
// src/openai-provider.ts
|
|
29
|
-
var
|
|
30
|
+
var import_provider_utils17 = require("@zenning/provider-utils");
|
|
30
31
|
|
|
31
32
|
// src/chat/openai-chat-language-model.ts
|
|
32
33
|
var import_provider3 = require("@zenning/provider");
|
|
33
|
-
var import_provider_utils3 = require("@
|
|
34
|
+
var import_provider_utils3 = require("@zenning/provider-utils");
|
|
34
35
|
var import_v43 = require("zod/v4");
|
|
35
36
|
|
|
36
37
|
// src/openai-error.ts
|
|
37
38
|
var import_v4 = require("zod/v4");
|
|
38
|
-
var import_provider_utils = require("@
|
|
39
|
+
var import_provider_utils = require("@zenning/provider-utils");
|
|
39
40
|
var openaiErrorDataSchema = import_v4.z.object({
|
|
40
41
|
error: import_v4.z.object({
|
|
41
42
|
message: import_v4.z.string(),
|
|
@@ -54,7 +55,7 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
|
54
55
|
|
|
55
56
|
// src/chat/convert-to-openai-chat-messages.ts
|
|
56
57
|
var import_provider = require("@zenning/provider");
|
|
57
|
-
var import_provider_utils2 = require("@
|
|
58
|
+
var import_provider_utils2 = require("@zenning/provider-utils");
|
|
58
59
|
function convertToOpenAIChatMessages({
|
|
59
60
|
prompt,
|
|
60
61
|
systemMessageMode = "system"
|
|
@@ -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) {
|
|
@@ -1069,7 +1070,7 @@ var reasoningModels = {
|
|
|
1069
1070
|
};
|
|
1070
1071
|
|
|
1071
1072
|
// src/completion/openai-completion-language-model.ts
|
|
1072
|
-
var import_provider_utils4 = require("@
|
|
1073
|
+
var import_provider_utils4 = require("@zenning/provider-utils");
|
|
1073
1074
|
var import_v45 = require("zod/v4");
|
|
1074
1075
|
|
|
1075
1076
|
// src/completion/convert-to-openai-completion-prompt.ts
|
|
@@ -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
|
};
|
|
@@ -1495,7 +1496,7 @@ var openaiCompletionChunkSchema = import_v45.z.union([
|
|
|
1495
1496
|
|
|
1496
1497
|
// src/embedding/openai-embedding-model.ts
|
|
1497
1498
|
var import_provider5 = require("@zenning/provider");
|
|
1498
|
-
var import_provider_utils5 = require("@
|
|
1499
|
+
var import_provider_utils5 = require("@zenning/provider-utils");
|
|
1499
1500
|
var import_v47 = require("zod/v4");
|
|
1500
1501
|
|
|
1501
1502
|
// src/embedding/openai-embedding-options.ts
|
|
@@ -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;
|
|
@@ -1582,7 +1583,7 @@ var openaiTextEmbeddingResponseSchema = import_v47.z.object({
|
|
|
1582
1583
|
});
|
|
1583
1584
|
|
|
1584
1585
|
// src/image/openai-image-model.ts
|
|
1585
|
-
var import_provider_utils6 = require("@
|
|
1586
|
+
var import_provider_utils6 = require("@zenning/provider-utils");
|
|
1586
1587
|
var import_v48 = require("zod/v4");
|
|
1587
1588
|
|
|
1588
1589
|
// src/image/openai-image-options.ts
|
|
@@ -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;
|
|
@@ -1678,7 +1679,7 @@ var openaiImageResponseSchema = import_v48.z.object({
|
|
|
1678
1679
|
});
|
|
1679
1680
|
|
|
1680
1681
|
// src/tool/code-interpreter.ts
|
|
1681
|
-
var import_provider_utils7 = require("@
|
|
1682
|
+
var import_provider_utils7 = require("@zenning/provider-utils");
|
|
1682
1683
|
var import_v49 = require("zod/v4");
|
|
1683
1684
|
var codeInterpreterInputSchema = import_v49.z.object({
|
|
1684
1685
|
code: import_v49.z.string().nullish(),
|
|
@@ -1711,7 +1712,7 @@ var codeInterpreter = (args = {}) => {
|
|
|
1711
1712
|
};
|
|
1712
1713
|
|
|
1713
1714
|
// src/tool/file-search.ts
|
|
1714
|
-
var import_provider_utils8 = require("@
|
|
1715
|
+
var import_provider_utils8 = require("@zenning/provider-utils");
|
|
1715
1716
|
var import_v410 = require("zod/v4");
|
|
1716
1717
|
var comparisonFilterSchema = import_v410.z.object({
|
|
1717
1718
|
key: import_v410.z.string(),
|
|
@@ -1753,7 +1754,7 @@ var fileSearch = (0, import_provider_utils8.createProviderDefinedToolFactoryWith
|
|
|
1753
1754
|
});
|
|
1754
1755
|
|
|
1755
1756
|
// src/tool/image-generation.ts
|
|
1756
|
-
var import_provider_utils9 = require("@
|
|
1757
|
+
var import_provider_utils9 = require("@zenning/provider-utils");
|
|
1757
1758
|
var import_v411 = require("zod/v4");
|
|
1758
1759
|
var imageGenerationArgsSchema = import_v411.z.object({
|
|
1759
1760
|
background: import_v411.z.enum(["auto", "opaque", "transparent"]).optional(),
|
|
@@ -1766,6 +1767,7 @@ var imageGenerationArgsSchema = import_v411.z.object({
|
|
|
1766
1767
|
moderation: import_v411.z.enum(["auto"]).optional(),
|
|
1767
1768
|
outputCompression: import_v411.z.number().int().min(0).max(100).optional(),
|
|
1768
1769
|
outputFormat: import_v411.z.enum(["png", "jpeg", "webp"]).optional(),
|
|
1770
|
+
partialImages: import_v411.z.number().int().min(0).max(3).optional(),
|
|
1769
1771
|
quality: import_v411.z.enum(["auto", "low", "medium", "high"]).optional(),
|
|
1770
1772
|
size: import_v411.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
|
|
1771
1773
|
}).strict();
|
|
@@ -1782,39 +1784,62 @@ var imageGeneration = (args = {}) => {
|
|
|
1782
1784
|
return imageGenerationToolFactory(args);
|
|
1783
1785
|
};
|
|
1784
1786
|
|
|
1785
|
-
// src/tool/
|
|
1786
|
-
var import_provider_utils10 = require("@
|
|
1787
|
+
// src/tool/local-shell.ts
|
|
1788
|
+
var import_provider_utils10 = require("@zenning/provider-utils");
|
|
1787
1789
|
var import_v412 = require("zod/v4");
|
|
1788
|
-
var
|
|
1789
|
-
|
|
1790
|
-
|
|
1790
|
+
var localShellInputSchema = import_v412.z.object({
|
|
1791
|
+
action: import_v412.z.object({
|
|
1792
|
+
type: import_v412.z.literal("exec"),
|
|
1793
|
+
command: import_v412.z.array(import_v412.z.string()),
|
|
1794
|
+
timeoutMs: import_v412.z.number().optional(),
|
|
1795
|
+
user: import_v412.z.string().optional(),
|
|
1796
|
+
workingDirectory: import_v412.z.string().optional(),
|
|
1797
|
+
env: import_v412.z.record(import_v412.z.string(), import_v412.z.string()).optional()
|
|
1798
|
+
})
|
|
1799
|
+
});
|
|
1800
|
+
var localShellOutputSchema = import_v412.z.object({
|
|
1801
|
+
output: import_v412.z.string()
|
|
1802
|
+
});
|
|
1803
|
+
var localShell = (0, import_provider_utils10.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
1804
|
+
id: "openai.local_shell",
|
|
1805
|
+
name: "local_shell",
|
|
1806
|
+
inputSchema: localShellInputSchema,
|
|
1807
|
+
outputSchema: localShellOutputSchema
|
|
1808
|
+
});
|
|
1809
|
+
|
|
1810
|
+
// src/tool/web-search.ts
|
|
1811
|
+
var import_provider_utils11 = require("@zenning/provider-utils");
|
|
1812
|
+
var import_v413 = require("zod/v4");
|
|
1813
|
+
var webSearchArgsSchema = import_v413.z.object({
|
|
1814
|
+
filters: import_v413.z.object({
|
|
1815
|
+
allowedDomains: import_v413.z.array(import_v413.z.string()).optional()
|
|
1791
1816
|
}).optional(),
|
|
1792
|
-
searchContextSize:
|
|
1793
|
-
userLocation:
|
|
1794
|
-
type:
|
|
1795
|
-
country:
|
|
1796
|
-
city:
|
|
1797
|
-
region:
|
|
1798
|
-
timezone:
|
|
1817
|
+
searchContextSize: import_v413.z.enum(["low", "medium", "high"]).optional(),
|
|
1818
|
+
userLocation: import_v413.z.object({
|
|
1819
|
+
type: import_v413.z.literal("approximate"),
|
|
1820
|
+
country: import_v413.z.string().optional(),
|
|
1821
|
+
city: import_v413.z.string().optional(),
|
|
1822
|
+
region: import_v413.z.string().optional(),
|
|
1823
|
+
timezone: import_v413.z.string().optional()
|
|
1799
1824
|
}).optional()
|
|
1800
1825
|
});
|
|
1801
|
-
var webSearchToolFactory = (0,
|
|
1826
|
+
var webSearchToolFactory = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1802
1827
|
id: "openai.web_search",
|
|
1803
1828
|
name: "web_search",
|
|
1804
|
-
inputSchema:
|
|
1805
|
-
action:
|
|
1806
|
-
|
|
1807
|
-
type:
|
|
1808
|
-
query:
|
|
1829
|
+
inputSchema: import_v413.z.object({
|
|
1830
|
+
action: import_v413.z.discriminatedUnion("type", [
|
|
1831
|
+
import_v413.z.object({
|
|
1832
|
+
type: import_v413.z.literal("search"),
|
|
1833
|
+
query: import_v413.z.string().nullish()
|
|
1809
1834
|
}),
|
|
1810
|
-
|
|
1811
|
-
type:
|
|
1812
|
-
url:
|
|
1835
|
+
import_v413.z.object({
|
|
1836
|
+
type: import_v413.z.literal("open_page"),
|
|
1837
|
+
url: import_v413.z.string()
|
|
1813
1838
|
}),
|
|
1814
|
-
|
|
1815
|
-
type:
|
|
1816
|
-
url:
|
|
1817
|
-
pattern:
|
|
1839
|
+
import_v413.z.object({
|
|
1840
|
+
type: import_v413.z.literal("find"),
|
|
1841
|
+
url: import_v413.z.string(),
|
|
1842
|
+
pattern: import_v413.z.string()
|
|
1818
1843
|
})
|
|
1819
1844
|
]).nullish()
|
|
1820
1845
|
})
|
|
@@ -1824,59 +1849,59 @@ var webSearch = (args = {}) => {
|
|
|
1824
1849
|
};
|
|
1825
1850
|
|
|
1826
1851
|
// src/tool/web-search-preview.ts
|
|
1827
|
-
var
|
|
1828
|
-
var
|
|
1829
|
-
var webSearchPreviewArgsSchema =
|
|
1852
|
+
var import_provider_utils12 = require("@zenning/provider-utils");
|
|
1853
|
+
var import_v414 = require("zod/v4");
|
|
1854
|
+
var webSearchPreviewArgsSchema = import_v414.z.object({
|
|
1830
1855
|
/**
|
|
1831
1856
|
* Search context size to use for the web search.
|
|
1832
1857
|
* - high: Most comprehensive context, highest cost, slower response
|
|
1833
1858
|
* - medium: Balanced context, cost, and latency (default)
|
|
1834
1859
|
* - low: Least context, lowest cost, fastest response
|
|
1835
1860
|
*/
|
|
1836
|
-
searchContextSize:
|
|
1861
|
+
searchContextSize: import_v414.z.enum(["low", "medium", "high"]).optional(),
|
|
1837
1862
|
/**
|
|
1838
1863
|
* User location information to provide geographically relevant search results.
|
|
1839
1864
|
*/
|
|
1840
|
-
userLocation:
|
|
1865
|
+
userLocation: import_v414.z.object({
|
|
1841
1866
|
/**
|
|
1842
1867
|
* Type of location (always 'approximate')
|
|
1843
1868
|
*/
|
|
1844
|
-
type:
|
|
1869
|
+
type: import_v414.z.literal("approximate"),
|
|
1845
1870
|
/**
|
|
1846
1871
|
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
1847
1872
|
*/
|
|
1848
|
-
country:
|
|
1873
|
+
country: import_v414.z.string().optional(),
|
|
1849
1874
|
/**
|
|
1850
1875
|
* City name (free text, e.g., 'Minneapolis')
|
|
1851
1876
|
*/
|
|
1852
|
-
city:
|
|
1877
|
+
city: import_v414.z.string().optional(),
|
|
1853
1878
|
/**
|
|
1854
1879
|
* Region name (free text, e.g., 'Minnesota')
|
|
1855
1880
|
*/
|
|
1856
|
-
region:
|
|
1881
|
+
region: import_v414.z.string().optional(),
|
|
1857
1882
|
/**
|
|
1858
1883
|
* IANA timezone (e.g., 'America/Chicago')
|
|
1859
1884
|
*/
|
|
1860
|
-
timezone:
|
|
1885
|
+
timezone: import_v414.z.string().optional()
|
|
1861
1886
|
}).optional()
|
|
1862
1887
|
});
|
|
1863
|
-
var webSearchPreview = (0,
|
|
1888
|
+
var webSearchPreview = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
1864
1889
|
id: "openai.web_search_preview",
|
|
1865
1890
|
name: "web_search_preview",
|
|
1866
|
-
inputSchema:
|
|
1867
|
-
action:
|
|
1868
|
-
|
|
1869
|
-
type:
|
|
1870
|
-
query:
|
|
1891
|
+
inputSchema: import_v414.z.object({
|
|
1892
|
+
action: import_v414.z.discriminatedUnion("type", [
|
|
1893
|
+
import_v414.z.object({
|
|
1894
|
+
type: import_v414.z.literal("search"),
|
|
1895
|
+
query: import_v414.z.string().nullish()
|
|
1871
1896
|
}),
|
|
1872
|
-
|
|
1873
|
-
type:
|
|
1874
|
-
url:
|
|
1897
|
+
import_v414.z.object({
|
|
1898
|
+
type: import_v414.z.literal("open_page"),
|
|
1899
|
+
url: import_v414.z.string()
|
|
1875
1900
|
}),
|
|
1876
|
-
|
|
1877
|
-
type:
|
|
1878
|
-
url:
|
|
1879
|
-
pattern:
|
|
1901
|
+
import_v414.z.object({
|
|
1902
|
+
type: import_v414.z.literal("find"),
|
|
1903
|
+
url: import_v414.z.string(),
|
|
1904
|
+
pattern: import_v414.z.string()
|
|
1880
1905
|
})
|
|
1881
1906
|
]).nullish()
|
|
1882
1907
|
})
|
|
@@ -1914,13 +1939,27 @@ var openaiTools = {
|
|
|
1914
1939
|
*
|
|
1915
1940
|
* Must have name `image_generation`.
|
|
1916
1941
|
*
|
|
1917
|
-
* @param
|
|
1918
|
-
* @param
|
|
1919
|
-
* @param
|
|
1920
|
-
* @param
|
|
1921
|
-
* @param
|
|
1942
|
+
* @param background - Background type for the generated image. One of 'auto', 'opaque', or 'transparent'.
|
|
1943
|
+
* @param inputFidelity - Input fidelity for the generated image. One of 'low' or 'high'.
|
|
1944
|
+
* @param inputImageMask - Optional mask for inpainting. Contains fileId and/or imageUrl.
|
|
1945
|
+
* @param model - The image generation model to use. Default: gpt-image-1.
|
|
1946
|
+
* @param moderation - Moderation level for the generated image. Default: 'auto'.
|
|
1947
|
+
* @param outputCompression - Compression level for the output image (0-100).
|
|
1948
|
+
* @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
|
|
1949
|
+
* @param partialImages - Number of partial images to generate in streaming mode (0-3).
|
|
1950
|
+
* @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or 'high'.
|
|
1951
|
+
* @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
|
|
1922
1952
|
*/
|
|
1923
1953
|
imageGeneration,
|
|
1954
|
+
/**
|
|
1955
|
+
* Local shell is a tool that allows agents to run shell commands locally
|
|
1956
|
+
* on a machine you or the user provides.
|
|
1957
|
+
*
|
|
1958
|
+
* Supported models: `gpt-5-codex` and `codex-mini-latest`
|
|
1959
|
+
*
|
|
1960
|
+
* Must have name `local_shell`.
|
|
1961
|
+
*/
|
|
1962
|
+
localShell,
|
|
1924
1963
|
/**
|
|
1925
1964
|
* Web search allows models to access up-to-date information from the internet
|
|
1926
1965
|
* and provide answers with sourced citations.
|
|
@@ -1948,13 +1987,13 @@ var openaiTools = {
|
|
|
1948
1987
|
|
|
1949
1988
|
// src/responses/openai-responses-language-model.ts
|
|
1950
1989
|
var import_provider8 = require("@zenning/provider");
|
|
1951
|
-
var
|
|
1952
|
-
var
|
|
1990
|
+
var import_provider_utils14 = require("@zenning/provider-utils");
|
|
1991
|
+
var import_v416 = require("zod/v4");
|
|
1953
1992
|
|
|
1954
1993
|
// src/responses/convert-to-openai-responses-input.ts
|
|
1955
1994
|
var import_provider6 = require("@zenning/provider");
|
|
1956
|
-
var
|
|
1957
|
-
var
|
|
1995
|
+
var import_provider_utils13 = require("@zenning/provider-utils");
|
|
1996
|
+
var import_v415 = require("zod/v4");
|
|
1958
1997
|
function isFileId(data, prefixes) {
|
|
1959
1998
|
if (!prefixes) return false;
|
|
1960
1999
|
return prefixes.some((prefix) => data.startsWith(prefix));
|
|
@@ -1963,9 +2002,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
1963
2002
|
prompt,
|
|
1964
2003
|
systemMessageMode,
|
|
1965
2004
|
fileIdPrefixes,
|
|
1966
|
-
store
|
|
2005
|
+
store,
|
|
2006
|
+
hasLocalShellTool = false
|
|
1967
2007
|
}) {
|
|
1968
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2008
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1969
2009
|
const input = [];
|
|
1970
2010
|
const warnings = [];
|
|
1971
2011
|
for (const { role, content } of prompt) {
|
|
@@ -2011,7 +2051,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2011
2051
|
return {
|
|
2012
2052
|
type: "input_image",
|
|
2013
2053
|
...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,
|
|
2054
|
+
image_url: `data:${mediaType};base64,${(0, import_provider_utils13.convertToBase64)(part.data)}`
|
|
2015
2055
|
},
|
|
2016
2056
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
|
|
2017
2057
|
};
|
|
@@ -2026,7 +2066,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2026
2066
|
type: "input_file",
|
|
2027
2067
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
2028
2068
|
filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
|
|
2029
|
-
file_data: `data:application/pdf;base64,${(0,
|
|
2069
|
+
file_data: `data:application/pdf;base64,${(0, import_provider_utils13.convertToBase64)(part.data)}`
|
|
2030
2070
|
}
|
|
2031
2071
|
};
|
|
2032
2072
|
} else {
|
|
@@ -2058,12 +2098,29 @@ async function convertToOpenAIResponsesInput({
|
|
|
2058
2098
|
if (part.providerExecuted) {
|
|
2059
2099
|
break;
|
|
2060
2100
|
}
|
|
2101
|
+
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2102
|
+
const parsedInput = localShellInputSchema.parse(part.input);
|
|
2103
|
+
input.push({
|
|
2104
|
+
type: "local_shell_call",
|
|
2105
|
+
call_id: part.toolCallId,
|
|
2106
|
+
id: (_f = (_e = (_d = part.providerOptions) == null ? void 0 : _d.openai) == null ? void 0 : _e.itemId) != null ? _f : void 0,
|
|
2107
|
+
action: {
|
|
2108
|
+
type: "exec",
|
|
2109
|
+
command: parsedInput.action.command,
|
|
2110
|
+
timeout_ms: parsedInput.action.timeoutMs,
|
|
2111
|
+
user: parsedInput.action.user,
|
|
2112
|
+
working_directory: parsedInput.action.workingDirectory,
|
|
2113
|
+
env: parsedInput.action.env
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
break;
|
|
2117
|
+
}
|
|
2061
2118
|
input.push({
|
|
2062
2119
|
type: "function_call",
|
|
2063
2120
|
call_id: part.toolCallId,
|
|
2064
2121
|
name: part.toolName,
|
|
2065
2122
|
arguments: JSON.stringify(part.input),
|
|
2066
|
-
id: (
|
|
2123
|
+
id: (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.itemId) != null ? _i : void 0
|
|
2067
2124
|
});
|
|
2068
2125
|
break;
|
|
2069
2126
|
}
|
|
@@ -2080,33 +2137,47 @@ async function convertToOpenAIResponsesInput({
|
|
|
2080
2137
|
break;
|
|
2081
2138
|
}
|
|
2082
2139
|
case "reasoning": {
|
|
2083
|
-
const providerOptions = await (0,
|
|
2140
|
+
const providerOptions = await (0, import_provider_utils13.parseProviderOptions)({
|
|
2084
2141
|
provider: "openai",
|
|
2085
2142
|
providerOptions: part.providerOptions,
|
|
2086
2143
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
2087
2144
|
});
|
|
2088
2145
|
const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
|
|
2089
2146
|
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]);
|
|
2147
|
+
const reasoningMessage = reasoningMessages[reasoningId];
|
|
2148
|
+
if (store) {
|
|
2149
|
+
if (reasoningMessage === void 0) {
|
|
2150
|
+
input.push({ type: "item_reference", id: reasoningId });
|
|
2151
|
+
reasoningMessages[reasoningId] = {
|
|
2152
|
+
type: "reasoning",
|
|
2153
|
+
id: reasoningId,
|
|
2154
|
+
summary: []
|
|
2155
|
+
};
|
|
2156
|
+
}
|
|
2108
2157
|
} else {
|
|
2109
|
-
|
|
2158
|
+
const summaryParts = [];
|
|
2159
|
+
if (part.text.length > 0) {
|
|
2160
|
+
summaryParts.push({
|
|
2161
|
+
type: "summary_text",
|
|
2162
|
+
text: part.text
|
|
2163
|
+
});
|
|
2164
|
+
} else if (reasoningMessage !== void 0) {
|
|
2165
|
+
warnings.push({
|
|
2166
|
+
type: "other",
|
|
2167
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
if (reasoningMessage === void 0) {
|
|
2171
|
+
reasoningMessages[reasoningId] = {
|
|
2172
|
+
type: "reasoning",
|
|
2173
|
+
id: reasoningId,
|
|
2174
|
+
encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
|
|
2175
|
+
summary: summaryParts
|
|
2176
|
+
};
|
|
2177
|
+
input.push(reasoningMessages[reasoningId]);
|
|
2178
|
+
} else {
|
|
2179
|
+
reasoningMessage.summary.push(...summaryParts);
|
|
2180
|
+
}
|
|
2110
2181
|
}
|
|
2111
2182
|
} else {
|
|
2112
2183
|
warnings.push({
|
|
@@ -2123,6 +2194,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2123
2194
|
case "tool": {
|
|
2124
2195
|
for (const part of content) {
|
|
2125
2196
|
const output = part.output;
|
|
2197
|
+
if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
|
|
2198
|
+
input.push({
|
|
2199
|
+
type: "local_shell_call_output",
|
|
2200
|
+
call_id: part.toolCallId,
|
|
2201
|
+
output: localShellOutputSchema.parse(output.value).output
|
|
2202
|
+
});
|
|
2203
|
+
break;
|
|
2204
|
+
}
|
|
2126
2205
|
let contentValue;
|
|
2127
2206
|
switch (output.type) {
|
|
2128
2207
|
case "text":
|
|
@@ -2151,9 +2230,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2151
2230
|
}
|
|
2152
2231
|
return { input, warnings };
|
|
2153
2232
|
}
|
|
2154
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
2155
|
-
itemId:
|
|
2156
|
-
reasoningEncryptedContent:
|
|
2233
|
+
var openaiResponsesReasoningProviderOptionsSchema = import_v415.z.object({
|
|
2234
|
+
itemId: import_v415.z.string().nullish(),
|
|
2235
|
+
reasoningEncryptedContent: import_v415.z.string().nullish()
|
|
2157
2236
|
});
|
|
2158
2237
|
|
|
2159
2238
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
@@ -2214,6 +2293,12 @@ function prepareResponsesTools({
|
|
|
2214
2293
|
});
|
|
2215
2294
|
break;
|
|
2216
2295
|
}
|
|
2296
|
+
case "openai.local_shell": {
|
|
2297
|
+
openaiTools2.push({
|
|
2298
|
+
type: "local_shell"
|
|
2299
|
+
});
|
|
2300
|
+
break;
|
|
2301
|
+
}
|
|
2217
2302
|
case "openai.web_search_preview": {
|
|
2218
2303
|
const args = webSearchPreviewArgsSchema.parse(tool.args);
|
|
2219
2304
|
openaiTools2.push({
|
|
@@ -2252,11 +2337,12 @@ function prepareResponsesTools({
|
|
|
2252
2337
|
image_url: args.inputImageMask.imageUrl
|
|
2253
2338
|
} : void 0,
|
|
2254
2339
|
model: args.model,
|
|
2255
|
-
size: args.size,
|
|
2256
|
-
quality: args.quality,
|
|
2257
2340
|
moderation: args.moderation,
|
|
2341
|
+
partial_images: args.partialImages,
|
|
2342
|
+
quality: args.quality,
|
|
2343
|
+
output_compression: args.outputCompression,
|
|
2258
2344
|
output_format: args.outputFormat,
|
|
2259
|
-
|
|
2345
|
+
size: args.size
|
|
2260
2346
|
});
|
|
2261
2347
|
break;
|
|
2262
2348
|
}
|
|
@@ -2293,73 +2379,86 @@ function prepareResponsesTools({
|
|
|
2293
2379
|
}
|
|
2294
2380
|
|
|
2295
2381
|
// src/responses/openai-responses-language-model.ts
|
|
2296
|
-
var webSearchCallItem =
|
|
2297
|
-
type:
|
|
2298
|
-
id:
|
|
2299
|
-
status:
|
|
2300
|
-
action:
|
|
2301
|
-
|
|
2302
|
-
type:
|
|
2303
|
-
query:
|
|
2382
|
+
var webSearchCallItem = import_v416.z.object({
|
|
2383
|
+
type: import_v416.z.literal("web_search_call"),
|
|
2384
|
+
id: import_v416.z.string(),
|
|
2385
|
+
status: import_v416.z.string(),
|
|
2386
|
+
action: import_v416.z.discriminatedUnion("type", [
|
|
2387
|
+
import_v416.z.object({
|
|
2388
|
+
type: import_v416.z.literal("search"),
|
|
2389
|
+
query: import_v416.z.string().nullish()
|
|
2304
2390
|
}),
|
|
2305
|
-
|
|
2306
|
-
type:
|
|
2307
|
-
url:
|
|
2391
|
+
import_v416.z.object({
|
|
2392
|
+
type: import_v416.z.literal("open_page"),
|
|
2393
|
+
url: import_v416.z.string()
|
|
2308
2394
|
}),
|
|
2309
|
-
|
|
2310
|
-
type:
|
|
2311
|
-
url:
|
|
2312
|
-
pattern:
|
|
2395
|
+
import_v416.z.object({
|
|
2396
|
+
type: import_v416.z.literal("find"),
|
|
2397
|
+
url: import_v416.z.string(),
|
|
2398
|
+
pattern: import_v416.z.string()
|
|
2313
2399
|
})
|
|
2314
2400
|
]).nullish()
|
|
2315
2401
|
});
|
|
2316
|
-
var fileSearchCallItem =
|
|
2317
|
-
type:
|
|
2318
|
-
id:
|
|
2319
|
-
queries:
|
|
2320
|
-
results:
|
|
2321
|
-
|
|
2322
|
-
attributes:
|
|
2323
|
-
file_id:
|
|
2324
|
-
filename:
|
|
2325
|
-
score:
|
|
2326
|
-
text:
|
|
2402
|
+
var fileSearchCallItem = import_v416.z.object({
|
|
2403
|
+
type: import_v416.z.literal("file_search_call"),
|
|
2404
|
+
id: import_v416.z.string(),
|
|
2405
|
+
queries: import_v416.z.array(import_v416.z.string()),
|
|
2406
|
+
results: import_v416.z.array(
|
|
2407
|
+
import_v416.z.object({
|
|
2408
|
+
attributes: import_v416.z.record(import_v416.z.string(), import_v416.z.unknown()),
|
|
2409
|
+
file_id: import_v416.z.string(),
|
|
2410
|
+
filename: import_v416.z.string(),
|
|
2411
|
+
score: import_v416.z.number(),
|
|
2412
|
+
text: import_v416.z.string()
|
|
2327
2413
|
})
|
|
2328
2414
|
).nullish()
|
|
2329
2415
|
});
|
|
2330
|
-
var codeInterpreterCallItem =
|
|
2331
|
-
type:
|
|
2332
|
-
id:
|
|
2333
|
-
code:
|
|
2334
|
-
container_id:
|
|
2335
|
-
outputs:
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2416
|
+
var codeInterpreterCallItem = import_v416.z.object({
|
|
2417
|
+
type: import_v416.z.literal("code_interpreter_call"),
|
|
2418
|
+
id: import_v416.z.string(),
|
|
2419
|
+
code: import_v416.z.string().nullable(),
|
|
2420
|
+
container_id: import_v416.z.string(),
|
|
2421
|
+
outputs: import_v416.z.array(
|
|
2422
|
+
import_v416.z.discriminatedUnion("type", [
|
|
2423
|
+
import_v416.z.object({ type: import_v416.z.literal("logs"), logs: import_v416.z.string() }),
|
|
2424
|
+
import_v416.z.object({ type: import_v416.z.literal("image"), url: import_v416.z.string() })
|
|
2339
2425
|
])
|
|
2340
2426
|
).nullable()
|
|
2341
2427
|
});
|
|
2342
|
-
var
|
|
2343
|
-
type:
|
|
2344
|
-
id:
|
|
2345
|
-
|
|
2428
|
+
var localShellCallItem = import_v416.z.object({
|
|
2429
|
+
type: import_v416.z.literal("local_shell_call"),
|
|
2430
|
+
id: import_v416.z.string(),
|
|
2431
|
+
call_id: import_v416.z.string(),
|
|
2432
|
+
action: import_v416.z.object({
|
|
2433
|
+
type: import_v416.z.literal("exec"),
|
|
2434
|
+
command: import_v416.z.array(import_v416.z.string()),
|
|
2435
|
+
timeout_ms: import_v416.z.number().optional(),
|
|
2436
|
+
user: import_v416.z.string().optional(),
|
|
2437
|
+
working_directory: import_v416.z.string().optional(),
|
|
2438
|
+
env: import_v416.z.record(import_v416.z.string(), import_v416.z.string()).optional()
|
|
2439
|
+
})
|
|
2440
|
+
});
|
|
2441
|
+
var imageGenerationCallItem = import_v416.z.object({
|
|
2442
|
+
type: import_v416.z.literal("image_generation_call"),
|
|
2443
|
+
id: import_v416.z.string(),
|
|
2444
|
+
result: import_v416.z.string()
|
|
2346
2445
|
});
|
|
2347
2446
|
var TOP_LOGPROBS_MAX = 20;
|
|
2348
|
-
var LOGPROBS_SCHEMA =
|
|
2349
|
-
|
|
2350
|
-
token:
|
|
2351
|
-
logprob:
|
|
2352
|
-
top_logprobs:
|
|
2353
|
-
|
|
2354
|
-
token:
|
|
2355
|
-
logprob:
|
|
2447
|
+
var LOGPROBS_SCHEMA = import_v416.z.array(
|
|
2448
|
+
import_v416.z.object({
|
|
2449
|
+
token: import_v416.z.string(),
|
|
2450
|
+
logprob: import_v416.z.number(),
|
|
2451
|
+
top_logprobs: import_v416.z.array(
|
|
2452
|
+
import_v416.z.object({
|
|
2453
|
+
token: import_v416.z.string(),
|
|
2454
|
+
logprob: import_v416.z.number()
|
|
2356
2455
|
})
|
|
2357
2456
|
)
|
|
2358
2457
|
})
|
|
2359
2458
|
);
|
|
2360
2459
|
var OpenAIResponsesLanguageModel = class {
|
|
2361
2460
|
constructor(modelId, config) {
|
|
2362
|
-
this.specificationVersion = "
|
|
2461
|
+
this.specificationVersion = "v3";
|
|
2363
2462
|
this.supportedUrls = {
|
|
2364
2463
|
"image/*": [/^https?:\/\/.*$/],
|
|
2365
2464
|
"application/pdf": [/^https?:\/\/.*$/]
|
|
@@ -2409,7 +2508,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2409
2508
|
if (stopSequences != null) {
|
|
2410
2509
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
2411
2510
|
}
|
|
2412
|
-
const openaiOptions = await (0,
|
|
2511
|
+
const openaiOptions = await (0, import_provider_utils14.parseProviderOptions)({
|
|
2413
2512
|
provider: "openai",
|
|
2414
2513
|
providerOptions,
|
|
2415
2514
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -2418,7 +2517,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2418
2517
|
prompt,
|
|
2419
2518
|
systemMessageMode: modelConfig.systemMessageMode,
|
|
2420
2519
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
2421
|
-
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
|
|
2520
|
+
store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
|
|
2521
|
+
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
2422
2522
|
});
|
|
2423
2523
|
warnings.push(...inputWarnings);
|
|
2424
2524
|
const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
|
|
@@ -2577,51 +2677,51 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2577
2677
|
responseHeaders,
|
|
2578
2678
|
value: response,
|
|
2579
2679
|
rawValue: rawResponse
|
|
2580
|
-
} = await (0,
|
|
2680
|
+
} = await (0, import_provider_utils14.postJsonToApi)({
|
|
2581
2681
|
url,
|
|
2582
|
-
headers: (0,
|
|
2682
|
+
headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
|
|
2583
2683
|
body,
|
|
2584
2684
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2585
|
-
successfulResponseHandler: (0,
|
|
2586
|
-
|
|
2587
|
-
id:
|
|
2588
|
-
created_at:
|
|
2589
|
-
error:
|
|
2590
|
-
code:
|
|
2591
|
-
message:
|
|
2685
|
+
successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
|
|
2686
|
+
import_v416.z.object({
|
|
2687
|
+
id: import_v416.z.string(),
|
|
2688
|
+
created_at: import_v416.z.number(),
|
|
2689
|
+
error: import_v416.z.object({
|
|
2690
|
+
code: import_v416.z.string(),
|
|
2691
|
+
message: import_v416.z.string()
|
|
2592
2692
|
}).nullish(),
|
|
2593
|
-
model:
|
|
2594
|
-
output:
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
type:
|
|
2598
|
-
role:
|
|
2599
|
-
id:
|
|
2600
|
-
content:
|
|
2601
|
-
|
|
2602
|
-
type:
|
|
2603
|
-
text:
|
|
2693
|
+
model: import_v416.z.string(),
|
|
2694
|
+
output: import_v416.z.array(
|
|
2695
|
+
import_v416.z.discriminatedUnion("type", [
|
|
2696
|
+
import_v416.z.object({
|
|
2697
|
+
type: import_v416.z.literal("message"),
|
|
2698
|
+
role: import_v416.z.literal("assistant"),
|
|
2699
|
+
id: import_v416.z.string(),
|
|
2700
|
+
content: import_v416.z.array(
|
|
2701
|
+
import_v416.z.object({
|
|
2702
|
+
type: import_v416.z.literal("output_text"),
|
|
2703
|
+
text: import_v416.z.string(),
|
|
2604
2704
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2605
|
-
annotations:
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
type:
|
|
2609
|
-
start_index:
|
|
2610
|
-
end_index:
|
|
2611
|
-
url:
|
|
2612
|
-
title:
|
|
2705
|
+
annotations: import_v416.z.array(
|
|
2706
|
+
import_v416.z.discriminatedUnion("type", [
|
|
2707
|
+
import_v416.z.object({
|
|
2708
|
+
type: import_v416.z.literal("url_citation"),
|
|
2709
|
+
start_index: import_v416.z.number(),
|
|
2710
|
+
end_index: import_v416.z.number(),
|
|
2711
|
+
url: import_v416.z.string(),
|
|
2712
|
+
title: import_v416.z.string()
|
|
2613
2713
|
}),
|
|
2614
|
-
|
|
2615
|
-
type:
|
|
2616
|
-
file_id:
|
|
2617
|
-
filename:
|
|
2618
|
-
index:
|
|
2619
|
-
start_index:
|
|
2620
|
-
end_index:
|
|
2621
|
-
quote:
|
|
2714
|
+
import_v416.z.object({
|
|
2715
|
+
type: import_v416.z.literal("file_citation"),
|
|
2716
|
+
file_id: import_v416.z.string(),
|
|
2717
|
+
filename: import_v416.z.string().nullish(),
|
|
2718
|
+
index: import_v416.z.number().nullish(),
|
|
2719
|
+
start_index: import_v416.z.number().nullish(),
|
|
2720
|
+
end_index: import_v416.z.number().nullish(),
|
|
2721
|
+
quote: import_v416.z.string().nullish()
|
|
2622
2722
|
}),
|
|
2623
|
-
|
|
2624
|
-
type:
|
|
2723
|
+
import_v416.z.object({
|
|
2724
|
+
type: import_v416.z.literal("container_file_citation")
|
|
2625
2725
|
})
|
|
2626
2726
|
])
|
|
2627
2727
|
)
|
|
@@ -2632,33 +2732,34 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2632
2732
|
fileSearchCallItem,
|
|
2633
2733
|
codeInterpreterCallItem,
|
|
2634
2734
|
imageGenerationCallItem,
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2735
|
+
localShellCallItem,
|
|
2736
|
+
import_v416.z.object({
|
|
2737
|
+
type: import_v416.z.literal("function_call"),
|
|
2738
|
+
call_id: import_v416.z.string(),
|
|
2739
|
+
name: import_v416.z.string(),
|
|
2740
|
+
arguments: import_v416.z.string(),
|
|
2741
|
+
id: import_v416.z.string()
|
|
2641
2742
|
}),
|
|
2642
|
-
|
|
2643
|
-
type:
|
|
2644
|
-
id:
|
|
2645
|
-
status:
|
|
2743
|
+
import_v416.z.object({
|
|
2744
|
+
type: import_v416.z.literal("computer_call"),
|
|
2745
|
+
id: import_v416.z.string(),
|
|
2746
|
+
status: import_v416.z.string().optional()
|
|
2646
2747
|
}),
|
|
2647
|
-
|
|
2648
|
-
type:
|
|
2649
|
-
id:
|
|
2650
|
-
encrypted_content:
|
|
2651
|
-
summary:
|
|
2652
|
-
|
|
2653
|
-
type:
|
|
2654
|
-
text:
|
|
2748
|
+
import_v416.z.object({
|
|
2749
|
+
type: import_v416.z.literal("reasoning"),
|
|
2750
|
+
id: import_v416.z.string(),
|
|
2751
|
+
encrypted_content: import_v416.z.string().nullish(),
|
|
2752
|
+
summary: import_v416.z.array(
|
|
2753
|
+
import_v416.z.object({
|
|
2754
|
+
type: import_v416.z.literal("summary_text"),
|
|
2755
|
+
text: import_v416.z.string()
|
|
2655
2756
|
})
|
|
2656
2757
|
)
|
|
2657
2758
|
})
|
|
2658
2759
|
])
|
|
2659
2760
|
),
|
|
2660
|
-
service_tier:
|
|
2661
|
-
incomplete_details:
|
|
2761
|
+
service_tier: import_v416.z.string().nullish(),
|
|
2762
|
+
incomplete_details: import_v416.z.object({ reason: import_v416.z.string() }).nullish(),
|
|
2662
2763
|
usage: usageSchema2
|
|
2663
2764
|
})
|
|
2664
2765
|
),
|
|
@@ -2718,6 +2819,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2718
2819
|
});
|
|
2719
2820
|
break;
|
|
2720
2821
|
}
|
|
2822
|
+
case "local_shell_call": {
|
|
2823
|
+
content.push({
|
|
2824
|
+
type: "tool-call",
|
|
2825
|
+
toolCallId: part.call_id,
|
|
2826
|
+
toolName: "local_shell",
|
|
2827
|
+
input: JSON.stringify({ action: part.action }),
|
|
2828
|
+
providerMetadata: {
|
|
2829
|
+
openai: {
|
|
2830
|
+
itemId: part.id
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
});
|
|
2834
|
+
break;
|
|
2835
|
+
}
|
|
2721
2836
|
case "message": {
|
|
2722
2837
|
for (const contentPart of part.content) {
|
|
2723
2838
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
@@ -2737,7 +2852,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2737
2852
|
content.push({
|
|
2738
2853
|
type: "source",
|
|
2739
2854
|
sourceType: "url",
|
|
2740
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0,
|
|
2855
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils14.generateId)(),
|
|
2741
2856
|
url: annotation.url,
|
|
2742
2857
|
title: annotation.title
|
|
2743
2858
|
});
|
|
@@ -2745,7 +2860,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2745
2860
|
content.push({
|
|
2746
2861
|
type: "source",
|
|
2747
2862
|
sourceType: "document",
|
|
2748
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0,
|
|
2863
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils14.generateId)(),
|
|
2749
2864
|
mediaType: "text/plain",
|
|
2750
2865
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
2751
2866
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
@@ -2900,18 +3015,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2900
3015
|
warnings,
|
|
2901
3016
|
webSearchToolName
|
|
2902
3017
|
} = await this.getArgs(options);
|
|
2903
|
-
const { responseHeaders, value: response } = await (0,
|
|
3018
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
|
|
2904
3019
|
url: this.config.url({
|
|
2905
3020
|
path: "/responses",
|
|
2906
3021
|
modelId: this.modelId
|
|
2907
3022
|
}),
|
|
2908
|
-
headers: (0,
|
|
3023
|
+
headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
|
|
2909
3024
|
body: {
|
|
2910
3025
|
...body,
|
|
2911
3026
|
stream: true
|
|
2912
3027
|
},
|
|
2913
3028
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
2914
|
-
successfulResponseHandler: (0,
|
|
3029
|
+
successfulResponseHandler: (0, import_provider_utils14.createEventSourceResponseHandler)(
|
|
2915
3030
|
openaiResponsesChunkSchema
|
|
2916
3031
|
),
|
|
2917
3032
|
abortSignal: options.abortSignal,
|
|
@@ -2978,6 +3093,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2978
3093
|
id: value.item.id,
|
|
2979
3094
|
toolName: "computer_use"
|
|
2980
3095
|
});
|
|
3096
|
+
} else if (value.item.type === "code_interpreter_call") {
|
|
3097
|
+
ongoingToolCalls[value.output_index] = {
|
|
3098
|
+
toolName: "code_interpreter",
|
|
3099
|
+
toolCallId: value.item.id,
|
|
3100
|
+
codeInterpreter: {
|
|
3101
|
+
containerId: value.item.container_id
|
|
3102
|
+
}
|
|
3103
|
+
};
|
|
3104
|
+
controller.enqueue({
|
|
3105
|
+
type: "tool-input-start",
|
|
3106
|
+
id: value.item.id,
|
|
3107
|
+
toolName: "code_interpreter"
|
|
3108
|
+
});
|
|
3109
|
+
controller.enqueue({
|
|
3110
|
+
type: "tool-input-delta",
|
|
3111
|
+
id: value.item.id,
|
|
3112
|
+
delta: `{"containerId":"${value.item.container_id}","code":"`
|
|
3113
|
+
});
|
|
2981
3114
|
} else if (value.item.type === "file_search_call") {
|
|
2982
3115
|
controller.enqueue({
|
|
2983
3116
|
type: "tool-call",
|
|
@@ -3101,16 +3234,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3101
3234
|
providerExecuted: true
|
|
3102
3235
|
});
|
|
3103
3236
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3104
|
-
|
|
3105
|
-
type: "tool-call",
|
|
3106
|
-
toolCallId: value.item.id,
|
|
3107
|
-
toolName: "code_interpreter",
|
|
3108
|
-
input: JSON.stringify({
|
|
3109
|
-
code: value.item.code,
|
|
3110
|
-
containerId: value.item.container_id
|
|
3111
|
-
}),
|
|
3112
|
-
providerExecuted: true
|
|
3113
|
-
});
|
|
3237
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3114
3238
|
controller.enqueue({
|
|
3115
3239
|
type: "tool-result",
|
|
3116
3240
|
toolCallId: value.item.id,
|
|
@@ -3130,6 +3254,26 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3130
3254
|
},
|
|
3131
3255
|
providerExecuted: true
|
|
3132
3256
|
});
|
|
3257
|
+
} else if (value.item.type === "local_shell_call") {
|
|
3258
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3259
|
+
controller.enqueue({
|
|
3260
|
+
type: "tool-call",
|
|
3261
|
+
toolCallId: value.item.call_id,
|
|
3262
|
+
toolName: "local_shell",
|
|
3263
|
+
input: JSON.stringify({
|
|
3264
|
+
action: {
|
|
3265
|
+
type: "exec",
|
|
3266
|
+
command: value.item.action.command,
|
|
3267
|
+
timeoutMs: value.item.action.timeout_ms,
|
|
3268
|
+
user: value.item.action.user,
|
|
3269
|
+
workingDirectory: value.item.action.working_directory,
|
|
3270
|
+
env: value.item.action.env
|
|
3271
|
+
}
|
|
3272
|
+
}),
|
|
3273
|
+
providerMetadata: {
|
|
3274
|
+
openai: { itemId: value.item.id }
|
|
3275
|
+
}
|
|
3276
|
+
});
|
|
3133
3277
|
} else if (value.item.type === "message") {
|
|
3134
3278
|
controller.enqueue({
|
|
3135
3279
|
type: "text-end",
|
|
@@ -3160,6 +3304,51 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3160
3304
|
delta: value.delta
|
|
3161
3305
|
});
|
|
3162
3306
|
}
|
|
3307
|
+
} else if (isResponseImageGenerationCallPartialImageChunk(value)) {
|
|
3308
|
+
controller.enqueue({
|
|
3309
|
+
type: "tool-result",
|
|
3310
|
+
toolCallId: value.item_id,
|
|
3311
|
+
toolName: "image_generation",
|
|
3312
|
+
result: {
|
|
3313
|
+
result: value.partial_image_b64
|
|
3314
|
+
},
|
|
3315
|
+
providerExecuted: true,
|
|
3316
|
+
preliminary: true
|
|
3317
|
+
});
|
|
3318
|
+
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3319
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3320
|
+
if (toolCall != null) {
|
|
3321
|
+
controller.enqueue({
|
|
3322
|
+
type: "tool-input-delta",
|
|
3323
|
+
id: toolCall.toolCallId,
|
|
3324
|
+
// The delta is code, which is embedding in a JSON string.
|
|
3325
|
+
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
3326
|
+
delta: JSON.stringify(value.delta).slice(1, -1)
|
|
3327
|
+
});
|
|
3328
|
+
}
|
|
3329
|
+
} else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
3330
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3331
|
+
if (toolCall != null) {
|
|
3332
|
+
controller.enqueue({
|
|
3333
|
+
type: "tool-input-delta",
|
|
3334
|
+
id: toolCall.toolCallId,
|
|
3335
|
+
delta: '"}'
|
|
3336
|
+
});
|
|
3337
|
+
controller.enqueue({
|
|
3338
|
+
type: "tool-input-end",
|
|
3339
|
+
id: toolCall.toolCallId
|
|
3340
|
+
});
|
|
3341
|
+
controller.enqueue({
|
|
3342
|
+
type: "tool-call",
|
|
3343
|
+
toolCallId: toolCall.toolCallId,
|
|
3344
|
+
toolName: "code_interpreter",
|
|
3345
|
+
input: JSON.stringify({
|
|
3346
|
+
code: value.code,
|
|
3347
|
+
containerId: toolCall.codeInterpreter.containerId
|
|
3348
|
+
}),
|
|
3349
|
+
providerExecuted: true
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3163
3352
|
} else if (isResponseCreatedChunk(value)) {
|
|
3164
3353
|
responseId = value.response.id;
|
|
3165
3354
|
controller.enqueue({
|
|
@@ -3222,7 +3411,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3222
3411
|
controller.enqueue({
|
|
3223
3412
|
type: "source",
|
|
3224
3413
|
sourceType: "url",
|
|
3225
|
-
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0,
|
|
3414
|
+
id: (_q = (_p = (_o = self.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils14.generateId)(),
|
|
3226
3415
|
url: value.annotation.url,
|
|
3227
3416
|
title: value.annotation.title
|
|
3228
3417
|
});
|
|
@@ -3230,7 +3419,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3230
3419
|
controller.enqueue({
|
|
3231
3420
|
type: "source",
|
|
3232
3421
|
sourceType: "document",
|
|
3233
|
-
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0,
|
|
3422
|
+
id: (_t = (_s = (_r = self.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils14.generateId)(),
|
|
3234
3423
|
mediaType: "text/plain",
|
|
3235
3424
|
title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
|
|
3236
3425
|
filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id,
|
|
@@ -3269,166 +3458,201 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3269
3458
|
};
|
|
3270
3459
|
}
|
|
3271
3460
|
};
|
|
3272
|
-
var usageSchema2 =
|
|
3273
|
-
input_tokens:
|
|
3274
|
-
input_tokens_details:
|
|
3275
|
-
output_tokens:
|
|
3276
|
-
output_tokens_details:
|
|
3461
|
+
var usageSchema2 = import_v416.z.object({
|
|
3462
|
+
input_tokens: import_v416.z.number(),
|
|
3463
|
+
input_tokens_details: import_v416.z.object({ cached_tokens: import_v416.z.number().nullish() }).nullish(),
|
|
3464
|
+
output_tokens: import_v416.z.number(),
|
|
3465
|
+
output_tokens_details: import_v416.z.object({ reasoning_tokens: import_v416.z.number().nullish() }).nullish()
|
|
3277
3466
|
});
|
|
3278
|
-
var textDeltaChunkSchema =
|
|
3279
|
-
type:
|
|
3280
|
-
item_id:
|
|
3281
|
-
delta:
|
|
3467
|
+
var textDeltaChunkSchema = import_v416.z.object({
|
|
3468
|
+
type: import_v416.z.literal("response.output_text.delta"),
|
|
3469
|
+
item_id: import_v416.z.string(),
|
|
3470
|
+
delta: import_v416.z.string(),
|
|
3282
3471
|
logprobs: LOGPROBS_SCHEMA.nullish()
|
|
3283
3472
|
});
|
|
3284
|
-
var errorChunkSchema =
|
|
3285
|
-
type:
|
|
3286
|
-
code:
|
|
3287
|
-
message:
|
|
3288
|
-
param:
|
|
3289
|
-
sequence_number:
|
|
3473
|
+
var errorChunkSchema = import_v416.z.object({
|
|
3474
|
+
type: import_v416.z.literal("error"),
|
|
3475
|
+
code: import_v416.z.string(),
|
|
3476
|
+
message: import_v416.z.string(),
|
|
3477
|
+
param: import_v416.z.string().nullish(),
|
|
3478
|
+
sequence_number: import_v416.z.number()
|
|
3290
3479
|
});
|
|
3291
|
-
var responseFinishedChunkSchema =
|
|
3292
|
-
type:
|
|
3293
|
-
response:
|
|
3294
|
-
incomplete_details:
|
|
3480
|
+
var responseFinishedChunkSchema = import_v416.z.object({
|
|
3481
|
+
type: import_v416.z.enum(["response.completed", "response.incomplete"]),
|
|
3482
|
+
response: import_v416.z.object({
|
|
3483
|
+
incomplete_details: import_v416.z.object({ reason: import_v416.z.string() }).nullish(),
|
|
3295
3484
|
usage: usageSchema2,
|
|
3296
|
-
service_tier:
|
|
3485
|
+
service_tier: import_v416.z.string().nullish()
|
|
3297
3486
|
})
|
|
3298
3487
|
});
|
|
3299
|
-
var responseCreatedChunkSchema =
|
|
3300
|
-
type:
|
|
3301
|
-
response:
|
|
3302
|
-
id:
|
|
3303
|
-
created_at:
|
|
3304
|
-
model:
|
|
3305
|
-
service_tier:
|
|
3488
|
+
var responseCreatedChunkSchema = import_v416.z.object({
|
|
3489
|
+
type: import_v416.z.literal("response.created"),
|
|
3490
|
+
response: import_v416.z.object({
|
|
3491
|
+
id: import_v416.z.string(),
|
|
3492
|
+
created_at: import_v416.z.number(),
|
|
3493
|
+
model: import_v416.z.string(),
|
|
3494
|
+
service_tier: import_v416.z.string().nullish()
|
|
3306
3495
|
})
|
|
3307
3496
|
});
|
|
3308
|
-
var responseOutputItemAddedSchema =
|
|
3309
|
-
type:
|
|
3310
|
-
output_index:
|
|
3311
|
-
item:
|
|
3312
|
-
|
|
3313
|
-
type:
|
|
3314
|
-
id:
|
|
3497
|
+
var responseOutputItemAddedSchema = import_v416.z.object({
|
|
3498
|
+
type: import_v416.z.literal("response.output_item.added"),
|
|
3499
|
+
output_index: import_v416.z.number(),
|
|
3500
|
+
item: import_v416.z.discriminatedUnion("type", [
|
|
3501
|
+
import_v416.z.object({
|
|
3502
|
+
type: import_v416.z.literal("message"),
|
|
3503
|
+
id: import_v416.z.string()
|
|
3315
3504
|
}),
|
|
3316
|
-
|
|
3317
|
-
type:
|
|
3318
|
-
id:
|
|
3319
|
-
encrypted_content:
|
|
3505
|
+
import_v416.z.object({
|
|
3506
|
+
type: import_v416.z.literal("reasoning"),
|
|
3507
|
+
id: import_v416.z.string(),
|
|
3508
|
+
encrypted_content: import_v416.z.string().nullish()
|
|
3320
3509
|
}),
|
|
3321
|
-
|
|
3322
|
-
type:
|
|
3323
|
-
id:
|
|
3324
|
-
call_id:
|
|
3325
|
-
name:
|
|
3326
|
-
arguments:
|
|
3510
|
+
import_v416.z.object({
|
|
3511
|
+
type: import_v416.z.literal("function_call"),
|
|
3512
|
+
id: import_v416.z.string(),
|
|
3513
|
+
call_id: import_v416.z.string(),
|
|
3514
|
+
name: import_v416.z.string(),
|
|
3515
|
+
arguments: import_v416.z.string()
|
|
3327
3516
|
}),
|
|
3328
|
-
|
|
3329
|
-
type:
|
|
3330
|
-
id:
|
|
3331
|
-
status:
|
|
3332
|
-
action:
|
|
3333
|
-
type:
|
|
3334
|
-
query:
|
|
3517
|
+
import_v416.z.object({
|
|
3518
|
+
type: import_v416.z.literal("web_search_call"),
|
|
3519
|
+
id: import_v416.z.string(),
|
|
3520
|
+
status: import_v416.z.string(),
|
|
3521
|
+
action: import_v416.z.object({
|
|
3522
|
+
type: import_v416.z.literal("search"),
|
|
3523
|
+
query: import_v416.z.string().optional()
|
|
3335
3524
|
}).nullish()
|
|
3336
3525
|
}),
|
|
3337
|
-
|
|
3338
|
-
type:
|
|
3339
|
-
id:
|
|
3340
|
-
status:
|
|
3526
|
+
import_v416.z.object({
|
|
3527
|
+
type: import_v416.z.literal("computer_call"),
|
|
3528
|
+
id: import_v416.z.string(),
|
|
3529
|
+
status: import_v416.z.string()
|
|
3341
3530
|
}),
|
|
3342
|
-
|
|
3343
|
-
type:
|
|
3344
|
-
id:
|
|
3531
|
+
import_v416.z.object({
|
|
3532
|
+
type: import_v416.z.literal("file_search_call"),
|
|
3533
|
+
id: import_v416.z.string()
|
|
3345
3534
|
}),
|
|
3346
|
-
|
|
3347
|
-
type:
|
|
3348
|
-
id:
|
|
3535
|
+
import_v416.z.object({
|
|
3536
|
+
type: import_v416.z.literal("image_generation_call"),
|
|
3537
|
+
id: import_v416.z.string()
|
|
3538
|
+
}),
|
|
3539
|
+
import_v416.z.object({
|
|
3540
|
+
type: import_v416.z.literal("code_interpreter_call"),
|
|
3541
|
+
id: import_v416.z.string(),
|
|
3542
|
+
container_id: import_v416.z.string(),
|
|
3543
|
+
code: import_v416.z.string().nullable(),
|
|
3544
|
+
outputs: import_v416.z.array(
|
|
3545
|
+
import_v416.z.discriminatedUnion("type", [
|
|
3546
|
+
import_v416.z.object({ type: import_v416.z.literal("logs"), logs: import_v416.z.string() }),
|
|
3547
|
+
import_v416.z.object({ type: import_v416.z.literal("image"), url: import_v416.z.string() })
|
|
3548
|
+
])
|
|
3549
|
+
).nullable(),
|
|
3550
|
+
status: import_v416.z.string()
|
|
3349
3551
|
})
|
|
3350
3552
|
])
|
|
3351
3553
|
});
|
|
3352
|
-
var responseOutputItemDoneSchema =
|
|
3353
|
-
type:
|
|
3354
|
-
output_index:
|
|
3355
|
-
item:
|
|
3356
|
-
|
|
3357
|
-
type:
|
|
3358
|
-
id:
|
|
3554
|
+
var responseOutputItemDoneSchema = import_v416.z.object({
|
|
3555
|
+
type: import_v416.z.literal("response.output_item.done"),
|
|
3556
|
+
output_index: import_v416.z.number(),
|
|
3557
|
+
item: import_v416.z.discriminatedUnion("type", [
|
|
3558
|
+
import_v416.z.object({
|
|
3559
|
+
type: import_v416.z.literal("message"),
|
|
3560
|
+
id: import_v416.z.string()
|
|
3359
3561
|
}),
|
|
3360
|
-
|
|
3361
|
-
type:
|
|
3362
|
-
id:
|
|
3363
|
-
encrypted_content:
|
|
3562
|
+
import_v416.z.object({
|
|
3563
|
+
type: import_v416.z.literal("reasoning"),
|
|
3564
|
+
id: import_v416.z.string(),
|
|
3565
|
+
encrypted_content: import_v416.z.string().nullish()
|
|
3364
3566
|
}),
|
|
3365
|
-
|
|
3366
|
-
type:
|
|
3367
|
-
id:
|
|
3368
|
-
call_id:
|
|
3369
|
-
name:
|
|
3370
|
-
arguments:
|
|
3371
|
-
status:
|
|
3567
|
+
import_v416.z.object({
|
|
3568
|
+
type: import_v416.z.literal("function_call"),
|
|
3569
|
+
id: import_v416.z.string(),
|
|
3570
|
+
call_id: import_v416.z.string(),
|
|
3571
|
+
name: import_v416.z.string(),
|
|
3572
|
+
arguments: import_v416.z.string(),
|
|
3573
|
+
status: import_v416.z.literal("completed")
|
|
3372
3574
|
}),
|
|
3373
3575
|
codeInterpreterCallItem,
|
|
3374
3576
|
imageGenerationCallItem,
|
|
3375
3577
|
webSearchCallItem,
|
|
3376
3578
|
fileSearchCallItem,
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3579
|
+
localShellCallItem,
|
|
3580
|
+
import_v416.z.object({
|
|
3581
|
+
type: import_v416.z.literal("computer_call"),
|
|
3582
|
+
id: import_v416.z.string(),
|
|
3583
|
+
status: import_v416.z.literal("completed")
|
|
3381
3584
|
})
|
|
3382
3585
|
])
|
|
3383
3586
|
});
|
|
3384
|
-
var responseFunctionCallArgumentsDeltaSchema =
|
|
3385
|
-
type:
|
|
3386
|
-
item_id:
|
|
3387
|
-
output_index:
|
|
3388
|
-
delta:
|
|
3587
|
+
var responseFunctionCallArgumentsDeltaSchema = import_v416.z.object({
|
|
3588
|
+
type: import_v416.z.literal("response.function_call_arguments.delta"),
|
|
3589
|
+
item_id: import_v416.z.string(),
|
|
3590
|
+
output_index: import_v416.z.number(),
|
|
3591
|
+
delta: import_v416.z.string()
|
|
3592
|
+
});
|
|
3593
|
+
var responseImageGenerationCallPartialImageSchema = import_v416.z.object({
|
|
3594
|
+
type: import_v416.z.literal("response.image_generation_call.partial_image"),
|
|
3595
|
+
item_id: import_v416.z.string(),
|
|
3596
|
+
output_index: import_v416.z.number(),
|
|
3597
|
+
partial_image_b64: import_v416.z.string()
|
|
3598
|
+
});
|
|
3599
|
+
var responseCodeInterpreterCallCodeDeltaSchema = import_v416.z.object({
|
|
3600
|
+
type: import_v416.z.literal("response.code_interpreter_call_code.delta"),
|
|
3601
|
+
item_id: import_v416.z.string(),
|
|
3602
|
+
output_index: import_v416.z.number(),
|
|
3603
|
+
delta: import_v416.z.string()
|
|
3389
3604
|
});
|
|
3390
|
-
var
|
|
3391
|
-
type:
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3605
|
+
var responseCodeInterpreterCallCodeDoneSchema = import_v416.z.object({
|
|
3606
|
+
type: import_v416.z.literal("response.code_interpreter_call_code.done"),
|
|
3607
|
+
item_id: import_v416.z.string(),
|
|
3608
|
+
output_index: import_v416.z.number(),
|
|
3609
|
+
code: import_v416.z.string()
|
|
3610
|
+
});
|
|
3611
|
+
var responseAnnotationAddedSchema = import_v416.z.object({
|
|
3612
|
+
type: import_v416.z.literal("response.output_text.annotation.added"),
|
|
3613
|
+
annotation: import_v416.z.discriminatedUnion("type", [
|
|
3614
|
+
import_v416.z.object({
|
|
3615
|
+
type: import_v416.z.literal("url_citation"),
|
|
3616
|
+
url: import_v416.z.string(),
|
|
3617
|
+
title: import_v416.z.string()
|
|
3397
3618
|
}),
|
|
3398
|
-
|
|
3399
|
-
type:
|
|
3400
|
-
file_id:
|
|
3401
|
-
filename:
|
|
3402
|
-
index:
|
|
3403
|
-
start_index:
|
|
3404
|
-
end_index:
|
|
3405
|
-
quote:
|
|
3619
|
+
import_v416.z.object({
|
|
3620
|
+
type: import_v416.z.literal("file_citation"),
|
|
3621
|
+
file_id: import_v416.z.string(),
|
|
3622
|
+
filename: import_v416.z.string().nullish(),
|
|
3623
|
+
index: import_v416.z.number().nullish(),
|
|
3624
|
+
start_index: import_v416.z.number().nullish(),
|
|
3625
|
+
end_index: import_v416.z.number().nullish(),
|
|
3626
|
+
quote: import_v416.z.string().nullish()
|
|
3406
3627
|
})
|
|
3407
3628
|
])
|
|
3408
3629
|
});
|
|
3409
|
-
var responseReasoningSummaryPartAddedSchema =
|
|
3410
|
-
type:
|
|
3411
|
-
item_id:
|
|
3412
|
-
summary_index:
|
|
3630
|
+
var responseReasoningSummaryPartAddedSchema = import_v416.z.object({
|
|
3631
|
+
type: import_v416.z.literal("response.reasoning_summary_part.added"),
|
|
3632
|
+
item_id: import_v416.z.string(),
|
|
3633
|
+
summary_index: import_v416.z.number()
|
|
3413
3634
|
});
|
|
3414
|
-
var responseReasoningSummaryTextDeltaSchema =
|
|
3415
|
-
type:
|
|
3416
|
-
item_id:
|
|
3417
|
-
summary_index:
|
|
3418
|
-
delta:
|
|
3635
|
+
var responseReasoningSummaryTextDeltaSchema = import_v416.z.object({
|
|
3636
|
+
type: import_v416.z.literal("response.reasoning_summary_text.delta"),
|
|
3637
|
+
item_id: import_v416.z.string(),
|
|
3638
|
+
summary_index: import_v416.z.number(),
|
|
3639
|
+
delta: import_v416.z.string()
|
|
3419
3640
|
});
|
|
3420
|
-
var openaiResponsesChunkSchema =
|
|
3641
|
+
var openaiResponsesChunkSchema = import_v416.z.union([
|
|
3421
3642
|
textDeltaChunkSchema,
|
|
3422
3643
|
responseFinishedChunkSchema,
|
|
3423
3644
|
responseCreatedChunkSchema,
|
|
3424
3645
|
responseOutputItemAddedSchema,
|
|
3425
3646
|
responseOutputItemDoneSchema,
|
|
3426
3647
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3648
|
+
responseImageGenerationCallPartialImageSchema,
|
|
3649
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3650
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
3427
3651
|
responseAnnotationAddedSchema,
|
|
3428
3652
|
responseReasoningSummaryPartAddedSchema,
|
|
3429
3653
|
responseReasoningSummaryTextDeltaSchema,
|
|
3430
3654
|
errorChunkSchema,
|
|
3431
|
-
|
|
3655
|
+
import_v416.z.object({ type: import_v416.z.string() }).loose()
|
|
3432
3656
|
// fallback for unknown chunks
|
|
3433
3657
|
]);
|
|
3434
3658
|
function isTextDeltaChunk(chunk) {
|
|
@@ -3449,6 +3673,15 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3449
3673
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3450
3674
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3451
3675
|
}
|
|
3676
|
+
function isResponseImageGenerationCallPartialImageChunk(chunk) {
|
|
3677
|
+
return chunk.type === "response.image_generation_call.partial_image";
|
|
3678
|
+
}
|
|
3679
|
+
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
3680
|
+
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
3681
|
+
}
|
|
3682
|
+
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
3683
|
+
return chunk.type === "response.code_interpreter_call_code.done";
|
|
3684
|
+
}
|
|
3452
3685
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3453
3686
|
return chunk.type === "response.output_item.added";
|
|
3454
3687
|
}
|
|
@@ -3501,15 +3734,15 @@ function getResponsesModelConfig(modelId) {
|
|
|
3501
3734
|
isReasoningModel: false
|
|
3502
3735
|
};
|
|
3503
3736
|
}
|
|
3504
|
-
var openaiResponsesProviderOptionsSchema =
|
|
3505
|
-
include:
|
|
3506
|
-
|
|
3737
|
+
var openaiResponsesProviderOptionsSchema = import_v416.z.object({
|
|
3738
|
+
include: import_v416.z.array(
|
|
3739
|
+
import_v416.z.enum([
|
|
3507
3740
|
"reasoning.encrypted_content",
|
|
3508
3741
|
"file_search_call.results",
|
|
3509
3742
|
"message.output_text.logprobs"
|
|
3510
3743
|
])
|
|
3511
3744
|
).nullish(),
|
|
3512
|
-
instructions:
|
|
3745
|
+
instructions: import_v416.z.string().nullish(),
|
|
3513
3746
|
/**
|
|
3514
3747
|
* Return the log probabilities of the tokens.
|
|
3515
3748
|
*
|
|
@@ -3522,33 +3755,33 @@ var openaiResponsesProviderOptionsSchema = import_v415.z.object({
|
|
|
3522
3755
|
* @see https://platform.openai.com/docs/api-reference/responses/create
|
|
3523
3756
|
* @see https://cookbook.openai.com/examples/using_logprobs
|
|
3524
3757
|
*/
|
|
3525
|
-
logprobs:
|
|
3758
|
+
logprobs: import_v416.z.union([import_v416.z.boolean(), import_v416.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
|
|
3526
3759
|
/**
|
|
3527
3760
|
* The maximum number of total calls to built-in tools that can be processed in a response.
|
|
3528
3761
|
* This maximum number applies across all built-in tool calls, not per individual tool.
|
|
3529
3762
|
* Any further attempts to call a tool by the model will be ignored.
|
|
3530
3763
|
*/
|
|
3531
|
-
maxToolCalls:
|
|
3532
|
-
metadata:
|
|
3533
|
-
parallelToolCalls:
|
|
3534
|
-
previousResponseId:
|
|
3535
|
-
promptCacheKey:
|
|
3536
|
-
reasoningEffort:
|
|
3537
|
-
reasoningSummary:
|
|
3538
|
-
safetyIdentifier:
|
|
3539
|
-
serviceTier:
|
|
3540
|
-
store:
|
|
3541
|
-
strictJsonSchema:
|
|
3542
|
-
textVerbosity:
|
|
3543
|
-
user:
|
|
3764
|
+
maxToolCalls: import_v416.z.number().nullish(),
|
|
3765
|
+
metadata: import_v416.z.any().nullish(),
|
|
3766
|
+
parallelToolCalls: import_v416.z.boolean().nullish(),
|
|
3767
|
+
previousResponseId: import_v416.z.string().nullish(),
|
|
3768
|
+
promptCacheKey: import_v416.z.string().nullish(),
|
|
3769
|
+
reasoningEffort: import_v416.z.string().nullish(),
|
|
3770
|
+
reasoningSummary: import_v416.z.string().nullish(),
|
|
3771
|
+
safetyIdentifier: import_v416.z.string().nullish(),
|
|
3772
|
+
serviceTier: import_v416.z.enum(["auto", "flex", "priority"]).nullish(),
|
|
3773
|
+
store: import_v416.z.boolean().nullish(),
|
|
3774
|
+
strictJsonSchema: import_v416.z.boolean().nullish(),
|
|
3775
|
+
textVerbosity: import_v416.z.enum(["low", "medium", "high"]).nullish(),
|
|
3776
|
+
user: import_v416.z.string().nullish()
|
|
3544
3777
|
});
|
|
3545
3778
|
|
|
3546
3779
|
// src/speech/openai-speech-model.ts
|
|
3547
|
-
var
|
|
3548
|
-
var
|
|
3549
|
-
var OpenAIProviderOptionsSchema =
|
|
3550
|
-
instructions:
|
|
3551
|
-
speed:
|
|
3780
|
+
var import_provider_utils15 = require("@zenning/provider-utils");
|
|
3781
|
+
var import_v417 = require("zod/v4");
|
|
3782
|
+
var OpenAIProviderOptionsSchema = import_v417.z.object({
|
|
3783
|
+
instructions: import_v417.z.string().nullish(),
|
|
3784
|
+
speed: import_v417.z.number().min(0.25).max(4).default(1).nullish()
|
|
3552
3785
|
});
|
|
3553
3786
|
var OpenAISpeechModel = class {
|
|
3554
3787
|
constructor(modelId, config) {
|
|
@@ -3569,7 +3802,7 @@ var OpenAISpeechModel = class {
|
|
|
3569
3802
|
providerOptions
|
|
3570
3803
|
}) {
|
|
3571
3804
|
const warnings = [];
|
|
3572
|
-
const openAIOptions = await (0,
|
|
3805
|
+
const openAIOptions = await (0, import_provider_utils15.parseProviderOptions)({
|
|
3573
3806
|
provider: "openai",
|
|
3574
3807
|
providerOptions,
|
|
3575
3808
|
schema: OpenAIProviderOptionsSchema
|
|
@@ -3622,15 +3855,15 @@ var OpenAISpeechModel = class {
|
|
|
3622
3855
|
value: audio,
|
|
3623
3856
|
responseHeaders,
|
|
3624
3857
|
rawValue: rawResponse
|
|
3625
|
-
} = await (0,
|
|
3858
|
+
} = await (0, import_provider_utils15.postJsonToApi)({
|
|
3626
3859
|
url: this.config.url({
|
|
3627
3860
|
path: "/audio/speech",
|
|
3628
3861
|
modelId: this.modelId
|
|
3629
3862
|
}),
|
|
3630
|
-
headers: (0,
|
|
3863
|
+
headers: (0, import_provider_utils15.combineHeaders)(this.config.headers(), options.headers),
|
|
3631
3864
|
body: requestBody,
|
|
3632
3865
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3633
|
-
successfulResponseHandler: (0,
|
|
3866
|
+
successfulResponseHandler: (0, import_provider_utils15.createBinaryResponseHandler)(),
|
|
3634
3867
|
abortSignal: options.abortSignal,
|
|
3635
3868
|
fetch: this.config.fetch
|
|
3636
3869
|
});
|
|
@@ -3651,34 +3884,34 @@ var OpenAISpeechModel = class {
|
|
|
3651
3884
|
};
|
|
3652
3885
|
|
|
3653
3886
|
// src/transcription/openai-transcription-model.ts
|
|
3654
|
-
var
|
|
3655
|
-
var
|
|
3887
|
+
var import_provider_utils16 = require("@zenning/provider-utils");
|
|
3888
|
+
var import_v419 = require("zod/v4");
|
|
3656
3889
|
|
|
3657
3890
|
// src/transcription/openai-transcription-options.ts
|
|
3658
|
-
var
|
|
3659
|
-
var openAITranscriptionProviderOptions =
|
|
3891
|
+
var import_v418 = require("zod/v4");
|
|
3892
|
+
var openAITranscriptionProviderOptions = import_v418.z.object({
|
|
3660
3893
|
/**
|
|
3661
3894
|
* Additional information to include in the transcription response.
|
|
3662
3895
|
*/
|
|
3663
|
-
include:
|
|
3896
|
+
include: import_v418.z.array(import_v418.z.string()).optional(),
|
|
3664
3897
|
/**
|
|
3665
3898
|
* The language of the input audio in ISO-639-1 format.
|
|
3666
3899
|
*/
|
|
3667
|
-
language:
|
|
3900
|
+
language: import_v418.z.string().optional(),
|
|
3668
3901
|
/**
|
|
3669
3902
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
3670
3903
|
*/
|
|
3671
|
-
prompt:
|
|
3904
|
+
prompt: import_v418.z.string().optional(),
|
|
3672
3905
|
/**
|
|
3673
3906
|
* The sampling temperature, between 0 and 1.
|
|
3674
3907
|
* @default 0
|
|
3675
3908
|
*/
|
|
3676
|
-
temperature:
|
|
3909
|
+
temperature: import_v418.z.number().min(0).max(1).default(0).optional(),
|
|
3677
3910
|
/**
|
|
3678
3911
|
* The timestamp granularities to populate for this transcription.
|
|
3679
3912
|
* @default ['segment']
|
|
3680
3913
|
*/
|
|
3681
|
-
timestampGranularities:
|
|
3914
|
+
timestampGranularities: import_v418.z.array(import_v418.z.enum(["word", "segment"])).default(["segment"]).optional()
|
|
3682
3915
|
});
|
|
3683
3916
|
|
|
3684
3917
|
// src/transcription/openai-transcription-model.ts
|
|
@@ -3756,15 +3989,15 @@ var OpenAITranscriptionModel = class {
|
|
|
3756
3989
|
providerOptions
|
|
3757
3990
|
}) {
|
|
3758
3991
|
const warnings = [];
|
|
3759
|
-
const openAIOptions = await (0,
|
|
3992
|
+
const openAIOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
3760
3993
|
provider: "openai",
|
|
3761
3994
|
providerOptions,
|
|
3762
3995
|
schema: openAITranscriptionProviderOptions
|
|
3763
3996
|
});
|
|
3764
3997
|
const formData = new FormData();
|
|
3765
|
-
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0,
|
|
3998
|
+
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils16.convertBase64ToUint8Array)(audio)]);
|
|
3766
3999
|
formData.append("model", this.modelId);
|
|
3767
|
-
const fileExtension = (0,
|
|
4000
|
+
const fileExtension = (0, import_provider_utils16.mediaTypeToExtension)(mediaType);
|
|
3768
4001
|
formData.append(
|
|
3769
4002
|
"file",
|
|
3770
4003
|
new File([blob], "audio", { type: mediaType }),
|
|
@@ -3809,15 +4042,15 @@ var OpenAITranscriptionModel = class {
|
|
|
3809
4042
|
value: response,
|
|
3810
4043
|
responseHeaders,
|
|
3811
4044
|
rawValue: rawResponse
|
|
3812
|
-
} = await (0,
|
|
4045
|
+
} = await (0, import_provider_utils16.postFormDataToApi)({
|
|
3813
4046
|
url: this.config.url({
|
|
3814
4047
|
path: "/audio/transcriptions",
|
|
3815
4048
|
modelId: this.modelId
|
|
3816
4049
|
}),
|
|
3817
|
-
headers: (0,
|
|
4050
|
+
headers: (0, import_provider_utils16.combineHeaders)(this.config.headers(), options.headers),
|
|
3818
4051
|
formData,
|
|
3819
4052
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3820
|
-
successfulResponseHandler: (0,
|
|
4053
|
+
successfulResponseHandler: (0, import_provider_utils16.createJsonResponseHandler)(
|
|
3821
4054
|
openaiTranscriptionResponseSchema
|
|
3822
4055
|
),
|
|
3823
4056
|
abortSignal: options.abortSignal,
|
|
@@ -3847,48 +4080,59 @@ var OpenAITranscriptionModel = class {
|
|
|
3847
4080
|
};
|
|
3848
4081
|
}
|
|
3849
4082
|
};
|
|
3850
|
-
var openaiTranscriptionResponseSchema =
|
|
3851
|
-
text:
|
|
3852
|
-
language:
|
|
3853
|
-
duration:
|
|
3854
|
-
words:
|
|
3855
|
-
|
|
3856
|
-
word:
|
|
3857
|
-
start:
|
|
3858
|
-
end:
|
|
4083
|
+
var openaiTranscriptionResponseSchema = import_v419.z.object({
|
|
4084
|
+
text: import_v419.z.string(),
|
|
4085
|
+
language: import_v419.z.string().nullish(),
|
|
4086
|
+
duration: import_v419.z.number().nullish(),
|
|
4087
|
+
words: import_v419.z.array(
|
|
4088
|
+
import_v419.z.object({
|
|
4089
|
+
word: import_v419.z.string(),
|
|
4090
|
+
start: import_v419.z.number(),
|
|
4091
|
+
end: import_v419.z.number()
|
|
3859
4092
|
})
|
|
3860
4093
|
).nullish(),
|
|
3861
|
-
segments:
|
|
3862
|
-
|
|
3863
|
-
id:
|
|
3864
|
-
seek:
|
|
3865
|
-
start:
|
|
3866
|
-
end:
|
|
3867
|
-
text:
|
|
3868
|
-
tokens:
|
|
3869
|
-
temperature:
|
|
3870
|
-
avg_logprob:
|
|
3871
|
-
compression_ratio:
|
|
3872
|
-
no_speech_prob:
|
|
4094
|
+
segments: import_v419.z.array(
|
|
4095
|
+
import_v419.z.object({
|
|
4096
|
+
id: import_v419.z.number(),
|
|
4097
|
+
seek: import_v419.z.number(),
|
|
4098
|
+
start: import_v419.z.number(),
|
|
4099
|
+
end: import_v419.z.number(),
|
|
4100
|
+
text: import_v419.z.string(),
|
|
4101
|
+
tokens: import_v419.z.array(import_v419.z.number()),
|
|
4102
|
+
temperature: import_v419.z.number(),
|
|
4103
|
+
avg_logprob: import_v419.z.number(),
|
|
4104
|
+
compression_ratio: import_v419.z.number(),
|
|
4105
|
+
no_speech_prob: import_v419.z.number()
|
|
3873
4106
|
})
|
|
3874
4107
|
).nullish()
|
|
3875
4108
|
});
|
|
3876
4109
|
|
|
4110
|
+
// src/version.ts
|
|
4111
|
+
var VERSION = true ? "2.2.0" : "0.0.0-test";
|
|
4112
|
+
|
|
3877
4113
|
// src/openai-provider.ts
|
|
3878
4114
|
function createOpenAI(options = {}) {
|
|
3879
4115
|
var _a, _b;
|
|
3880
|
-
const baseURL = (_a = (0,
|
|
4116
|
+
const baseURL = (_a = (0, import_provider_utils17.withoutTrailingSlash)(
|
|
4117
|
+
(0, import_provider_utils17.loadOptionalSetting)({
|
|
4118
|
+
settingValue: options.baseURL,
|
|
4119
|
+
environmentVariableName: "OPENAI_BASE_URL"
|
|
4120
|
+
})
|
|
4121
|
+
)) != null ? _a : "https://api.openai.com/v1";
|
|
3881
4122
|
const providerName = (_b = options.name) != null ? _b : "openai";
|
|
3882
|
-
const getHeaders = () => (
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
4123
|
+
const getHeaders = () => (0, import_provider_utils17.withUserAgentSuffix)(
|
|
4124
|
+
{
|
|
4125
|
+
Authorization: `Bearer ${(0, import_provider_utils17.loadApiKey)({
|
|
4126
|
+
apiKey: options.apiKey,
|
|
4127
|
+
environmentVariableName: "OPENAI_API_KEY",
|
|
4128
|
+
description: "OpenAI"
|
|
4129
|
+
})}`,
|
|
4130
|
+
"OpenAI-Organization": options.organization,
|
|
4131
|
+
"OpenAI-Project": options.project,
|
|
4132
|
+
...options.headers
|
|
4133
|
+
},
|
|
4134
|
+
`ai-sdk/openai/${VERSION}`
|
|
4135
|
+
);
|
|
3892
4136
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
3893
4137
|
provider: `${providerName}.chat`,
|
|
3894
4138
|
url: ({ path }) => `${baseURL}${path}`,
|
|
@@ -3964,6 +4208,7 @@ function createOpenAI(options = {}) {
|
|
|
3964
4208
|
var openai = createOpenAI();
|
|
3965
4209
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3966
4210
|
0 && (module.exports = {
|
|
4211
|
+
VERSION,
|
|
3967
4212
|
createOpenAI,
|
|
3968
4213
|
openai
|
|
3969
4214
|
});
|