ai 7.0.39 → 7.0.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.39",
3
+ "version": "7.0.41",
4
4
  "type": "module",
5
5
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@ai-sdk/gateway": "4.0.30",
45
+ "@ai-sdk/gateway": "4.0.31",
46
46
  "@ai-sdk/provider": "4.0.4",
47
47
  "@ai-sdk/provider-utils": "5.0.14"
48
48
  },
@@ -25,6 +25,11 @@ export interface GeneratedFile {
25
25
  readonly mediaType: string;
26
26
  }
27
27
 
28
+ /**
29
+ * @deprecated Use `GeneratedFile` instead. This alias will be removed in v8.
30
+ */
31
+ export type Experimental_GeneratedImage = GeneratedFile;
32
+
28
33
  export class DefaultGeneratedFile implements GeneratedFile {
29
34
  private base64Data: string | undefined;
30
35
  private uint8ArrayData: Uint8Array | undefined;
@@ -23,7 +23,7 @@ export type {
23
23
  export type { GenerateTextResult } from './generate-text-result';
24
24
  export {
25
25
  DefaultGeneratedFile,
26
- type GeneratedFile as Experimental_GeneratedImage, // Image for backwards compatibility, TODO remove in v7
26
+ type Experimental_GeneratedImage,
27
27
  type GeneratedFile,
28
28
  } from './generated-file';
29
29
  export type {
@@ -88,6 +88,23 @@ export const FIRST_WARNING_INFO_MESSAGE =
88
88
 
89
89
  let hasLoggedBefore = false;
90
90
 
91
+ function emitWarning({
92
+ message,
93
+ type,
94
+ }: {
95
+ message: string;
96
+ type: 'DeprecationWarning' | 'Warning';
97
+ }) {
98
+ if (
99
+ typeof process !== 'undefined' &&
100
+ typeof process.emitWarning === 'function'
101
+ ) {
102
+ process.emitWarning(message, { type });
103
+ } else {
104
+ console.warn(message);
105
+ }
106
+ }
107
+
91
108
  /**
92
109
  * Logs warnings to the console or uses a custom logger if configured.
93
110
  *
@@ -123,7 +140,10 @@ export const logWarnings: LogWarningsFunction = options => {
123
140
  // display information note on first call
124
141
  if (!hasLoggedBefore) {
125
142
  hasLoggedBefore = true;
126
- console.info(FIRST_WARNING_INFO_MESSAGE);
143
+ emitWarning({
144
+ message: FIRST_WARNING_INFO_MESSAGE,
145
+ type: 'Warning',
146
+ });
127
147
  }
128
148
 
129
149
  // default behavior: log warnings via process.emitWarning if available, otherwise console.warn
@@ -133,16 +153,10 @@ export const logWarnings: LogWarningsFunction = options => {
133
153
  provider: options.provider,
134
154
  model: options.model,
135
155
  });
136
- if (
137
- typeof process !== 'undefined' &&
138
- typeof process.emitWarning === 'function'
139
- ) {
140
- process.emitWarning(message, {
141
- type: warning.type === 'deprecated' ? 'DeprecationWarning' : 'Warning',
142
- });
143
- } else {
144
- console.warn(message);
145
- }
156
+ emitWarning({
157
+ message,
158
+ type: warning.type === 'deprecated' ? 'DeprecationWarning' : 'Warning',
159
+ });
146
160
  }
147
161
  };
148
162