ai 5.0.5 → 5.0.7

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 8e72304: fix (ai): handle invalid tool calls
8
+
9
+ ## 5.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - d983eee: feat(ai): allow passing model string for embeddings
14
+
3
15
  ## 5.0.5
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -142,7 +142,7 @@ type TelemetrySettings = {
142
142
  /**
143
143
  Embedding model that is used by the AI SDK Core functions.
144
144
  */
145
- type EmbeddingModel<VALUE> = EmbeddingModelV2<VALUE>;
145
+ type EmbeddingModel<VALUE = string> = string | EmbeddingModelV2<VALUE>;
146
146
  /**
147
147
  Embedding.
148
148
  */
@@ -428,6 +428,8 @@ type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
428
428
  input: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
429
429
  providerExecuted?: boolean;
430
430
  dynamic?: false | undefined;
431
+ invalid?: false | undefined;
432
+ error?: never;
431
433
  providerMetadata?: ProviderMetadata;
432
434
  };
433
435
  }>;
@@ -439,6 +441,15 @@ type DynamicToolCall = {
439
441
  providerExecuted?: boolean;
440
442
  dynamic: true;
441
443
  providerMetadata?: ProviderMetadata;
444
+ /**
445
+ * True if this is caused by an unparsable tool call or
446
+ * a tool that does not exist.
447
+ */
448
+ invalid?: boolean;
449
+ /**
450
+ * The error that caused the tool call to be invalid.
451
+ */
452
+ error?: unknown;
442
453
  };
443
454
  type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
444
455
 
@@ -1450,7 +1461,8 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1450
1461
  callProviderMetadata?: ProviderMetadata;
1451
1462
  } | {
1452
1463
  state: 'output-error';
1453
- input: TOOLS[NAME]['input'];
1464
+ input: TOOLS[NAME]['input'] | undefined;
1465
+ rawInput?: unknown;
1454
1466
  output?: never;
1455
1467
  errorText: string;
1456
1468
  providerExecuted?: boolean;
@@ -1545,6 +1557,15 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
1545
1557
  providerExecuted?: boolean;
1546
1558
  providerMetadata?: ProviderMetadata;
1547
1559
  dynamic?: boolean;
1560
+ } | {
1561
+ type: 'tool-input-error';
1562
+ toolCallId: string;
1563
+ toolName: string;
1564
+ input: unknown;
1565
+ providerExecuted?: boolean;
1566
+ providerMetadata?: ProviderMetadata;
1567
+ dynamic?: boolean;
1568
+ errorText: string;
1548
1569
  } | {
1549
1570
  type: 'tool-output-available';
1550
1571
  toolCallId: string;
@@ -2114,7 +2135,7 @@ Embed a value using an embedding model. The type of the value is defined by the
2114
2135
 
2115
2136
  @returns A result object that contains the embedding, the value, and additional information.
2116
2137
  */
2117
- declare function embed<VALUE>({ model, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
2138
+ declare function embed<VALUE = string>({ model: modelArg, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
2118
2139
  /**
2119
2140
  The embedding model to use.
2120
2141
  */
@@ -2202,7 +2223,7 @@ has a limit on how many embeddings can be generated in a single call.
2202
2223
 
2203
2224
  @returns A result object that contains the embeddings, the value, and additional information.
2204
2225
  */
2205
- declare function embedMany<VALUE>({ model, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
2226
+ declare function embedMany<VALUE = string>({ model: modelArg, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
2206
2227
  /**
2207
2228
  The embedding model to use.
2208
2229
  */
package/dist/index.d.ts CHANGED
@@ -142,7 +142,7 @@ type TelemetrySettings = {
142
142
  /**
143
143
  Embedding model that is used by the AI SDK Core functions.
144
144
  */
145
- type EmbeddingModel<VALUE> = EmbeddingModelV2<VALUE>;
145
+ type EmbeddingModel<VALUE = string> = string | EmbeddingModelV2<VALUE>;
146
146
  /**
147
147
  Embedding.
148
148
  */
@@ -428,6 +428,8 @@ type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
428
428
  input: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
429
429
  providerExecuted?: boolean;
430
430
  dynamic?: false | undefined;
431
+ invalid?: false | undefined;
432
+ error?: never;
431
433
  providerMetadata?: ProviderMetadata;
432
434
  };
433
435
  }>;
@@ -439,6 +441,15 @@ type DynamicToolCall = {
439
441
  providerExecuted?: boolean;
440
442
  dynamic: true;
441
443
  providerMetadata?: ProviderMetadata;
444
+ /**
445
+ * True if this is caused by an unparsable tool call or
446
+ * a tool that does not exist.
447
+ */
448
+ invalid?: boolean;
449
+ /**
450
+ * The error that caused the tool call to be invalid.
451
+ */
452
+ error?: unknown;
442
453
  };
443
454
  type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
444
455
 
@@ -1450,7 +1461,8 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1450
1461
  callProviderMetadata?: ProviderMetadata;
1451
1462
  } | {
1452
1463
  state: 'output-error';
1453
- input: TOOLS[NAME]['input'];
1464
+ input: TOOLS[NAME]['input'] | undefined;
1465
+ rawInput?: unknown;
1454
1466
  output?: never;
1455
1467
  errorText: string;
1456
1468
  providerExecuted?: boolean;
@@ -1545,6 +1557,15 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
1545
1557
  providerExecuted?: boolean;
1546
1558
  providerMetadata?: ProviderMetadata;
1547
1559
  dynamic?: boolean;
1560
+ } | {
1561
+ type: 'tool-input-error';
1562
+ toolCallId: string;
1563
+ toolName: string;
1564
+ input: unknown;
1565
+ providerExecuted?: boolean;
1566
+ providerMetadata?: ProviderMetadata;
1567
+ dynamic?: boolean;
1568
+ errorText: string;
1548
1569
  } | {
1549
1570
  type: 'tool-output-available';
1550
1571
  toolCallId: string;
@@ -2114,7 +2135,7 @@ Embed a value using an embedding model. The type of the value is defined by the
2114
2135
 
2115
2136
  @returns A result object that contains the embedding, the value, and additional information.
2116
2137
  */
2117
- declare function embed<VALUE>({ model, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
2138
+ declare function embed<VALUE = string>({ model: modelArg, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
2118
2139
  /**
2119
2140
  The embedding model to use.
2120
2141
  */
@@ -2202,7 +2223,7 @@ has a limit on how many embeddings can be generated in a single call.
2202
2223
 
2203
2224
  @returns A result object that contains the embeddings, the value, and additional information.
2204
2225
  */
2205
- declare function embedMany<VALUE>({ model, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
2226
+ declare function embedMany<VALUE = string>({ model: modelArg, values, maxParallelCalls, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
2206
2227
  /**
2207
2228
  The embedding model to use.
2208
2229
  */