@ai-sdk/openai 1.2.4 → 1.2.5

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
@@ -1666,8 +1666,8 @@ function convertToOpenAIResponsesMessages({
1666
1666
  case "user": {
1667
1667
  messages.push({
1668
1668
  role: "user",
1669
- content: content.map((part) => {
1670
- var _a, _b, _c;
1669
+ content: content.map((part, index) => {
1670
+ var _a, _b, _c, _d;
1671
1671
  switch (part.type) {
1672
1672
  case "text": {
1673
1673
  return { type: "input_text", text: part.text };
@@ -1681,9 +1681,25 @@ function convertToOpenAIResponsesMessages({
1681
1681
  };
1682
1682
  }
1683
1683
  case "file": {
1684
- throw new UnsupportedFunctionalityError6({
1685
- functionality: "Image content parts in user messages"
1686
- });
1684
+ if (part.data instanceof URL) {
1685
+ throw new UnsupportedFunctionalityError6({
1686
+ functionality: "File URLs in user messages"
1687
+ });
1688
+ }
1689
+ switch (part.mimeType) {
1690
+ case "application/pdf": {
1691
+ return {
1692
+ type: "input_file",
1693
+ filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
1694
+ file_data: `data:application/pdf;base64,${part.data}`
1695
+ };
1696
+ }
1697
+ default: {
1698
+ throw new UnsupportedFunctionalityError6({
1699
+ functionality: "Only PDF files are supported in user messages"
1700
+ });
1701
+ }
1702
+ }
1687
1703
  }
1688
1704
  }
1689
1705
  })