@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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 1.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 2e1101a: feat (provider/openai): pdf input support
8
+ - Updated dependencies [2e1101a]
9
+ - @ai-sdk/provider@1.0.11
10
+ - @ai-sdk/provider-utils@2.1.13
11
+
3
12
  ## 1.2.4
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1645,8 +1645,8 @@ function convertToOpenAIResponsesMessages({
1645
1645
  case "user": {
1646
1646
  messages.push({
1647
1647
  role: "user",
1648
- content: content.map((part) => {
1649
- var _a, _b, _c;
1648
+ content: content.map((part, index) => {
1649
+ var _a, _b, _c, _d;
1650
1650
  switch (part.type) {
1651
1651
  case "text": {
1652
1652
  return { type: "input_text", text: part.text };
@@ -1660,9 +1660,25 @@ function convertToOpenAIResponsesMessages({
1660
1660
  };
1661
1661
  }
1662
1662
  case "file": {
1663
- throw new import_provider7.UnsupportedFunctionalityError({
1664
- functionality: "Image content parts in user messages"
1665
- });
1663
+ if (part.data instanceof URL) {
1664
+ throw new import_provider7.UnsupportedFunctionalityError({
1665
+ functionality: "File URLs in user messages"
1666
+ });
1667
+ }
1668
+ switch (part.mimeType) {
1669
+ case "application/pdf": {
1670
+ return {
1671
+ type: "input_file",
1672
+ filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
1673
+ file_data: `data:application/pdf;base64,${part.data}`
1674
+ };
1675
+ }
1676
+ default: {
1677
+ throw new import_provider7.UnsupportedFunctionalityError({
1678
+ functionality: "Only PDF files are supported in user messages"
1679
+ });
1680
+ }
1681
+ }
1666
1682
  }
1667
1683
  }
1668
1684
  })