@ai-sdk/assemblyai 2.0.7 → 2.0.9

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,19 @@
1
1
  # @ai-sdk/assemblyai
2
2
 
3
+ ## 2.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 8dc54db: chore: add src folders to package bundle
8
+
9
+ ## 2.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [5c090e7]
14
+ - @ai-sdk/provider@3.0.4
15
+ - @ai-sdk/provider-utils@4.0.8
16
+
3
17
  ## 2.0.7
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -401,7 +401,7 @@ var assemblyaiTranscriptionResponseSchema = import_v42.z.object({
401
401
  });
402
402
 
403
403
  // src/version.ts
404
- var VERSION = true ? "2.0.7" : "0.0.0-test";
404
+ var VERSION = true ? "2.0.9" : "0.0.0-test";
405
405
 
406
406
  // src/assemblyai-provider.ts
407
407
  function createAssemblyAI(options = {}) {
package/dist/index.mjs CHANGED
@@ -385,7 +385,7 @@ var assemblyaiTranscriptionResponseSchema = z2.object({
385
385
  });
386
386
 
387
387
  // src/version.ts
388
- var VERSION = true ? "2.0.7" : "0.0.0-test";
388
+ var VERSION = true ? "2.0.9" : "0.0.0-test";
389
389
 
390
390
  // src/assemblyai-provider.ts
391
391
  function createAssemblyAI(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/assemblyai",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -8,6 +8,7 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
11
+ "src",
11
12
  "CHANGELOG.md",
12
13
  "README.md"
13
14
  ],
@@ -20,15 +21,15 @@
20
21
  }
21
22
  },
22
23
  "dependencies": {
23
- "@ai-sdk/provider": "3.0.3",
24
- "@ai-sdk/provider-utils": "4.0.7"
24
+ "@ai-sdk/provider": "3.0.4",
25
+ "@ai-sdk/provider-utils": "4.0.8"
25
26
  },
26
27
  "devDependencies": {
27
28
  "@types/node": "20.17.24",
28
29
  "tsup": "^8",
29
30
  "typescript": "5.6.3",
30
31
  "zod": "3.25.76",
31
- "@ai-sdk/test-server": "1.0.1",
32
+ "@ai-sdk/test-server": "1.0.2",
32
33
  "@vercel/ai-tsconfig": "0.0.0"
33
34
  },
34
35
  "peerDependencies": {
@@ -0,0 +1,362 @@
1
+ export type AssemblyAITranscriptionAPITypes = {
2
+ /**
3
+ * The URL of the audio or video file to transcribe.
4
+ */
5
+ audio_url: string;
6
+
7
+ /**
8
+ * The point in time, in milliseconds, to stop transcribing in your media file
9
+ */
10
+ audio_end_at?: number;
11
+
12
+ /**
13
+ * The point in time, in milliseconds, to begin transcribing in your media file
14
+ */
15
+ audio_start_from?: number;
16
+
17
+ /**
18
+ * Enable Auto Chapters, can be true or false
19
+ * @default false
20
+ */
21
+ auto_chapters?: boolean;
22
+
23
+ /**
24
+ * Enable Key Phrases, either true or false
25
+ * @default false
26
+ */
27
+ auto_highlights?: boolean;
28
+
29
+ /**
30
+ * How much to boost specified words
31
+ */
32
+ boost_param?: 'low' | 'default' | 'high';
33
+
34
+ /**
35
+ * Enable Content Moderation, can be true or false
36
+ * @default false
37
+ */
38
+ content_safety?: boolean;
39
+
40
+ /**
41
+ * The confidence threshold for the Content Moderation model. Values must be between 25 and 100.
42
+ * @default 50
43
+ */
44
+ content_safety_confidence?: number;
45
+
46
+ /**
47
+ * Customize how words are spelled and formatted using to and from values
48
+ */
49
+ custom_spelling?: Array<{
50
+ /**
51
+ * Words or phrases to replace
52
+ */
53
+ from: string[];
54
+ /**
55
+ * Word to replace with
56
+ */
57
+ to: string;
58
+ }>;
59
+
60
+ /**
61
+ * Transcribe Filler Words, like "umm", in your media file; can be true or false
62
+ * @default false
63
+ */
64
+ disfluencies?: boolean;
65
+
66
+ /**
67
+ * Enable Entity Detection, can be true or false
68
+ * @default false
69
+ */
70
+ entity_detection?: boolean;
71
+
72
+ /**
73
+ * Filter profanity from the transcribed text, can be true or false
74
+ * @default false
75
+ */
76
+ filter_profanity?: boolean;
77
+
78
+ /**
79
+ * Enable Text Formatting, can be true or false
80
+ * @default true
81
+ */
82
+ format_text?: boolean;
83
+
84
+ /**
85
+ * Enable Topic Detection, can be true or false
86
+ * @default false
87
+ */
88
+ iab_categories?: boolean;
89
+
90
+ /**
91
+ * The language of your audio file. Possible values are found in Supported Languages.
92
+ * @default 'en_us'
93
+ */
94
+ language_code?:
95
+ | 'en'
96
+ | 'en_au'
97
+ | 'en_uk'
98
+ | 'en_us'
99
+ | 'es'
100
+ | 'fr'
101
+ | 'de'
102
+ | 'it'
103
+ | 'pt'
104
+ | 'nl'
105
+ | 'af'
106
+ | 'sq'
107
+ | 'am'
108
+ | 'ar'
109
+ | 'hy'
110
+ | 'as'
111
+ | 'az'
112
+ | 'ba'
113
+ | 'eu'
114
+ | 'be'
115
+ | 'bn'
116
+ | 'bs'
117
+ | 'br'
118
+ | 'bg'
119
+ | 'my'
120
+ | 'ca'
121
+ | 'zh'
122
+ | 'hr'
123
+ | 'cs'
124
+ | 'da'
125
+ | 'et'
126
+ | 'fo'
127
+ | 'fi'
128
+ | 'gl'
129
+ | 'ka'
130
+ | 'el'
131
+ | 'gu'
132
+ | 'ht'
133
+ | 'ha'
134
+ | 'haw'
135
+ | 'he'
136
+ | 'hi'
137
+ | 'hu'
138
+ | 'is'
139
+ | 'id'
140
+ | 'ja'
141
+ | 'jw'
142
+ | 'kn'
143
+ | 'kk'
144
+ | 'km'
145
+ | 'ko'
146
+ | 'lo'
147
+ | 'la'
148
+ | 'lv'
149
+ | 'ln'
150
+ | 'lt'
151
+ | 'lb'
152
+ | 'mk'
153
+ | 'mg'
154
+ | 'ms'
155
+ | 'ml'
156
+ | 'mt'
157
+ | 'mi'
158
+ | 'mr'
159
+ | 'mn'
160
+ | 'ne'
161
+ | 'no'
162
+ | 'nn'
163
+ | 'oc'
164
+ | 'pa'
165
+ | 'ps'
166
+ | 'fa'
167
+ | 'pl'
168
+ | 'ro'
169
+ | 'ru'
170
+ | 'sa'
171
+ | 'sr'
172
+ | 'sn'
173
+ | 'sd'
174
+ | 'si'
175
+ | 'sk'
176
+ | 'sl'
177
+ | 'so'
178
+ | 'su'
179
+ | 'sw'
180
+ | 'sv'
181
+ | 'tl'
182
+ | 'tg'
183
+ | 'ta'
184
+ | 'tt'
185
+ | 'te'
186
+ | 'th'
187
+ | 'bo'
188
+ | 'tr'
189
+ | 'tk'
190
+ | 'uk'
191
+ | 'ur'
192
+ | 'uz'
193
+ | 'vi'
194
+ | 'cy'
195
+ | 'yi'
196
+ | 'yo';
197
+
198
+ /**
199
+ * The confidence threshold for the automatically detected language. An error will be returned if the language confidence is below this threshold.
200
+ * @default 0
201
+ */
202
+ language_confidence_threshold?: number;
203
+
204
+ /**
205
+ * Enable Automatic language detection, either true or false.
206
+ * @default false
207
+ */
208
+ language_detection?: boolean;
209
+
210
+ /**
211
+ * Enable Multichannel transcription, can be true or false.
212
+ * @default false
213
+ */
214
+ multichannel?: boolean;
215
+
216
+ /**
217
+ * Enable Automatic Punctuation, can be true or false
218
+ * @default true
219
+ */
220
+ punctuate?: boolean;
221
+
222
+ /**
223
+ * Redact PII from the transcribed text using the Redact PII model, can be true or false
224
+ * @default false
225
+ */
226
+ redact_pii?: boolean;
227
+
228
+ /**
229
+ * Generate a copy of the original media file with spoken PII "beeped" out, can be true or false.
230
+ * @default false
231
+ */
232
+ redact_pii_audio?: boolean;
233
+
234
+ /**
235
+ * Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav.
236
+ */
237
+ redact_pii_audio_quality?: 'mp3' | 'wav';
238
+
239
+ /**
240
+ * The list of PII Redaction policies to enable.
241
+ */
242
+ redact_pii_policies?: Array<
243
+ | 'account_number'
244
+ | 'banking_information'
245
+ | 'blood_type'
246
+ | 'credit_card_cvv'
247
+ | 'credit_card_expiration'
248
+ | 'credit_card_number'
249
+ | 'date'
250
+ | 'date_interval'
251
+ | 'date_of_birth'
252
+ | 'drivers_license'
253
+ | 'drug'
254
+ | 'duration'
255
+ | 'email_address'
256
+ | 'event'
257
+ | 'filename'
258
+ | 'gender_sexuality'
259
+ | 'healthcare_number'
260
+ | 'injury'
261
+ | 'ip_address'
262
+ | 'language'
263
+ | 'location'
264
+ | 'marital_status'
265
+ | 'medical_condition'
266
+ | 'medical_process'
267
+ | 'money_amount'
268
+ | 'nationality'
269
+ | 'number_sequence'
270
+ | 'occupation'
271
+ | 'organization'
272
+ | 'passport_number'
273
+ | 'password'
274
+ | 'person_age'
275
+ | 'person_name'
276
+ | 'phone_number'
277
+ | 'physical_attribute'
278
+ | 'political_affiliation'
279
+ | 'religion'
280
+ | 'statistics'
281
+ | 'time'
282
+ | 'url'
283
+ | 'us_social_security_number'
284
+ | 'username'
285
+ | 'vehicle_id'
286
+ | 'zodiac_sign'
287
+ >;
288
+
289
+ /**
290
+ * The replacement logic for detected PII, can be "entity_name" or "hash".
291
+ */
292
+ redact_pii_sub?: 'entity_name' | 'hash';
293
+
294
+ /**
295
+ * Enable Sentiment Analysis, can be true or false
296
+ * @default false
297
+ */
298
+ sentiment_analysis?: boolean;
299
+
300
+ /**
301
+ * Enable Speaker diarization, can be true or false
302
+ * @default false
303
+ */
304
+ speaker_labels?: boolean;
305
+
306
+ /**
307
+ * Tells the speaker label model how many speakers it should attempt to identify, up to 10.
308
+ */
309
+ speakers_expected?: number;
310
+
311
+ /**
312
+ * The speech model to use for the transcription.
313
+ */
314
+ speech_model?: 'best' | 'nano';
315
+
316
+ /**
317
+ * Reject audio files that contain less than this fraction of speech. Valid values are in the range [0, 1] inclusive.
318
+ */
319
+ speech_threshold?: number;
320
+
321
+ /**
322
+ * Enable Summarization, can be true or false
323
+ * @default false
324
+ */
325
+ summarization?: boolean;
326
+
327
+ /**
328
+ * The model to summarize the transcript
329
+ */
330
+ summary_model?: 'informative' | 'conversational' | 'catchy';
331
+
332
+ /**
333
+ * The type of summary
334
+ */
335
+ summary_type?:
336
+ | 'bullets'
337
+ | 'bullets_verbose'
338
+ | 'gist'
339
+ | 'headline'
340
+ | 'paragraph';
341
+
342
+ /**
343
+ * The header name to be sent with the transcript completed or failed webhook requests
344
+ */
345
+ webhook_auth_header_name?: string;
346
+
347
+ /**
348
+ * The header value to send back with the transcript completed or failed webhook requests for added security
349
+ */
350
+ webhook_auth_header_value?: string;
351
+
352
+ /**
353
+ * The URL to which we send webhook requests. We sends two different types of webhook requests.
354
+ * One request when a transcript is completed or failed, and one request when the redacted audio is ready if redact_pii_audio is enabled.
355
+ */
356
+ webhook_url?: string;
357
+
358
+ /**
359
+ * The list of custom vocabulary to boost transcription probability for
360
+ */
361
+ word_boost?: string[];
362
+ };
@@ -0,0 +1,9 @@
1
+ import { FetchFunction } from '@ai-sdk/provider-utils';
2
+
3
+ export type AssemblyAIConfig = {
4
+ provider: string;
5
+ url: (options: { modelId: string; path: string }) => string;
6
+ headers: () => Record<string, string | undefined>;
7
+ fetch?: FetchFunction;
8
+ generateId?: () => string;
9
+ };
@@ -0,0 +1,34 @@
1
+ import { safeParseJSON } from '@ai-sdk/provider-utils';
2
+ import { assemblyaiErrorDataSchema } from './assemblyai-error';
3
+ import { describe, it, expect } from 'vitest';
4
+
5
+ describe('assemblyaiErrorDataSchema', () => {
6
+ it('should parse AssemblyAI resource exhausted error', async () => {
7
+ const error = `
8
+ {"error":{"message":"{\\n \\"error\\": {\\n \\"code\\": 429,\\n \\"message\\": \\"Resource has been exhausted (e.g. check quota).\\",\\n \\"status\\": \\"RESOURCE_EXHAUSTED\\"\\n }\\n}\\n","code":429}}
9
+ `;
10
+
11
+ const result = await safeParseJSON({
12
+ text: error,
13
+ schema: assemblyaiErrorDataSchema,
14
+ });
15
+
16
+ expect(result).toStrictEqual({
17
+ success: true,
18
+ value: {
19
+ error: {
20
+ message:
21
+ '{\n "error": {\n "code": 429,\n "message": "Resource has been exhausted (e.g. check quota).",\n "status": "RESOURCE_EXHAUSTED"\n }\n}\n',
22
+ code: 429,
23
+ },
24
+ },
25
+ rawValue: {
26
+ error: {
27
+ message:
28
+ '{\n "error": {\n "code": 429,\n "message": "Resource has been exhausted (e.g. check quota).",\n "status": "RESOURCE_EXHAUSTED"\n }\n}\n',
29
+ code: 429,
30
+ },
31
+ },
32
+ });
33
+ });
34
+ });
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod/v4';
2
+ import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
3
+
4
+ export const assemblyaiErrorDataSchema = z.object({
5
+ error: z.object({
6
+ message: z.string(),
7
+ code: z.number(),
8
+ }),
9
+ });
10
+
11
+ export type AssemblyAIErrorData = z.infer<typeof assemblyaiErrorDataSchema>;
12
+
13
+ export const assemblyaiFailedResponseHandler = createJsonErrorResponseHandler({
14
+ errorSchema: assemblyaiErrorDataSchema,
15
+ errorToMessage: data => data.error.message,
16
+ });
@@ -0,0 +1,112 @@
1
+ import {
2
+ TranscriptionModelV3,
3
+ ProviderV3,
4
+ NoSuchModelError,
5
+ } from '@ai-sdk/provider';
6
+ import {
7
+ FetchFunction,
8
+ loadApiKey,
9
+ withUserAgentSuffix,
10
+ } from '@ai-sdk/provider-utils';
11
+ import { AssemblyAITranscriptionModel } from './assemblyai-transcription-model';
12
+ import { AssemblyAITranscriptionModelId } from './assemblyai-transcription-settings';
13
+ import { VERSION } from './version';
14
+
15
+ export interface AssemblyAIProvider extends ProviderV3 {
16
+ (
17
+ modelId: 'best',
18
+ settings?: {},
19
+ ): {
20
+ transcription: AssemblyAITranscriptionModel;
21
+ };
22
+
23
+ /**
24
+ Creates a model for transcription.
25
+ */
26
+ transcription(modelId: AssemblyAITranscriptionModelId): TranscriptionModelV3;
27
+
28
+ /**
29
+ * @deprecated Use `embeddingModel` instead.
30
+ */
31
+ textEmbeddingModel(modelId: string): never;
32
+ }
33
+
34
+ export interface AssemblyAIProviderSettings {
35
+ /**
36
+ API key for authenticating requests.
37
+ */
38
+ apiKey?: string;
39
+
40
+ /**
41
+ Custom headers to include in the requests.
42
+ */
43
+ headers?: Record<string, string>;
44
+
45
+ /**
46
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
47
+ or to provide a custom fetch implementation for e.g. testing.
48
+ */
49
+ fetch?: FetchFunction;
50
+ }
51
+
52
+ /**
53
+ Create an AssemblyAI provider instance.
54
+ */
55
+ export function createAssemblyAI(
56
+ options: AssemblyAIProviderSettings = {},
57
+ ): AssemblyAIProvider {
58
+ const getHeaders = () =>
59
+ withUserAgentSuffix(
60
+ {
61
+ authorization: loadApiKey({
62
+ apiKey: options.apiKey,
63
+ environmentVariableName: 'ASSEMBLYAI_API_KEY',
64
+ description: 'AssemblyAI',
65
+ }),
66
+ ...options.headers,
67
+ },
68
+ `ai-sdk/assemblyai/${VERSION}`,
69
+ );
70
+
71
+ const createTranscriptionModel = (modelId: AssemblyAITranscriptionModelId) =>
72
+ new AssemblyAITranscriptionModel(modelId, {
73
+ provider: `assemblyai.transcription`,
74
+ url: ({ path }) => `https://api.assemblyai.com${path}`,
75
+ headers: getHeaders,
76
+ fetch: options.fetch,
77
+ });
78
+
79
+ const provider = function (modelId: AssemblyAITranscriptionModelId) {
80
+ return {
81
+ transcription: createTranscriptionModel(modelId),
82
+ };
83
+ };
84
+
85
+ provider.specificationVersion = 'v3' as const;
86
+ provider.transcription = createTranscriptionModel;
87
+ provider.transcriptionModel = createTranscriptionModel;
88
+
89
+ provider.languageModel = () => {
90
+ throw new NoSuchModelError({
91
+ modelId: 'unknown',
92
+ modelType: 'languageModel',
93
+ message: 'AssemblyAI does not provide language models',
94
+ });
95
+ };
96
+
97
+ provider.embeddingModel = (modelId: string) => {
98
+ throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });
99
+ };
100
+ provider.textEmbeddingModel = provider.embeddingModel;
101
+
102
+ provider.imageModel = (modelId: string) => {
103
+ throw new NoSuchModelError({ modelId, modelType: 'imageModel' });
104
+ };
105
+
106
+ return provider as AssemblyAIProvider;
107
+ }
108
+
109
+ /**
110
+ Default AssemblyAI provider instance.
111
+ */
112
+ export const assemblyai = createAssemblyAI();