@ai-sdk/openai 3.0.36 → 3.0.37
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 +8 -0
- package/dist/index.d.mts +50 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +1166 -947
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1116 -893
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +18 -0
- package/dist/internal/index.d.ts +18 -0
- package/dist/internal/index.js +348 -140
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +326 -114
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +78 -0
- package/package.json +2 -2
- package/src/openai-tools.ts +12 -0
- package/src/responses/convert-to-openai-responses-input.ts +74 -0
- package/src/responses/openai-responses-api.ts +58 -0
- package/src/responses/openai-responses-language-model.ts +94 -9
- package/src/responses/openai-responses-prepare-tools.ts +41 -11
- package/src/tool/custom.ts +64 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -286,6 +286,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
286
286
|
path: string;
|
|
287
287
|
diff: string;
|
|
288
288
|
};
|
|
289
|
+
} | {
|
|
290
|
+
type: "custom_tool_call";
|
|
291
|
+
id: string;
|
|
292
|
+
call_id: string;
|
|
293
|
+
name: string;
|
|
294
|
+
input: string;
|
|
289
295
|
} | {
|
|
290
296
|
type: "shell_call";
|
|
291
297
|
id: string;
|
|
@@ -328,6 +334,13 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
328
334
|
name: string;
|
|
329
335
|
arguments: string;
|
|
330
336
|
status: "completed";
|
|
337
|
+
} | {
|
|
338
|
+
type: "custom_tool_call";
|
|
339
|
+
id: string;
|
|
340
|
+
call_id: string;
|
|
341
|
+
name: string;
|
|
342
|
+
input: string;
|
|
343
|
+
status: "completed";
|
|
331
344
|
} | {
|
|
332
345
|
type: "code_interpreter_call";
|
|
333
346
|
id: string;
|
|
@@ -477,6 +490,11 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
477
490
|
item_id: string;
|
|
478
491
|
output_index: number;
|
|
479
492
|
delta: string;
|
|
493
|
+
} | {
|
|
494
|
+
type: "response.custom_tool_call_input.delta";
|
|
495
|
+
item_id: string;
|
|
496
|
+
output_index: number;
|
|
497
|
+
delta: string;
|
|
480
498
|
} | {
|
|
481
499
|
type: "response.image_generation_call.partial_image";
|
|
482
500
|
item_id: string;
|
|
@@ -556,6 +574,28 @@ type OpenAIResponsesLogprobs = NonNullable<(OpenAIResponsesChunk & {
|
|
|
556
574
|
type: 'response.output_text.delta';
|
|
557
575
|
})['logprobs']> | null;
|
|
558
576
|
|
|
577
|
+
declare const customToolFactory: _ai_sdk_provider_utils.ProviderToolFactory<string, {
|
|
578
|
+
/**
|
|
579
|
+
* The name of the custom tool, used to identify it in the API.
|
|
580
|
+
*/
|
|
581
|
+
name: string;
|
|
582
|
+
/**
|
|
583
|
+
* An optional description of what the tool does.
|
|
584
|
+
*/
|
|
585
|
+
description?: string;
|
|
586
|
+
/**
|
|
587
|
+
* The output format specification for the tool.
|
|
588
|
+
* Omit for unconstrained text output.
|
|
589
|
+
*/
|
|
590
|
+
format?: {
|
|
591
|
+
type: "grammar";
|
|
592
|
+
syntax: "regex" | "lark";
|
|
593
|
+
definition: string;
|
|
594
|
+
} | {
|
|
595
|
+
type: "text";
|
|
596
|
+
};
|
|
597
|
+
}>;
|
|
598
|
+
|
|
559
599
|
/**
|
|
560
600
|
* Type definitions for the apply_patch operations.
|
|
561
601
|
*/
|
|
@@ -602,6 +642,16 @@ declare const openaiTools: {
|
|
|
602
642
|
status: "completed" | "failed";
|
|
603
643
|
output?: string;
|
|
604
644
|
}, {}>;
|
|
645
|
+
/**
|
|
646
|
+
* Custom tools let callers constrain model output to a grammar (regex or
|
|
647
|
+
* Lark syntax). The model returns a `custom_tool_call` output item whose
|
|
648
|
+
* `input` field is a string matching the specified grammar.
|
|
649
|
+
*
|
|
650
|
+
* @param name - The name of the custom tool.
|
|
651
|
+
* @param description - An optional description of the tool.
|
|
652
|
+
* @param format - The output format constraint (grammar type, syntax, and definition).
|
|
653
|
+
*/
|
|
654
|
+
customTool: (args: Parameters<typeof customToolFactory>[0]) => _ai_sdk_provider_utils.Tool<string, unknown>;
|
|
605
655
|
/**
|
|
606
656
|
* The Code Interpreter tool allows models to write and run Python code in a
|
|
607
657
|
* sandboxed environment to solve complex problems in domains like data analysis,
|
package/dist/index.d.ts
CHANGED
|
@@ -286,6 +286,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
286
286
|
path: string;
|
|
287
287
|
diff: string;
|
|
288
288
|
};
|
|
289
|
+
} | {
|
|
290
|
+
type: "custom_tool_call";
|
|
291
|
+
id: string;
|
|
292
|
+
call_id: string;
|
|
293
|
+
name: string;
|
|
294
|
+
input: string;
|
|
289
295
|
} | {
|
|
290
296
|
type: "shell_call";
|
|
291
297
|
id: string;
|
|
@@ -328,6 +334,13 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
328
334
|
name: string;
|
|
329
335
|
arguments: string;
|
|
330
336
|
status: "completed";
|
|
337
|
+
} | {
|
|
338
|
+
type: "custom_tool_call";
|
|
339
|
+
id: string;
|
|
340
|
+
call_id: string;
|
|
341
|
+
name: string;
|
|
342
|
+
input: string;
|
|
343
|
+
status: "completed";
|
|
331
344
|
} | {
|
|
332
345
|
type: "code_interpreter_call";
|
|
333
346
|
id: string;
|
|
@@ -477,6 +490,11 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
477
490
|
item_id: string;
|
|
478
491
|
output_index: number;
|
|
479
492
|
delta: string;
|
|
493
|
+
} | {
|
|
494
|
+
type: "response.custom_tool_call_input.delta";
|
|
495
|
+
item_id: string;
|
|
496
|
+
output_index: number;
|
|
497
|
+
delta: string;
|
|
480
498
|
} | {
|
|
481
499
|
type: "response.image_generation_call.partial_image";
|
|
482
500
|
item_id: string;
|
|
@@ -556,6 +574,28 @@ type OpenAIResponsesLogprobs = NonNullable<(OpenAIResponsesChunk & {
|
|
|
556
574
|
type: 'response.output_text.delta';
|
|
557
575
|
})['logprobs']> | null;
|
|
558
576
|
|
|
577
|
+
declare const customToolFactory: _ai_sdk_provider_utils.ProviderToolFactory<string, {
|
|
578
|
+
/**
|
|
579
|
+
* The name of the custom tool, used to identify it in the API.
|
|
580
|
+
*/
|
|
581
|
+
name: string;
|
|
582
|
+
/**
|
|
583
|
+
* An optional description of what the tool does.
|
|
584
|
+
*/
|
|
585
|
+
description?: string;
|
|
586
|
+
/**
|
|
587
|
+
* The output format specification for the tool.
|
|
588
|
+
* Omit for unconstrained text output.
|
|
589
|
+
*/
|
|
590
|
+
format?: {
|
|
591
|
+
type: "grammar";
|
|
592
|
+
syntax: "regex" | "lark";
|
|
593
|
+
definition: string;
|
|
594
|
+
} | {
|
|
595
|
+
type: "text";
|
|
596
|
+
};
|
|
597
|
+
}>;
|
|
598
|
+
|
|
559
599
|
/**
|
|
560
600
|
* Type definitions for the apply_patch operations.
|
|
561
601
|
*/
|
|
@@ -602,6 +642,16 @@ declare const openaiTools: {
|
|
|
602
642
|
status: "completed" | "failed";
|
|
603
643
|
output?: string;
|
|
604
644
|
}, {}>;
|
|
645
|
+
/**
|
|
646
|
+
* Custom tools let callers constrain model output to a grammar (regex or
|
|
647
|
+
* Lark syntax). The model returns a `custom_tool_call` output item whose
|
|
648
|
+
* `input` field is a string matching the specified grammar.
|
|
649
|
+
*
|
|
650
|
+
* @param name - The name of the custom tool.
|
|
651
|
+
* @param description - An optional description of the tool.
|
|
652
|
+
* @param format - The output format constraint (grammar type, syntax, and definition).
|
|
653
|
+
*/
|
|
654
|
+
customTool: (args: Parameters<typeof customToolFactory>[0]) => _ai_sdk_provider_utils.Tool<string, unknown>;
|
|
605
655
|
/**
|
|
606
656
|
* The Code Interpreter tool allows models to write and run Python code in a
|
|
607
657
|
* sandboxed environment to solve complex problems in domains like data analysis,
|