ai 5.0.0-beta.8 → 5.0.0-beta.9

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,11 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.0-beta.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 86cfc72: feat (ai): add ignoreIncompleteToolCalls option to convertToModelMessages
8
+
3
9
  ## 5.0.0-beta.8
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2154,9 +2154,14 @@ declare function convertFileListToFileUIParts(files: FileList | undefined): Prom
2154
2154
  /**
2155
2155
  Converts an array of messages from useChat into an array of CoreMessages that can be used
2156
2156
  with the AI core functions (e.g. `streamText`).
2157
+
2158
+ @param messages - The messages to convert.
2159
+ @param options.tools - The tools to use.
2160
+ @param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
2157
2161
  */
2158
2162
  declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
2159
2163
  tools?: ToolSet;
2164
+ ignoreIncompleteToolCalls?: boolean;
2160
2165
  }): ModelMessage[];
2161
2166
  /**
2162
2167
  @deprecated Use `convertToModelMessages` instead.
package/dist/index.d.ts CHANGED
@@ -2154,9 +2154,14 @@ declare function convertFileListToFileUIParts(files: FileList | undefined): Prom
2154
2154
  /**
2155
2155
  Converts an array of messages from useChat into an array of CoreMessages that can be used
2156
2156
  with the AI core functions (e.g. `streamText`).
2157
+
2158
+ @param messages - The messages to convert.
2159
+ @param options.tools - The tools to use.
2160
+ @param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
2157
2161
  */
2158
2162
  declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
2159
2163
  tools?: ToolSet;
2164
+ ignoreIncompleteToolCalls?: boolean;
2160
2165
  }): ModelMessage[];
2161
2166
  /**
2162
2167
  @deprecated Use `convertToModelMessages` instead.
package/dist/index.js CHANGED
@@ -5718,6 +5718,14 @@ function updateToolOutput({
5718
5718
  // src/ui/convert-to-model-messages.ts
5719
5719
  function convertToModelMessages(messages, options) {
5720
5720
  const modelMessages = [];
5721
+ if (options == null ? void 0 : options.ignoreIncompleteToolCalls) {
5722
+ messages = messages.map((message) => ({
5723
+ ...message,
5724
+ parts: message.parts.filter(
5725
+ (part) => !isToolUIPart(part) || part.state !== "input-streaming" && part.state !== "input-available"
5726
+ )
5727
+ }));
5728
+ }
5721
5729
  for (const message of messages) {
5722
5730
  switch (message.role) {
5723
5731
  case "system": {