@ai-sdk/azure 3.0.140 → 3.0.142

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.
@@ -5,6 +5,8 @@ import type {
5
5
  SharedV3Warning,
6
6
  } from '@ai-sdk/provider';
7
7
  import {
8
+ lazySchema,
9
+ zodSchema,
8
10
  combineHeaders,
9
11
  convertBase64ToUint8Array,
10
12
  createJsonErrorResponseHandler,
@@ -232,12 +234,16 @@ async function fileToBlob(
232
234
  return new Blob([data as BlobPart], { type: file.mediaType });
233
235
  }
234
236
 
235
- const maiErrorSchema = z.object({
236
- error: z.object({
237
- code: z.union([z.string(), z.number()]).nullish(),
238
- message: z.string(),
239
- }),
240
- });
237
+ const maiErrorSchema = lazySchema(() =>
238
+ zodSchema(
239
+ z.object({
240
+ error: z.object({
241
+ code: z.union([z.string(), z.number()]).nullish(),
242
+ message: z.string(),
243
+ }),
244
+ }),
245
+ ),
246
+ );
241
247
 
242
248
  const maiFailedResponseHandler = createJsonErrorResponseHandler({
243
249
  errorSchema: maiErrorSchema,
@@ -245,15 +251,19 @@ const maiFailedResponseHandler = createJsonErrorResponseHandler({
245
251
  });
246
252
 
247
253
  // Only the fields used here, to tolerate API additions.
248
- const maiImageResponseSchema = z.object({
249
- created: z.number().nullish(),
250
- size: z.string().nullish(),
251
- usage: z
252
- .object({
253
- num_input_text_tokens: z.number().nullish(),
254
- num_input_image_tokens: z.number().nullish(),
255
- num_output_tokens: z.number().nullish(),
256
- })
257
- .nullish(),
258
- data: z.array(z.object({ b64_json: z.string() })),
259
- });
254
+ const maiImageResponseSchema = lazySchema(() =>
255
+ zodSchema(
256
+ z.object({
257
+ created: z.number().nullish(),
258
+ size: z.string().nullish(),
259
+ usage: z
260
+ .object({
261
+ num_input_text_tokens: z.number().nullish(),
262
+ num_input_image_tokens: z.number().nullish(),
263
+ num_output_tokens: z.number().nullish(),
264
+ })
265
+ .nullish(),
266
+ data: z.array(z.object({ b64_json: z.string() })),
267
+ }),
268
+ ),
269
+ );
@@ -4,6 +4,8 @@ import {
4
4
  type SpeechModelV3,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
+ lazySchema,
8
+ zodSchema,
7
9
  combineHeaders,
8
10
  createBinaryResponseHandler,
9
11
  extractResponseHeaders,
@@ -244,9 +246,13 @@ function resolveVoice(
244
246
  : { voice };
245
247
  }
246
248
 
247
- const errorSchema = z.object({
248
- error: z.object({ message: z.string() }),
249
- });
249
+ const errorSchema = lazySchema(() =>
250
+ zodSchema(
251
+ z.object({
252
+ error: z.object({ message: z.string() }),
253
+ }),
254
+ ),
255
+ );
250
256
 
251
257
  // Azure Speech answers invalid requests (style or output format) with an empty
252
258
  // 400 body. Unknown voices or styles reset the connection with an Envoy 502
@@ -1,5 +1,7 @@
1
1
  import type { TranscriptionModelV3 } from '@ai-sdk/provider';
2
2
  import {
3
+ lazySchema,
4
+ zodSchema,
3
5
  combineHeaders,
4
6
  convertBase64ToUint8Array,
5
7
  createJsonErrorResponseHandler,
@@ -129,28 +131,32 @@ export class AzureSpeechTranscriptionModel implements TranscriptionModelV3 {
129
131
  }
130
132
  }
131
133
 
132
- const responseSchema = z.object({
133
- combinedPhrases: z.array(z.object({ text: z.string() })),
134
- durationMilliseconds: z.number().nullish(),
135
- phrases: z
136
- .array(
137
- z.object({
138
- text: z.string(),
139
- offsetMilliseconds: z.number().nullish(),
140
- durationMilliseconds: z.number().nullish(),
141
- locale: z.string().nullish(),
142
- speaker: z.number().nullish(),
143
- confidence: z.number().nullish(),
144
- words: z
145
- .array(
146
- z.object({
147
- text: z.string(),
148
- offsetMilliseconds: z.number().nullish(),
149
- durationMilliseconds: z.number().nullish(),
150
- }),
151
- )
152
- .nullish(),
153
- }),
154
- )
155
- .nullish(),
156
- });
134
+ const responseSchema = lazySchema(() =>
135
+ zodSchema(
136
+ z.object({
137
+ combinedPhrases: z.array(z.object({ text: z.string() })),
138
+ durationMilliseconds: z.number().nullish(),
139
+ phrases: z
140
+ .array(
141
+ z.object({
142
+ text: z.string(),
143
+ offsetMilliseconds: z.number().nullish(),
144
+ durationMilliseconds: z.number().nullish(),
145
+ locale: z.string().nullish(),
146
+ speaker: z.number().nullish(),
147
+ confidence: z.number().nullish(),
148
+ words: z
149
+ .array(
150
+ z.object({
151
+ text: z.string(),
152
+ offsetMilliseconds: z.number().nullish(),
153
+ durationMilliseconds: z.number().nullish(),
154
+ }),
155
+ )
156
+ .nullish(),
157
+ }),
158
+ )
159
+ .nullish(),
160
+ }),
161
+ ),
162
+ );