@mux/ai 0.34.0 → 0.35.0
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/dist/{index-B5l0yXZD.d.ts → index-fU3hmKZu.d.ts} +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +39 -6
- package/dist/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +38 -5
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1416,7 +1416,10 @@ interface TranslationOptions<P extends SupportedProvider = SupportedProvider> ex
|
|
|
1416
1416
|
interface TranslationChunkingOptions {
|
|
1417
1417
|
/** Set to false to translate all cues in a single structured request. Defaults to true. */
|
|
1418
1418
|
enabled?: boolean;
|
|
1419
|
-
/**
|
|
1419
|
+
/**
|
|
1420
|
+
* Skip duration-based chunking until the asset is at least this long. Defaults to 30 minutes.
|
|
1421
|
+
* Shorter assets are still split by `maxCuesPerChunk` and `maxCueTextTokensPerChunk`.
|
|
1422
|
+
*/
|
|
1420
1423
|
minimumAssetDurationSeconds?: number;
|
|
1421
1424
|
/** Soft target for chunk duration once chunking starts. Defaults to 30 minutes. */
|
|
1422
1425
|
targetChunkDurationSeconds?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-
|
|
1
|
+
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-fU3hmKZu.js';
|
|
2
2
|
import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-BMbViFbZ.js';
|
|
3
3
|
export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, M as MuxAIOptions, d as MuxAsset, P as PlaybackAsset, e as PlaybackPolicy, f as ScopedMuxAIOptions, g as StorageAdapter, T as TextChunk, h as TokenChunkingConfig, i as TokenUsage, j as ToneType, U as UsageMetadata, V as VTTChunkingConfig, k as VideoEmbeddingsResult, l as WorkflowCredentialsInput, m as WorkflowMuxClient, n as WorkflowScope, o as decryptFromWorkflow, p as encryptForWorkflow } from './shots-BMbViFbZ.js';
|
|
4
4
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
@@ -9,7 +9,7 @@ import '@ai-sdk/google';
|
|
|
9
9
|
import '@ai-sdk/openai';
|
|
10
10
|
import '@mux/mux-node';
|
|
11
11
|
|
|
12
|
-
var version = "0.
|
|
12
|
+
var version = "0.35.0";
|
|
13
13
|
|
|
14
14
|
type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error" | "content_policy_error";
|
|
15
15
|
/**
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.35.0";
|
|
9
9
|
|
|
10
10
|
// src/lib/language-codes.ts
|
|
11
11
|
var ISO639_1_TO_3 = {
|
|
@@ -3157,6 +3157,22 @@ var CONTENT_POLICY_REASONS = /* @__PURE__ */ new Set([
|
|
|
3157
3157
|
"SAFETY",
|
|
3158
3158
|
"SPII"
|
|
3159
3159
|
]);
|
|
3160
|
+
var IncompleteGenerationError = class extends MuxAiError {
|
|
3161
|
+
constructor(finishReason, rawFinishReason, usage) {
|
|
3162
|
+
const reason = rawFinishReason ?? finishReason;
|
|
3163
|
+
const message = finishReason === "length" ? `The model reached its output limit before producing a complete response (finish reason: ${reason}).` : `The model stopped before producing a complete response (finish reason: ${reason}).`;
|
|
3164
|
+
super(message, {
|
|
3165
|
+
type: "processing_error",
|
|
3166
|
+
retryable: finishReason !== "length"
|
|
3167
|
+
});
|
|
3168
|
+
this.finishReason = finishReason;
|
|
3169
|
+
this.rawFinishReason = rawFinishReason;
|
|
3170
|
+
this.usage = usage;
|
|
3171
|
+
}
|
|
3172
|
+
};
|
|
3173
|
+
function isIncompleteGenerationError(error) {
|
|
3174
|
+
return MuxAiError.is(error) && typeof error.finishReason === "string";
|
|
3175
|
+
}
|
|
3160
3176
|
async function withContentPolicyErrorHandling(operation) {
|
|
3161
3177
|
try {
|
|
3162
3178
|
return await operation();
|
|
@@ -3183,6 +3199,14 @@ function getGeneratedOutputWithContentPolicyHandling(response) {
|
|
|
3183
3199
|
const reason = rawReason.success && isContentPolicyReason(rawReason.data) ? rawReason.data : "CONTENT_FILTER";
|
|
3184
3200
|
throwContentPolicyError({ reason }, getErrorTokenUsage(response));
|
|
3185
3201
|
}
|
|
3202
|
+
if (response.finishReason !== "stop") {
|
|
3203
|
+
const rawReason = PolicyTokenSchema.safeParse(response.rawFinishReason);
|
|
3204
|
+
throw new IncompleteGenerationError(
|
|
3205
|
+
response.finishReason,
|
|
3206
|
+
rawReason.success ? rawReason.data : void 0,
|
|
3207
|
+
getErrorTokenUsage(response)
|
|
3208
|
+
);
|
|
3209
|
+
}
|
|
3186
3210
|
return response.output;
|
|
3187
3211
|
}
|
|
3188
3212
|
function throwContentPolicyError(block, usage) {
|
|
@@ -7709,6 +7733,7 @@ import {
|
|
|
7709
7733
|
APICallError as APICallError3,
|
|
7710
7734
|
generateText as generateText7,
|
|
7711
7735
|
NoObjectGeneratedError as NoObjectGeneratedError2,
|
|
7736
|
+
NoOutputGeneratedError as NoOutputGeneratedError2,
|
|
7712
7737
|
Output as Output7,
|
|
7713
7738
|
RetryError as RetryError2,
|
|
7714
7739
|
TypeValidationError
|
|
@@ -7872,7 +7897,7 @@ function shouldSplitChunkTranslationError(error) {
|
|
|
7872
7897
|
if (isProviderServiceError(error)) {
|
|
7873
7898
|
return false;
|
|
7874
7899
|
}
|
|
7875
|
-
return NoObjectGeneratedError2.isInstance(error) || TypeValidationError.isInstance(error) || isTranslationChunkValidationError(error);
|
|
7900
|
+
return NoObjectGeneratedError2.isInstance(error) || NoOutputGeneratedError2.isInstance(error) || TypeValidationError.isInstance(error) || isIncompleteGenerationError(error) || isTranslationChunkValidationError(error);
|
|
7876
7901
|
}
|
|
7877
7902
|
function resolveTranslationChunkingOptions(options) {
|
|
7878
7903
|
const targetChunkDurationSeconds = Math.max(
|
|
@@ -7969,9 +7994,13 @@ function buildTranslationChunkRequests(vttContent, assetDurationSeconds, chunkin
|
|
|
7969
7994
|
if (typeof assetDurationSeconds !== "number" || assetDurationSeconds < resolvedChunking.minimumAssetDurationSeconds) {
|
|
7970
7995
|
return {
|
|
7971
7996
|
preamble,
|
|
7972
|
-
chunks:
|
|
7973
|
-
|
|
7974
|
-
|
|
7997
|
+
chunks: splitTranslationChunkRequestByBudget(
|
|
7998
|
+
"chunk-0",
|
|
7999
|
+
cues,
|
|
8000
|
+
cueBlocks,
|
|
8001
|
+
resolvedChunking.maxCuesPerChunk,
|
|
8002
|
+
resolvedChunking.maxCueTextTokensPerChunk
|
|
8003
|
+
)
|
|
7975
8004
|
};
|
|
7976
8005
|
}
|
|
7977
8006
|
const targetChunkDurationSeconds = resolvedChunking.targetChunkDurationSeconds;
|
|
@@ -8232,7 +8261,11 @@ async function translateChunkWithFallback({
|
|
|
8232
8261
|
);
|
|
8233
8262
|
return {
|
|
8234
8263
|
translatedVtt: concatenateVttSegments([leftResult.translatedVtt, rightResult.translatedVtt]),
|
|
8235
|
-
usage: aggregateTokenUsage([
|
|
8264
|
+
usage: aggregateTokenUsage([
|
|
8265
|
+
...failedAttemptUsage ? [failedAttemptUsage] : [],
|
|
8266
|
+
leftResult.usage,
|
|
8267
|
+
rightResult.usage
|
|
8268
|
+
]),
|
|
8236
8269
|
scrubbedCueCounts: mergeScrubbedCueCounts(
|
|
8237
8270
|
leftResult.scrubbedCueCounts,
|
|
8238
8271
|
rightResult.scrubbedCueCounts
|