ai 4.2.6 → 4.2.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/dist/index.mjs CHANGED
@@ -1669,13 +1669,24 @@ function convertToCoreMessages(messages, options) {
1669
1669
  break;
1670
1670
  }
1671
1671
  case "user": {
1672
- coreMessages.push({
1673
- role: "user",
1674
- content: experimental_attachments ? [
1675
- { type: "text", text: content },
1676
- ...attachmentsToParts(experimental_attachments)
1677
- ] : content
1678
- });
1672
+ if (message.parts == null) {
1673
+ coreMessages.push({
1674
+ role: "user",
1675
+ content: experimental_attachments ? [
1676
+ { type: "text", text: content },
1677
+ ...attachmentsToParts(experimental_attachments)
1678
+ ] : content
1679
+ });
1680
+ } else {
1681
+ const textParts = message.parts.filter((part) => part.type === "text").map((part) => ({
1682
+ type: "text",
1683
+ text: part.text
1684
+ }));
1685
+ coreMessages.push({
1686
+ role: "user",
1687
+ content: experimental_attachments ? [...textParts, ...attachmentsToParts(experimental_attachments)] : textParts
1688
+ });
1689
+ }
1679
1690
  break;
1680
1691
  }
1681
1692
  case "assistant": {