@ai-sdk/openai 3.0.102 → 3.0.104

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/openai",
3
- "version": "3.0.102",
3
+ "version": "3.0.104",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@ai-sdk/provider": "3.0.15",
40
- "@ai-sdk/provider-utils": "4.0.48"
40
+ "@ai-sdk/provider-utils": "4.0.49"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -8,7 +8,11 @@ import type { OpenAIChatPrompt } from './openai-chat-prompt';
8
8
  import { convertToBase64 } from '@ai-sdk/provider-utils';
9
9
 
10
10
  function serializeToolCallArguments(input: unknown): string {
11
- return JSON.stringify(input === undefined ? {} : input);
11
+ return JSON.stringify(
12
+ typeof input === 'object' && input !== null && !Array.isArray(input)
13
+ ? input
14
+ : {},
15
+ );
12
16
  }
13
17
 
14
18
  type OpenAIPromptCacheBreakpoint = { mode: 'explicit' };
@@ -5,6 +5,7 @@ import {
5
5
  import {
6
6
  combineHeaders,
7
7
  createJsonResponseHandler,
8
+ EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
8
9
  parseProviderOptions,
9
10
  postJsonToApi,
10
11
  } from '@ai-sdk/provider-utils';
@@ -20,6 +21,7 @@ export class OpenAIEmbeddingModel implements EmbeddingModelV3 {
20
21
  readonly specificationVersion = 'v3';
21
22
  readonly modelId: OpenAIEmbeddingModelId;
22
23
  readonly maxEmbeddingsPerCall = 2048;
24
+ readonly [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] = 300_000;
23
25
  readonly supportsParallelCalls = true;
24
26
 
25
27
  private readonly config: OpenAIConfig;
@@ -268,6 +268,7 @@ export async function convertToOpenAIResponsesInput({
268
268
  hasLocalShellTool = false,
269
269
  hasShellTool = false,
270
270
  hasApplyPatchTool = false,
271
+ toolSearchToolName,
271
272
  customProviderToolNames,
272
273
  }: {
273
274
  prompt: LanguageModelV3Prompt;
@@ -282,6 +283,7 @@ export async function convertToOpenAIResponsesInput({
282
283
  hasLocalShellTool?: boolean;
283
284
  hasShellTool?: boolean;
284
285
  hasApplyPatchTool?: boolean;
286
+ toolSearchToolName?: string;
285
287
  customProviderToolNames?: Set<string>;
286
288
  }): Promise<{
287
289
  input: OpenAIResponsesInput;
@@ -559,7 +561,7 @@ export async function convertToOpenAIResponsesInput({
559
561
  part.toolName,
560
562
  );
561
563
 
562
- if (resolvedToolName === 'tool_search') {
564
+ if (part.toolName === toolSearchToolName) {
563
565
  if (store && id != null) {
564
566
  input.push({ type: 'item_reference', id });
565
567
  break;
@@ -740,7 +742,7 @@ export async function convertToOpenAIResponsesInput({
740
742
  part.toolName,
741
743
  );
742
744
 
743
- if (resolvedResultToolName === 'tool_search') {
745
+ if (part.toolName === toolSearchToolName) {
744
746
  const itemId = (part.providerOptions?.[providerOptionsName]
745
747
  ?.itemId ??
746
748
  (
@@ -1030,7 +1032,7 @@ export async function convertToOpenAIResponsesInput({
1030
1032
  part.toolName,
1031
1033
  );
1032
1034
 
1033
- if (resolvedToolName === 'tool_search' && output.type === 'json') {
1035
+ if (part.toolName === toolSearchToolName && output.type === 'json') {
1034
1036
  const parsedOutput = await validateTypes({
1035
1037
  value: output.value,
1036
1038
  schema: toolSearchOutputSchema,
@@ -243,6 +243,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
243
243
  hasLocalShellTool: hasOpenAITool('openai.local_shell'),
244
244
  hasShellTool: hasOpenAITool('openai.shell'),
245
245
  hasApplyPatchTool: hasOpenAITool('openai.apply_patch'),
246
+ toolSearchToolName: getOpenAIToolName('openai.tool_search'),
246
247
  customProviderToolNames:
247
248
  customProviderToolNames.size > 0
248
249
  ? customProviderToolNames
@@ -263,10 +264,13 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
263
264
  }
264
265
  }
265
266
 
267
+ function getOpenAIToolName(id: string) {
268
+ return tools?.find(tool => tool.type === 'provider' && tool.id === id)
269
+ ?.name;
270
+ }
271
+
266
272
  function hasOpenAITool(id: string) {
267
- return (
268
- tools?.find(tool => tool.type === 'provider' && tool.id === id) != null
269
- );
273
+ return getOpenAIToolName(id) != null;
270
274
  }
271
275
 
272
276
  // when logprobs are requested, automatically include them: