@ai-sdk/openai 3.0.60 → 3.0.62
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 +12 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +58 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +57 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +57 -20
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/responses/convert-to-openai-responses-input.ts +12 -0
- package/src/responses/openai-responses-language-model.ts +1 -0
- package/src/responses/openai-responses-options.ts +17 -0
- package/src/responses/openai-responses-prepare-tools.ts +26 -1
package/package.json
CHANGED
|
@@ -701,11 +701,17 @@ export async function convertToOpenAIResponsesInput({
|
|
|
701
701
|
return {
|
|
702
702
|
type: 'input_image' as const,
|
|
703
703
|
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
704
|
+
detail:
|
|
705
|
+
item.providerOptions?.[providerOptionsName]
|
|
706
|
+
?.imageDetail,
|
|
704
707
|
};
|
|
705
708
|
case 'image-url':
|
|
706
709
|
return {
|
|
707
710
|
type: 'input_image' as const,
|
|
708
711
|
image_url: item.url,
|
|
712
|
+
detail:
|
|
713
|
+
item.providerOptions?.[providerOptionsName]
|
|
714
|
+
?.imageDetail,
|
|
709
715
|
};
|
|
710
716
|
case 'file-data':
|
|
711
717
|
return {
|
|
@@ -764,6 +770,9 @@ export async function convertToOpenAIResponsesInput({
|
|
|
764
770
|
return {
|
|
765
771
|
type: 'input_image' as const,
|
|
766
772
|
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
773
|
+
detail:
|
|
774
|
+
item.providerOptions?.[providerOptionsName]
|
|
775
|
+
?.imageDetail,
|
|
767
776
|
};
|
|
768
777
|
}
|
|
769
778
|
|
|
@@ -771,6 +780,9 @@ export async function convertToOpenAIResponsesInput({
|
|
|
771
780
|
return {
|
|
772
781
|
type: 'input_image' as const,
|
|
773
782
|
image_url: item.url,
|
|
783
|
+
detail:
|
|
784
|
+
item.providerOptions?.[providerOptionsName]
|
|
785
|
+
?.imageDetail,
|
|
774
786
|
};
|
|
775
787
|
}
|
|
776
788
|
|
|
@@ -316,6 +316,23 @@ export const openaiLanguageModelResponsesOptionsSchema = lazySchema(() =>
|
|
|
316
316
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
317
317
|
*/
|
|
318
318
|
forceReasoning: z.boolean().optional(),
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Restrict the callable tools to a subset while keeping the full tools
|
|
322
|
+
* list intact, so prompt caching is preserved across requests with
|
|
323
|
+
* different allowlists.
|
|
324
|
+
*
|
|
325
|
+
* When set, this overrides the request-level `toolChoice` and emits
|
|
326
|
+
* `tool_choice: { type: "allowed_tools", mode, tools }` on the wire.
|
|
327
|
+
*
|
|
328
|
+
* @see https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(model)%20tool_choice_allowed%20%3E%20(schema)
|
|
329
|
+
*/
|
|
330
|
+
allowedTools: z
|
|
331
|
+
.object({
|
|
332
|
+
toolNames: z.array(z.string()).min(1),
|
|
333
|
+
mode: z.enum(['auto', 'required']).optional(),
|
|
334
|
+
})
|
|
335
|
+
.optional(),
|
|
319
336
|
}),
|
|
320
337
|
),
|
|
321
338
|
);
|
|
@@ -18,11 +18,16 @@ import type { OpenAIResponsesTool } from './openai-responses-api';
|
|
|
18
18
|
export async function prepareResponsesTools({
|
|
19
19
|
tools,
|
|
20
20
|
toolChoice,
|
|
21
|
+
allowedTools,
|
|
21
22
|
toolNameMapping,
|
|
22
23
|
customProviderToolNames,
|
|
23
24
|
}: {
|
|
24
25
|
tools: LanguageModelV3CallOptions['tools'];
|
|
25
26
|
toolChoice: LanguageModelV3CallOptions['toolChoice'] | undefined;
|
|
27
|
+
allowedTools?: {
|
|
28
|
+
toolNames: string[];
|
|
29
|
+
mode?: 'auto' | 'required';
|
|
30
|
+
};
|
|
26
31
|
toolNameMapping?: ToolNameMapping;
|
|
27
32
|
customProviderToolNames?: Set<string>;
|
|
28
33
|
}): Promise<{
|
|
@@ -39,7 +44,12 @@ export async function prepareResponsesTools({
|
|
|
39
44
|
| { type: 'code_interpreter' }
|
|
40
45
|
| { type: 'mcp' }
|
|
41
46
|
| { type: 'image_generation' }
|
|
42
|
-
| { type: 'apply_patch' }
|
|
47
|
+
| { type: 'apply_patch' }
|
|
48
|
+
| {
|
|
49
|
+
type: 'allowed_tools';
|
|
50
|
+
mode: 'auto' | 'required';
|
|
51
|
+
tools: Array<{ type: 'function'; name: string }>;
|
|
52
|
+
};
|
|
43
53
|
toolWarnings: SharedV3Warning[];
|
|
44
54
|
}> {
|
|
45
55
|
// when the tools array is empty, change it to undefined to prevent errors:
|
|
@@ -285,6 +295,21 @@ export async function prepareResponsesTools({
|
|
|
285
295
|
}
|
|
286
296
|
}
|
|
287
297
|
|
|
298
|
+
if (allowedTools != null) {
|
|
299
|
+
return {
|
|
300
|
+
tools: openaiTools,
|
|
301
|
+
toolChoice: {
|
|
302
|
+
type: 'allowed_tools',
|
|
303
|
+
mode: allowedTools.mode ?? 'auto',
|
|
304
|
+
tools: allowedTools.toolNames.map(name => ({
|
|
305
|
+
type: 'function',
|
|
306
|
+
name: toolNameMapping?.toProviderToolName(name) ?? name,
|
|
307
|
+
})),
|
|
308
|
+
},
|
|
309
|
+
toolWarnings,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
288
313
|
if (toolChoice == null) {
|
|
289
314
|
return { tools: openaiTools, toolChoice: undefined, toolWarnings };
|
|
290
315
|
}
|