@ai-sdk/assemblyai 3.0.0-beta.3 → 3.0.0-beta.31

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,10 +1,10 @@
1
1
  {
2
2
  "name": "@ai-sdk/assemblyai",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.31",
4
+ "type": "module",
4
5
  "license": "Apache-2.0",
5
6
  "sideEffects": false,
6
7
  "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
@@ -24,20 +24,20 @@
24
24
  "./package.json": "./package.json",
25
25
  ".": {
26
26
  "types": "./dist/index.d.ts",
27
- "import": "./dist/index.mjs",
28
- "require": "./dist/index.js"
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/provider": "4.0.0-beta.1",
33
- "@ai-sdk/provider-utils": "5.0.0-beta.2"
32
+ "@ai-sdk/provider": "4.0.0-beta.14",
33
+ "@ai-sdk/provider-utils": "5.0.0-beta.29"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "20.17.24",
37
37
  "tsup": "^8",
38
38
  "typescript": "5.6.3",
39
39
  "zod": "3.25.76",
40
- "@ai-sdk/test-server": "2.0.0-beta.0",
40
+ "@ai-sdk/test-server": "2.0.0-beta.3",
41
41
  "@vercel/ai-tsconfig": "0.0.0"
42
42
  },
43
43
  "peerDependencies": {
@@ -47,12 +47,14 @@
47
47
  "node": ">=18"
48
48
  },
49
49
  "publishConfig": {
50
- "access": "public"
50
+ "access": "public",
51
+ "provenance": true
51
52
  },
52
53
  "homepage": "https://ai-sdk.dev/docs",
53
54
  "repository": {
54
55
  "type": "git",
55
- "url": "git+https://github.com/vercel/ai.git"
56
+ "url": "https://github.com/vercel/ai",
57
+ "directory": "packages/assemblyai"
56
58
  },
57
59
  "bugs": {
58
60
  "url": "https://github.com/vercel/ai/issues"
@@ -64,9 +66,7 @@
64
66
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
65
67
  "build:watch": "pnpm clean && tsup --watch --tsconfig tsconfig.build.json",
66
68
  "clean": "del-cli dist docs *.tsbuildinfo",
67
- "lint": "eslint \"./**/*.ts*\"",
68
69
  "type-check": "tsc --build",
69
- "prettier-check": "prettier --check \"./**/*.ts*\"",
70
70
  "test": "pnpm test:node && pnpm test:edge",
71
71
  "test:watch": "vitest --config vitest.node.config.js",
72
72
  "test:edge": "vitest --config vitest.edge.config.js --run",
@@ -1,9 +1,9 @@
1
- import { FetchFunction } from '@ai-sdk/provider-utils';
1
+ import type { FetchFunction } from '@ai-sdk/provider-utils';
2
2
 
3
3
  export type AssemblyAIConfig = {
4
4
  provider: string;
5
5
  url: (options: { modelId: string; path: string }) => string;
6
- headers: () => Record<string, string | undefined>;
6
+ headers?: () => Record<string, string | undefined>;
7
7
  fetch?: FetchFunction;
8
8
  generateId?: () => string;
9
9
  };
@@ -1,15 +1,15 @@
1
1
  import {
2
- TranscriptionModelV4,
3
- ProviderV4,
4
2
  NoSuchModelError,
3
+ type TranscriptionModelV4,
4
+ type ProviderV4,
5
5
  } from '@ai-sdk/provider';
6
6
  import {
7
- FetchFunction,
8
7
  loadApiKey,
9
8
  withUserAgentSuffix,
9
+ type FetchFunction,
10
10
  } from '@ai-sdk/provider-utils';
11
11
  import { AssemblyAITranscriptionModel } from './assemblyai-transcription-model';
12
- import { AssemblyAITranscriptionModelId } from './assemblyai-transcription-settings';
12
+ import type { AssemblyAITranscriptionModelId } from './assemblyai-transcription-settings';
13
13
  import { VERSION } from './version';
14
14
 
15
15
  export interface AssemblyAIProvider extends ProviderV4 {
@@ -1,4 +1,4 @@
1
- import { TranscriptionModelV4, SharedV4Warning } from '@ai-sdk/provider';
1
+ import type { TranscriptionModelV4, SharedV4Warning } from '@ai-sdk/provider';
2
2
  import {
3
3
  combineHeaders,
4
4
  createJsonResponseHandler,
@@ -6,12 +6,15 @@ import {
6
6
  parseProviderOptions,
7
7
  postJsonToApi,
8
8
  postToApi,
9
+ serializeModelOptions,
10
+ WORKFLOW_SERIALIZE,
11
+ WORKFLOW_DESERIALIZE,
9
12
  } from '@ai-sdk/provider-utils';
10
13
  import { z } from 'zod/v4';
11
- import { AssemblyAIConfig } from './assemblyai-config';
14
+ import type { AssemblyAIConfig } from './assemblyai-config';
12
15
  import { assemblyaiFailedResponseHandler } from './assemblyai-error';
13
- import { AssemblyAITranscriptionModelId } from './assemblyai-transcription-settings';
14
- import { AssemblyAITranscriptionAPITypes } from './assemblyai-api-types';
16
+ import type { AssemblyAITranscriptionModelId } from './assemblyai-transcription-settings';
17
+ import type { AssemblyAITranscriptionAPITypes } from './assemblyai-api-types';
15
18
 
16
19
  // https://www.assemblyai.com/docs/api-reference/transcripts/submit
17
20
  const assemblyaiTranscriptionModelOptionsSchema = z.object({
@@ -183,6 +186,20 @@ export class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
183
186
  return this.config.provider;
184
187
  }
185
188
 
189
+ static [WORKFLOW_SERIALIZE](model: AssemblyAITranscriptionModel) {
190
+ return serializeModelOptions({
191
+ modelId: model.modelId,
192
+ config: model.config,
193
+ });
194
+ }
195
+
196
+ static [WORKFLOW_DESERIALIZE](options: {
197
+ modelId: AssemblyAITranscriptionModelId;
198
+ config: AssemblyAITranscriptionModelConfig;
199
+ }) {
200
+ return new AssemblyAITranscriptionModel(options.modelId, options.config);
201
+ }
202
+
186
203
  constructor(
187
204
  readonly modelId: AssemblyAITranscriptionModelId,
188
205
  private readonly config: AssemblyAITranscriptionModelConfig,
@@ -201,7 +218,7 @@ export class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
201
218
  });
202
219
 
203
220
  const body: Omit<AssemblyAITranscriptionAPITypes, 'audio_url'> = {
204
- speech_model: this.modelId,
221
+ speech_model: this.modelId as 'best' | 'nano',
205
222
  };
206
223
 
207
224
  // Add provider-specific options
@@ -289,7 +306,7 @@ export class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
289
306
  {
290
307
  method: 'GET',
291
308
  headers: combineHeaders(
292
- this.config.headers(),
309
+ this.config.headers?.(),
293
310
  headers,
294
311
  ) as HeadersInit,
295
312
  signal: abortSignal,
@@ -340,7 +357,7 @@ export class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
340
357
  }),
341
358
  headers: {
342
359
  'Content-Type': 'application/octet-stream',
343
- ...combineHeaders(this.config.headers(), options.headers),
360
+ ...combineHeaders(this.config.headers?.(), options.headers),
344
361
  },
345
362
  body: {
346
363
  content: options.audio,
@@ -361,7 +378,7 @@ export class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
361
378
  path: '/v2/transcript',
362
379
  modelId: this.modelId,
363
380
  }),
364
- headers: combineHeaders(this.config.headers(), options.headers),
381
+ headers: combineHeaders(this.config.headers?.(), options.headers),
365
382
  body: {
366
383
  ...body,
367
384
  audio_url: uploadResponse.upload_url,
@@ -1 +1 @@
1
- export type AssemblyAITranscriptionModelId = 'best' | 'nano';
1
+ export type AssemblyAITranscriptionModelId = 'best' | 'nano' | (string & {});
package/dist/index.d.mts DELETED
@@ -1,123 +0,0 @@
1
- import { TranscriptionModelV4, ProviderV4 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod/v4';
4
-
5
- type AssemblyAIConfig = {
6
- provider: string;
7
- url: (options: {
8
- modelId: string;
9
- path: string;
10
- }) => string;
11
- headers: () => Record<string, string | undefined>;
12
- fetch?: FetchFunction;
13
- generateId?: () => string;
14
- };
15
-
16
- type AssemblyAITranscriptionModelId = 'best' | 'nano';
17
-
18
- declare const assemblyaiTranscriptionModelOptionsSchema: z.ZodObject<{
19
- audioEndAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
20
- audioStartFrom: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
21
- autoChapters: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
22
- autoHighlights: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
23
- boostParam: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
- contentSafety: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
25
- contentSafetyConfidence: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
26
- customSpelling: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
27
- from: z.ZodArray<z.ZodString>;
28
- to: z.ZodString;
29
- }, z.core.$strip>>>>;
30
- disfluencies: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
31
- entityDetection: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
32
- filterProfanity: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
33
- formatText: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
34
- iabCategories: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
35
- languageCode: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"en">, z.ZodString]>>>;
36
- languageConfidenceThreshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
37
- languageDetection: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
38
- multichannel: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
39
- punctuate: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
40
- redactPii: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
41
- redactPiiAudio: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
42
- redactPiiAudioQuality: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
- redactPiiPolicies: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
44
- redactPiiSub: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
- sentimentAnalysis: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
46
- speakerLabels: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
47
- speakersExpected: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
48
- speechThreshold: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
49
- summarization: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
50
- summaryModel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
- summaryType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
- webhookAuthHeaderName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
- webhookAuthHeaderValue: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
- webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
- wordBoost: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
56
- }, z.core.$strip>;
57
- type AssemblyAITranscriptionModelOptions = z.infer<typeof assemblyaiTranscriptionModelOptionsSchema>;
58
- interface AssemblyAITranscriptionModelConfig extends AssemblyAIConfig {
59
- _internal?: {
60
- currentDate?: () => Date;
61
- };
62
- /**
63
- * The polling interval for checking transcript status in milliseconds.
64
- */
65
- pollingInterval?: number;
66
- }
67
- declare class AssemblyAITranscriptionModel implements TranscriptionModelV4 {
68
- readonly modelId: AssemblyAITranscriptionModelId;
69
- private readonly config;
70
- readonly specificationVersion = "v4";
71
- private readonly POLLING_INTERVAL_MS;
72
- get provider(): string;
73
- constructor(modelId: AssemblyAITranscriptionModelId, config: AssemblyAITranscriptionModelConfig);
74
- private getArgs;
75
- /**
76
- * Polls the given transcript until we have a status other than `processing` or `queued`.
77
- *
78
- * @see https://www.assemblyai.com/docs/getting-started/transcribe-an-audio-file#step-33
79
- */
80
- private waitForCompletion;
81
- doGenerate(options: Parameters<TranscriptionModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>>;
82
- }
83
-
84
- interface AssemblyAIProvider extends ProviderV4 {
85
- (modelId: 'best', settings?: {}): {
86
- transcription: AssemblyAITranscriptionModel;
87
- };
88
- /**
89
- * Creates a model for transcription.
90
- */
91
- transcription(modelId: AssemblyAITranscriptionModelId): TranscriptionModelV4;
92
- /**
93
- * @deprecated Use `embeddingModel` instead.
94
- */
95
- textEmbeddingModel(modelId: string): never;
96
- }
97
- interface AssemblyAIProviderSettings {
98
- /**
99
- * API key for authenticating requests.
100
- */
101
- apiKey?: string;
102
- /**
103
- * Custom headers to include in the requests.
104
- */
105
- headers?: Record<string, string>;
106
- /**
107
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
108
- * or to provide a custom fetch implementation for e.g. testing.
109
- */
110
- fetch?: FetchFunction;
111
- }
112
- /**
113
- * Create an AssemblyAI provider instance.
114
- */
115
- declare function createAssemblyAI(options?: AssemblyAIProviderSettings): AssemblyAIProvider;
116
- /**
117
- * Default AssemblyAI provider instance.
118
- */
119
- declare const assemblyai: AssemblyAIProvider;
120
-
121
- declare const VERSION: string;
122
-
123
- export { type AssemblyAIProvider, type AssemblyAIProviderSettings, type AssemblyAITranscriptionModelOptions, VERSION, assemblyai, createAssemblyAI };