@ai-sdk/openai 1.2.4 → 1.2.6

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
@@ -123,10 +123,6 @@ function convertToOpenAIChatMessages({
123
123
  text += part.text;
124
124
  break;
125
125
  }
126
- case "redacted-reasoning":
127
- case "reasoning": {
128
- break;
129
- }
130
126
  case "tool-call": {
131
127
  toolCalls.push({
132
128
  id: part.toolCallId,
@@ -138,10 +134,6 @@ function convertToOpenAIChatMessages({
138
134
  });
139
135
  break;
140
136
  }
141
- default: {
142
- const _exhaustiveCheck = part;
143
- throw new Error(`Unsupported part: ${_exhaustiveCheck}`);
144
- }
145
137
  }
146
138
  }
147
139
  if (useLegacyFunctionCalling) {
@@ -1666,8 +1658,8 @@ function convertToOpenAIResponsesMessages({
1666
1658
  case "user": {
1667
1659
  messages.push({
1668
1660
  role: "user",
1669
- content: content.map((part) => {
1670
- var _a, _b, _c;
1661
+ content: content.map((part, index) => {
1662
+ var _a, _b, _c, _d;
1671
1663
  switch (part.type) {
1672
1664
  case "text": {
1673
1665
  return { type: "input_text", text: part.text };
@@ -1681,9 +1673,25 @@ function convertToOpenAIResponsesMessages({
1681
1673
  };
1682
1674
  }
1683
1675
  case "file": {
1684
- throw new UnsupportedFunctionalityError6({
1685
- functionality: "Image content parts in user messages"
1686
- });
1676
+ if (part.data instanceof URL) {
1677
+ throw new UnsupportedFunctionalityError6({
1678
+ functionality: "File URLs in user messages"
1679
+ });
1680
+ }
1681
+ switch (part.mimeType) {
1682
+ case "application/pdf": {
1683
+ return {
1684
+ type: "input_file",
1685
+ filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
1686
+ file_data: `data:application/pdf;base64,${part.data}`
1687
+ };
1688
+ }
1689
+ default: {
1690
+ throw new UnsupportedFunctionalityError6({
1691
+ functionality: "Only PDF files are supported in user messages"
1692
+ });
1693
+ }
1694
+ }
1687
1695
  }
1688
1696
  }
1689
1697
  })