@ai-sdk/openai 4.0.65 → 4.0.67
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 +34 -0
- package/README.md +26 -1
- package/dist/index.d.ts +133 -28
- package/dist/index.js +787 -130
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +7 -0
- package/dist/internal/index.js +164 -24
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +102 -7
- package/package.json +3 -3
- package/src/chat/openai-chat-language-model.ts +11 -2
- package/src/chat/openai-chat-prepare-tools.ts +9 -2
- package/src/index.ts +10 -0
- package/src/live/openai-live-event-mapper.ts +286 -0
- package/src/live/openai-live-session-config.ts +145 -0
- package/src/live/openai-realtime-model-live-options.ts +65 -0
- package/src/live/openai-realtime-model-live.ts +107 -0
- package/src/normalize-openai-json-schema.ts +161 -0
- package/src/openai-batch.ts +16 -0
- package/src/openai-config.ts +7 -0
- package/src/openai-provider.ts +11 -32
- package/src/realtime/openai-realtime-event-mapper.ts +8 -1
- package/src/realtime/openai-realtime-factory.ts +88 -0
- package/src/responses/openai-responses-language-model-options.ts +9 -0
- package/src/responses/openai-responses-language-model.ts +16 -3
- package/src/responses/openai-responses-prepare-tools.ts +16 -2
|
@@ -21,6 +21,7 @@ import { shellArgsSchema } from '../tool/shell';
|
|
|
21
21
|
import { toolSearchArgsSchema } from '../tool/tool-search';
|
|
22
22
|
import { webSearchArgsSchema } from '../tool/web-search';
|
|
23
23
|
import { webSearchPreviewArgsSchema } from '../tool/web-search-preview';
|
|
24
|
+
import { normalizeOpenAIJsonSchema } from '../normalize-openai-json-schema';
|
|
24
25
|
import type {
|
|
25
26
|
OpenAIResponsesAllowedTool,
|
|
26
27
|
OpenAIResponsesFunctionTool,
|
|
@@ -147,6 +148,7 @@ export async function prepareResponsesTools({
|
|
|
147
148
|
const openaiFunctionTool = prepareFunctionTool({
|
|
148
149
|
tool,
|
|
149
150
|
options: openaiOptions,
|
|
151
|
+
toolWarnings,
|
|
150
152
|
async: resolveAsyncToolOption({
|
|
151
153
|
value: openaiOptions?.async,
|
|
152
154
|
supportsAsyncToolCalling,
|
|
@@ -627,19 +629,31 @@ function toAllowedToolResolution(
|
|
|
627
629
|
function prepareFunctionTool({
|
|
628
630
|
tool,
|
|
629
631
|
options,
|
|
632
|
+
toolWarnings,
|
|
630
633
|
async,
|
|
631
634
|
}: {
|
|
632
635
|
tool: LanguageModelV4FunctionTool;
|
|
633
636
|
options: OpenAIToolOptions | undefined;
|
|
637
|
+
toolWarnings: SharedV4Warning[];
|
|
634
638
|
async: boolean | undefined;
|
|
635
639
|
}): OpenAIResponsesFunctionTool {
|
|
636
640
|
const deferLoading = options?.deferLoading;
|
|
641
|
+
const normalizedInputSchema = normalizeOpenAIJsonSchema(tool.inputSchema);
|
|
642
|
+
const normalizedOutputSchema =
|
|
643
|
+
options?.outputSchema != null
|
|
644
|
+
? normalizeOpenAIJsonSchema(options.outputSchema as JSONSchema7)
|
|
645
|
+
: undefined;
|
|
646
|
+
|
|
647
|
+
toolWarnings.push(
|
|
648
|
+
...normalizedInputSchema.warnings,
|
|
649
|
+
...(normalizedOutputSchema?.warnings ?? []),
|
|
650
|
+
);
|
|
637
651
|
|
|
638
652
|
return {
|
|
639
653
|
type: 'function',
|
|
640
654
|
name: tool.name,
|
|
641
655
|
description: tool.description,
|
|
642
|
-
parameters:
|
|
656
|
+
parameters: normalizedInputSchema.schema,
|
|
643
657
|
...(async != null ? { async } : {}),
|
|
644
658
|
...(tool.strict != null ? { strict: tool.strict } : {}),
|
|
645
659
|
...(deferLoading != null ? { defer_loading: deferLoading } : {}),
|
|
@@ -647,7 +661,7 @@ function prepareFunctionTool({
|
|
|
647
661
|
? { allowed_callers: options.allowedCallers }
|
|
648
662
|
: {}),
|
|
649
663
|
...(options?.outputSchema != null
|
|
650
|
-
? { output_schema:
|
|
664
|
+
? { output_schema: normalizedOutputSchema?.schema }
|
|
651
665
|
: {}),
|
|
652
666
|
};
|
|
653
667
|
}
|