@ai-sdk/azure 4.0.87 → 4.0.90
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 +19 -0
- package/dist/index.d.ts +36 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +551 -26
- package/dist/index.js.map +1 -1
- package/docs/04-azure.mdx +190 -25
- package/package.json +1 -1
- package/src/azure-mai-transcription-model-options.ts +22 -0
- package/src/azure-mai-transcription-model.ts +371 -0
- package/src/azure-openai-provider.ts +191 -33
- package/src/azure-speech-model-options.ts +35 -0
- package/src/azure-speech-speech-model-options.ts +27 -0
- package/src/azure-speech-speech-model.ts +289 -0
- package/src/azure-speech-transcription-model.ts +6 -5
- package/src/azure-transcription-model-options.ts +21 -4
- package/src/index.ts +1 -0
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { z } from 'zod/v4';
|
|
12
12
|
import type { AzureTranscriptionProviderMetadata } from './azure-transcription-provider-metadata';
|
|
13
13
|
import type { AzureTranscriptionModelSpeechOptions } from './azure-speech-transcription-model-options';
|
|
14
|
-
import {
|
|
14
|
+
import { getMAITranscribeModel } from './azure-transcription-model-options';
|
|
15
15
|
|
|
16
16
|
export class AzureSpeechTranscriptionModel implements TranscriptionModelV4 {
|
|
17
17
|
readonly specificationVersion = 'v4';
|
|
@@ -31,6 +31,7 @@ export class AzureSpeechTranscriptionModel implements TranscriptionModelV4 {
|
|
|
31
31
|
azureOptions: AzureTranscriptionModelSpeechOptions = {},
|
|
32
32
|
): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {
|
|
33
33
|
const timestamp = new Date();
|
|
34
|
+
const maiModel = getMAITranscribeModel(this.modelId);
|
|
34
35
|
const formData = new FormData();
|
|
35
36
|
formData.append(
|
|
36
37
|
'audio',
|
|
@@ -49,11 +50,11 @@ export class AzureSpeechTranscriptionModel implements TranscriptionModelV4 {
|
|
|
49
50
|
JSON.stringify({
|
|
50
51
|
enhancedMode: {
|
|
51
52
|
enabled: true,
|
|
52
|
-
model:
|
|
53
|
-
? 'MAI-Transcribe-2'
|
|
54
|
-
: this.modelId,
|
|
53
|
+
model: maiModel?.name ?? this.modelId,
|
|
55
54
|
modelOptions: {
|
|
56
|
-
timestamps:
|
|
55
|
+
timestamps:
|
|
56
|
+
azureOptions.timestamps ??
|
|
57
|
+
(maiModel?.supportsTimestamps === false ? undefined : 'segment'),
|
|
57
58
|
transcribeStyle: azureOptions.transcribeStyle,
|
|
58
59
|
},
|
|
59
60
|
},
|
|
@@ -4,16 +4,19 @@ import {
|
|
|
4
4
|
type InferSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
6
6
|
import { z } from 'zod/v4';
|
|
7
|
+
import { azureMaiTranscriptionModelOptionsShape } from './azure-mai-transcription-model-options';
|
|
7
8
|
import { azureSpeechTranscriptionModelOptionsShape } from './azure-speech-transcription-model-options';
|
|
8
9
|
|
|
9
10
|
export const azureTranscriptionModelOptions = lazySchema(() =>
|
|
10
11
|
zodSchema(
|
|
11
12
|
z.strictObject({
|
|
12
13
|
/**
|
|
13
|
-
* API to use. Defaults to Speech for MAI-Transcribe
|
|
14
|
+
* API to use. Defaults to Speech for MAI-Transcribe models, MAI for
|
|
15
|
+
* MAI-Transcribe-2-Streaming, and OpenAI otherwise.
|
|
14
16
|
*/
|
|
15
|
-
api: z.enum(['openai', 'speech']).optional(),
|
|
17
|
+
api: z.enum(['openai', 'speech', 'mai']).optional(),
|
|
16
18
|
...azureSpeechTranscriptionModelOptionsShape(),
|
|
19
|
+
...azureMaiTranscriptionModelOptionsShape(),
|
|
17
20
|
}),
|
|
18
21
|
),
|
|
19
22
|
);
|
|
@@ -22,6 +25,20 @@ export type AzureTranscriptionModelOptions = InferSchema<
|
|
|
22
25
|
typeof azureTranscriptionModelOptions
|
|
23
26
|
>;
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
// Azure Speech model names by lowercase model ID. MAI-Transcribe-1.5 only
|
|
29
|
+
// accepts Azure's default timestamps (`none`).
|
|
30
|
+
const maiTranscribeModels = new Map([
|
|
31
|
+
['mai-transcribe-2', { name: 'MAI-Transcribe-2', supportsTimestamps: true }],
|
|
32
|
+
[
|
|
33
|
+
'mai-transcribe-1.5',
|
|
34
|
+
{ name: 'MAI-Transcribe-1.5', supportsTimestamps: false },
|
|
35
|
+
],
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
export function getMAITranscribeModel(modelId: string) {
|
|
39
|
+
return maiTranscribeModels.get(modelId.toLowerCase());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isMAITranscribeStreaming(modelId: string): boolean {
|
|
43
|
+
return modelId.toLowerCase() === 'mai-transcribe-2-streaming';
|
|
27
44
|
}
|
package/src/index.ts
CHANGED
|
@@ -28,5 +28,6 @@ export type {
|
|
|
28
28
|
AzureResponsesSourceDocumentProviderMetadata,
|
|
29
29
|
} from './azure-openai-provider-metadata';
|
|
30
30
|
export { VERSION } from './version';
|
|
31
|
+
export type { AzureSpeechModelOptions } from './azure-speech-model-options';
|
|
31
32
|
export type { AzureTranscriptionModelOptions } from './azure-transcription-model-options';
|
|
32
33
|
export type { AzureTranscriptionProviderMetadata } from './azure-transcription-provider-metadata';
|