ai 4.3.4 → 4.3.6
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 +18 -0
- package/dist/index.d.mts +147 -13
- package/dist/index.d.ts +147 -13
- package/dist/index.js +117 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
@@ -6282,9 +6282,99 @@ var DefaultStreamTextResult = class {
|
|
6282
6282
|
}
|
6283
6283
|
};
|
6284
6284
|
|
6285
|
-
// errors/no-
|
6285
|
+
// errors/no-speech-generated-error.ts
|
6286
6286
|
import { AISDKError as AISDKError18 } from "@ai-sdk/provider";
|
6287
|
-
var
|
6287
|
+
var NoSpeechGeneratedError = class extends AISDKError18 {
|
6288
|
+
constructor(options) {
|
6289
|
+
super({
|
6290
|
+
name: "AI_NoSpeechGeneratedError",
|
6291
|
+
message: "No speech audio generated."
|
6292
|
+
});
|
6293
|
+
this.responses = options.responses;
|
6294
|
+
}
|
6295
|
+
};
|
6296
|
+
|
6297
|
+
// core/generate-speech/generated-audio-file.ts
|
6298
|
+
var DefaultGeneratedAudioFile = class extends DefaultGeneratedFile {
|
6299
|
+
constructor({
|
6300
|
+
data,
|
6301
|
+
mimeType
|
6302
|
+
}) {
|
6303
|
+
super({ data, mimeType });
|
6304
|
+
let format = "mp3";
|
6305
|
+
if (mimeType) {
|
6306
|
+
const mimeTypeParts = mimeType.split("/");
|
6307
|
+
if (mimeTypeParts.length === 2) {
|
6308
|
+
if (mimeType !== "audio/mpeg") {
|
6309
|
+
format = mimeTypeParts[1];
|
6310
|
+
}
|
6311
|
+
}
|
6312
|
+
}
|
6313
|
+
if (!format) {
|
6314
|
+
throw new Error(
|
6315
|
+
"Audio format must be provided or determinable from mimeType"
|
6316
|
+
);
|
6317
|
+
}
|
6318
|
+
this.format = format;
|
6319
|
+
}
|
6320
|
+
};
|
6321
|
+
|
6322
|
+
// core/generate-speech/generate-speech.ts
|
6323
|
+
async function generateSpeech({
|
6324
|
+
model,
|
6325
|
+
text: text2,
|
6326
|
+
voice,
|
6327
|
+
outputFormat,
|
6328
|
+
instructions,
|
6329
|
+
speed,
|
6330
|
+
providerOptions = {},
|
6331
|
+
maxRetries: maxRetriesArg,
|
6332
|
+
abortSignal,
|
6333
|
+
headers
|
6334
|
+
}) {
|
6335
|
+
var _a17;
|
6336
|
+
const { retry } = prepareRetries({ maxRetries: maxRetriesArg });
|
6337
|
+
const result = await retry(
|
6338
|
+
() => model.doGenerate({
|
6339
|
+
text: text2,
|
6340
|
+
voice,
|
6341
|
+
outputFormat,
|
6342
|
+
instructions,
|
6343
|
+
speed,
|
6344
|
+
abortSignal,
|
6345
|
+
headers,
|
6346
|
+
providerOptions
|
6347
|
+
})
|
6348
|
+
);
|
6349
|
+
if (!result.audio || result.audio.length === 0) {
|
6350
|
+
throw new NoSpeechGeneratedError({ responses: [result.response] });
|
6351
|
+
}
|
6352
|
+
return new DefaultSpeechResult({
|
6353
|
+
audio: new DefaultGeneratedAudioFile({
|
6354
|
+
data: result.audio,
|
6355
|
+
mimeType: (_a17 = detectMimeType({
|
6356
|
+
data: result.audio,
|
6357
|
+
signatures: audioMimeTypeSignatures
|
6358
|
+
})) != null ? _a17 : "audio/mp3"
|
6359
|
+
}),
|
6360
|
+
warnings: result.warnings,
|
6361
|
+
responses: [result.response],
|
6362
|
+
providerMetadata: result.providerMetadata
|
6363
|
+
});
|
6364
|
+
}
|
6365
|
+
var DefaultSpeechResult = class {
|
6366
|
+
constructor(options) {
|
6367
|
+
var _a17;
|
6368
|
+
this.audio = options.audio;
|
6369
|
+
this.warnings = options.warnings;
|
6370
|
+
this.responses = options.responses;
|
6371
|
+
this.providerMetadata = (_a17 = options.providerMetadata) != null ? _a17 : {};
|
6372
|
+
}
|
6373
|
+
};
|
6374
|
+
|
6375
|
+
// errors/no-transcript-generated-error.ts
|
6376
|
+
import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
|
6377
|
+
var NoTranscriptGeneratedError = class extends AISDKError19 {
|
6288
6378
|
constructor(options) {
|
6289
6379
|
super({
|
6290
6380
|
name: "AI_NoTranscriptGeneratedError",
|
@@ -6663,7 +6753,7 @@ function appendClientMessage({
|
|
6663
6753
|
import {
|
6664
6754
|
extractMaxToolInvocationStep
|
6665
6755
|
} from "@ai-sdk/ui-utils";
|
6666
|
-
import { AISDKError as
|
6756
|
+
import { AISDKError as AISDKError20 } from "@ai-sdk/provider";
|
6667
6757
|
function appendResponseMessages({
|
6668
6758
|
messages,
|
6669
6759
|
responseMessages,
|
@@ -6746,7 +6836,7 @@ function appendResponseMessages({
|
|
6746
6836
|
break;
|
6747
6837
|
case "file":
|
6748
6838
|
if (part.data instanceof URL) {
|
6749
|
-
throw new
|
6839
|
+
throw new AISDKError20({
|
6750
6840
|
name: "InvalidAssistantFileData",
|
6751
6841
|
message: "File data cannot be a URL"
|
6752
6842
|
});
|
@@ -6880,7 +6970,7 @@ function customProvider({
|
|
6880
6970
|
var experimental_customProvider = customProvider;
|
6881
6971
|
|
6882
6972
|
// core/registry/no-such-provider-error.ts
|
6883
|
-
import { AISDKError as
|
6973
|
+
import { AISDKError as AISDKError21, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
|
6884
6974
|
var name16 = "AI_NoSuchProviderError";
|
6885
6975
|
var marker16 = `vercel.ai.error.${name16}`;
|
6886
6976
|
var symbol16 = Symbol.for(marker16);
|
@@ -6899,7 +6989,7 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
|
|
6899
6989
|
this.availableProviders = availableProviders;
|
6900
6990
|
}
|
6901
6991
|
static isInstance(error) {
|
6902
|
-
return
|
6992
|
+
return AISDKError21.hasMarker(error, marker16);
|
6903
6993
|
}
|
6904
6994
|
};
|
6905
6995
|
_a16 = symbol16;
|
@@ -6950,7 +7040,7 @@ var DefaultProviderRegistry = class {
|
|
6950
7040
|
message: `Invalid ${modelType} id for registry: ${id} (must be in the format "providerId${this.separator}modelId")`
|
6951
7041
|
});
|
6952
7042
|
}
|
6953
|
-
return [id.slice(0, index), id.slice(index +
|
7043
|
+
return [id.slice(0, index), id.slice(index + this.separator.length)];
|
6954
7044
|
}
|
6955
7045
|
languageModel(id) {
|
6956
7046
|
var _a17, _b;
|
@@ -7473,6 +7563,7 @@ var MCPClient = class {
|
|
7473
7563
|
async tools({
|
7474
7564
|
schemas = "automatic"
|
7475
7565
|
} = {}) {
|
7566
|
+
var _a17;
|
7476
7567
|
const tools = {};
|
7477
7568
|
try {
|
7478
7569
|
const listToolsResult = await this.listTools();
|
@@ -7480,14 +7571,18 @@ var MCPClient = class {
|
|
7480
7571
|
if (schemas !== "automatic" && !(name17 in schemas)) {
|
7481
7572
|
continue;
|
7482
7573
|
}
|
7483
|
-
const parameters = schemas === "automatic" ? jsonSchema(
|
7574
|
+
const parameters = schemas === "automatic" ? jsonSchema({
|
7575
|
+
...inputSchema,
|
7576
|
+
properties: (_a17 = inputSchema.properties) != null ? _a17 : {},
|
7577
|
+
additionalProperties: false
|
7578
|
+
}) : schemas[name17].parameters;
|
7484
7579
|
const self = this;
|
7485
7580
|
const toolWithExecute = tool({
|
7486
7581
|
description,
|
7487
7582
|
parameters,
|
7488
7583
|
execute: async (args, options) => {
|
7489
|
-
var
|
7490
|
-
(
|
7584
|
+
var _a18;
|
7585
|
+
(_a18 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a18.throwIfAborted();
|
7491
7586
|
return self.callTool({
|
7492
7587
|
name: name17,
|
7493
7588
|
args,
|
@@ -7983,6 +8078,7 @@ export {
|
|
7983
8078
|
experimental_createProviderRegistry,
|
7984
8079
|
experimental_customProvider,
|
7985
8080
|
generateImage as experimental_generateImage,
|
8081
|
+
generateSpeech as experimental_generateSpeech,
|
7986
8082
|
transcribe as experimental_transcribe,
|
7987
8083
|
experimental_wrapLanguageModel,
|
7988
8084
|
extractReasoningMiddleware,
|