@ai-sdk/openai 1.2.7 → 1.2.8

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-sdk/openai
2
2
 
3
+ ## 1.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 9f4f1bc: feat (provider/openai): pdf support for chat language models
8
+
3
9
  ## 1.2.7
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -78,8 +78,8 @@ function convertToOpenAIChatMessages({
78
78
  }
79
79
  messages.push({
80
80
  role: "user",
81
- content: content.map((part) => {
82
- var _a, _b, _c;
81
+ content: content.map((part, index) => {
82
+ var _a, _b, _c, _d;
83
83
  switch (part.type) {
84
84
  case "text": {
85
85
  return { type: "text", text: part.text };
@@ -114,6 +114,15 @@ function convertToOpenAIChatMessages({
114
114
  input_audio: { data: part.data, format: "mp3" }
115
115
  };
116
116
  }
117
+ case "application/pdf": {
118
+ return {
119
+ type: "file",
120
+ file: {
121
+ filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
122
+ file_data: `data:application/pdf;base64,${part.data}`
123
+ }
124
+ };
125
+ }
117
126
  default: {
118
127
  throw new import_provider.UnsupportedFunctionalityError({
119
128
  functionality: `File content part type ${part.mimeType} in user messages`