@ai-sdk/openai 3.0.52 → 3.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +12 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +12 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +6 -5
- package/src/chat/convert-to-openai-chat-messages.ts +6 -2
- package/src/image/openai-image-options.ts +3 -0
- package/src/responses/convert-to-openai-responses-input.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.54",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ai-sdk/provider": "3.0.
|
|
40
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
39
|
+
"@ai-sdk/provider": "3.0.9",
|
|
40
|
+
"@ai-sdk/provider-utils": "4.0.24"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "20.17.24",
|
|
44
44
|
"tsup": "^8",
|
|
45
45
|
"typescript": "5.8.3",
|
|
46
46
|
"zod": "3.25.76",
|
|
47
|
-
"@ai-sdk/test-server": "1.0.
|
|
47
|
+
"@ai-sdk/test-server": "1.0.4",
|
|
48
48
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"homepage": "https://ai-sdk.dev/docs",
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
62
|
-
"url": "
|
|
62
|
+
"url": "https://github.com/vercel/ai",
|
|
63
|
+
"directory": "packages/openai"
|
|
63
64
|
},
|
|
64
65
|
"bugs": {
|
|
65
66
|
"url": "https://github.com/vercel/ai/issues"
|
|
@@ -6,6 +6,10 @@ import {
|
|
|
6
6
|
import { OpenAIChatPrompt } from './openai-chat-prompt';
|
|
7
7
|
import { convertToBase64 } from '@ai-sdk/provider-utils';
|
|
8
8
|
|
|
9
|
+
function serializeToolCallArguments(input: unknown): string {
|
|
10
|
+
return JSON.stringify(input === undefined ? {} : input);
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
export function convertToOpenAIChatMessages({
|
|
10
14
|
prompt,
|
|
11
15
|
systemMessageMode = 'system',
|
|
@@ -165,7 +169,7 @@ export function convertToOpenAIChatMessages({
|
|
|
165
169
|
type: 'function',
|
|
166
170
|
function: {
|
|
167
171
|
name: part.toolName,
|
|
168
|
-
arguments:
|
|
172
|
+
arguments: serializeToolCallArguments(part.input),
|
|
169
173
|
},
|
|
170
174
|
});
|
|
171
175
|
break;
|
|
@@ -175,7 +179,7 @@ export function convertToOpenAIChatMessages({
|
|
|
175
179
|
|
|
176
180
|
messages.push({
|
|
177
181
|
role: 'assistant',
|
|
178
|
-
content: text,
|
|
182
|
+
content: text || null,
|
|
179
183
|
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
180
184
|
});
|
|
181
185
|
|
|
@@ -4,6 +4,7 @@ export type OpenAIImageModelId =
|
|
|
4
4
|
| 'gpt-image-1'
|
|
5
5
|
| 'gpt-image-1-mini'
|
|
6
6
|
| 'gpt-image-1.5'
|
|
7
|
+
| 'gpt-image-2'
|
|
7
8
|
| 'chatgpt-image-latest'
|
|
8
9
|
| (string & {});
|
|
9
10
|
|
|
@@ -14,6 +15,7 @@ export const modelMaxImagesPerCall: Record<OpenAIImageModelId, number> = {
|
|
|
14
15
|
'gpt-image-1': 10,
|
|
15
16
|
'gpt-image-1-mini': 10,
|
|
16
17
|
'gpt-image-1.5': 10,
|
|
18
|
+
'gpt-image-2': 10,
|
|
17
19
|
'chatgpt-image-latest': 10,
|
|
18
20
|
};
|
|
19
21
|
|
|
@@ -22,6 +24,7 @@ const defaultResponseFormatPrefixes = [
|
|
|
22
24
|
'gpt-image-1-mini',
|
|
23
25
|
'gpt-image-1.5',
|
|
24
26
|
'gpt-image-1',
|
|
27
|
+
'gpt-image-2',
|
|
25
28
|
];
|
|
26
29
|
|
|
27
30
|
export function hasDefaultResponseFormat(modelId: string): boolean {
|
|
@@ -33,6 +33,10 @@ import {
|
|
|
33
33
|
OpenAIResponsesReasoning,
|
|
34
34
|
} from './openai-responses-api';
|
|
35
35
|
|
|
36
|
+
function serializeToolCallArguments(input: unknown): string {
|
|
37
|
+
return JSON.stringify(input === undefined ? {} : input);
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
/**
|
|
37
41
|
* Check if a string is a file ID based on the given prefixes
|
|
38
42
|
* Returns false if prefixes is undefined (disables file ID detection)
|
|
@@ -334,7 +338,7 @@ export async function convertToOpenAIResponsesInput({
|
|
|
334
338
|
type: 'function_call',
|
|
335
339
|
call_id: part.toolCallId,
|
|
336
340
|
name: resolvedToolName,
|
|
337
|
-
arguments:
|
|
341
|
+
arguments: serializeToolCallArguments(part.input),
|
|
338
342
|
id,
|
|
339
343
|
});
|
|
340
344
|
break;
|