@mux/ai 0.23.0 → 0.25.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-ePt2EMpB.d.ts → index-C5zhbQHK.d.ts} +8 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +73 -11
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.js +16 -4
- package/dist/primitives/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +72 -10
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AskQuestionsOptions, j as AskQuestionsResult, k as AskQuestionsType, l as AudioTranslationOptions, m as AudioTranslationResult, n as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, o as BurnedInCaptionsOptions, p as BurnedInCaptionsPromptOverrides, q as BurnedInCaptionsPromptSections, r as BurnedInCaptionsResult, C as CaptionReplacement, s as CensorMode, u as Chapter, v as ChapterSystemPromptSections, w as ChaptersOptions, x as ChaptersPromptOverrides, y as ChaptersPromptSections, z as ChaptersResult, D as ChaptersType, E as DEFAULT_DESCRIPTION_LENGTH, F as DEFAULT_SUMMARY_KEYWORD_LIMIT, G as DEFAULT_TITLE_LENGTH, H as EditCaptionsOptions, J as EditCaptionsResult, K as EmbeddingsOptions, M as EmbeddingsResult, N as EngagementInsightsOptions, O as EngagementInsightsResult, P as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, Q as HIVE_SEXUAL_CATEGORIES, R as HIVE_VIOLENCE_CATEGORIES, T as HiveModerationOutput, U as HiveModerationSource, V as ModerationOptions, W as ModerationProvider, X as ModerationResult, Y as MomentInsight, Z as OverallInsight, _ as ProfanityDetectionPayload, $ as Question, a0 as QuestionAnswer, a1 as QuestionAnswerType, a2 as ReplacementRecord, a3 as SummarizationOptions, a4 as SummarizationPromptOverrides, a5 as SummarizationPromptSections, a6 as SummaryAndTagsResult, a7 as SummaryType, a8 as ThumbnailModerationScore, a9 as TranslationChunkingOptions, aa as TranslationOptions, ab as TranslationPayload, ac as TranslationResult, ad as aggregateTokenUsage, ae as applyOverrideLists, af as applyReplacements, ag as askQuestions, ah as buildReplacementRegex, ai as burnedInCaptionsSchema, aj as censorVttContent, ak as chapterSchema, al as chaptersSchema, am as createReplacer, an as editCaptions, ao as extractTranscriptSegmentsForHotspots, ap as generateChapters, aq as generateEmbeddings, ar as generateEngagementInsights, as as generateVideoEmbeddings, at as getModerationScores, au as getSummaryAndTags, av as hasBurnedInCaptions, aw as mapShotsToHotspots, ax as normalizeTranslatedVtt, ay as profanityDetectionSchema, az as questionAnswerSchema, aA as shouldSplitChunkTranslationError, aB as summarySchema, aC as transformCueText, aD as translateAudio, aE as translateCaptions, aF as translationSchema } from '../index-
|
|
1
|
+
export { A as AskQuestionsOptions, j as AskQuestionsResult, k as AskQuestionsType, l as AudioTranslationOptions, m as AudioTranslationResult, n as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, o as BurnedInCaptionsOptions, p as BurnedInCaptionsPromptOverrides, q as BurnedInCaptionsPromptSections, r as BurnedInCaptionsResult, C as CaptionReplacement, s as CensorMode, u as Chapter, v as ChapterSystemPromptSections, w as ChaptersOptions, x as ChaptersPromptOverrides, y as ChaptersPromptSections, z as ChaptersResult, D as ChaptersType, E as DEFAULT_DESCRIPTION_LENGTH, F as DEFAULT_SUMMARY_KEYWORD_LIMIT, G as DEFAULT_TITLE_LENGTH, H as EditCaptionsOptions, J as EditCaptionsResult, K as EmbeddingsOptions, M as EmbeddingsResult, N as EngagementInsightsOptions, O as EngagementInsightsResult, P as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, Q as HIVE_SEXUAL_CATEGORIES, R as HIVE_VIOLENCE_CATEGORIES, T as HiveModerationOutput, U as HiveModerationSource, V as ModerationOptions, W as ModerationProvider, X as ModerationResult, Y as MomentInsight, Z as OverallInsight, _ as ProfanityDetectionPayload, $ as Question, a0 as QuestionAnswer, a1 as QuestionAnswerType, a2 as ReplacementRecord, a3 as SummarizationOptions, a4 as SummarizationPromptOverrides, a5 as SummarizationPromptSections, a6 as SummaryAndTagsResult, a7 as SummaryType, a8 as ThumbnailModerationScore, a9 as TranslationChunkingOptions, aa as TranslationOptions, ab as TranslationPayload, ac as TranslationResult, ad as aggregateTokenUsage, ae as applyOverrideLists, af as applyReplacements, ag as askQuestions, ah as buildReplacementRegex, ai as burnedInCaptionsSchema, aj as censorVttContent, ak as chapterSchema, al as chaptersSchema, am as createReplacer, an as editCaptions, ao as extractTranscriptSegmentsForHotspots, ap as generateChapters, aq as generateEmbeddings, ar as generateEngagementInsights, as as generateVideoEmbeddings, at as getModerationScores, au as getSummaryAndTags, av as hasBurnedInCaptions, aw as mapShotsToHotspots, ax as normalizeTranslatedVtt, ay as profanityDetectionSchema, az as questionAnswerSchema, aA as shouldSplitChunkTranslationError, aB as summarySchema, aC as transformCueText, aD as translateAudio, aE as translateCaptions, aF as translationSchema } from '../index-C5zhbQHK.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@ai-sdk/anthropic';
|
|
4
4
|
import '@ai-sdk/google';
|
package/dist/workflows/index.js
CHANGED
|
@@ -1508,7 +1508,8 @@ function getReliableLanguageCode(track, confidenceThreshold = LOW_CONFIDENCE_THR
|
|
|
1508
1508
|
return void 0;
|
|
1509
1509
|
if (isUndeterminedLanguageCode(track.language_code))
|
|
1510
1510
|
return void 0;
|
|
1511
|
-
|
|
1511
|
+
const { auto_language_confidence: autoLanguageConfidence } = track;
|
|
1512
|
+
if (autoLanguageConfidence !== void 0 && autoLanguageConfidence < confidenceThreshold) {
|
|
1512
1513
|
return void 0;
|
|
1513
1514
|
}
|
|
1514
1515
|
return track.language_code;
|
|
@@ -3396,12 +3397,64 @@ function transformCueText(rawVtt, transform) {
|
|
|
3396
3397
|
});
|
|
3397
3398
|
return transformed.join("\n");
|
|
3398
3399
|
}
|
|
3400
|
+
function transformCueTextBlocks(rawVtt, transform) {
|
|
3401
|
+
const lines = rawVtt.split("\n");
|
|
3402
|
+
const transformed = [];
|
|
3403
|
+
let cueTextLines;
|
|
3404
|
+
let currentCueStartTime = 0;
|
|
3405
|
+
const flushCueText = () => {
|
|
3406
|
+
if (!cueTextLines)
|
|
3407
|
+
return;
|
|
3408
|
+
if (cueTextLines.length > 0) {
|
|
3409
|
+
transformed.push(...transform(cueTextLines.join("\n"), currentCueStartTime).split("\n"));
|
|
3410
|
+
}
|
|
3411
|
+
cueTextLines = void 0;
|
|
3412
|
+
};
|
|
3413
|
+
for (const line of lines) {
|
|
3414
|
+
if (line.includes("-->")) {
|
|
3415
|
+
flushCueText();
|
|
3416
|
+
const startTimestamp = line.split("-->")[0].trim();
|
|
3417
|
+
currentCueStartTime = vttTimestampToSeconds(startTimestamp);
|
|
3418
|
+
transformed.push(line);
|
|
3419
|
+
cueTextLines = [];
|
|
3420
|
+
continue;
|
|
3421
|
+
}
|
|
3422
|
+
if (cueTextLines) {
|
|
3423
|
+
if (line.trim() === "") {
|
|
3424
|
+
flushCueText();
|
|
3425
|
+
transformed.push(line);
|
|
3426
|
+
} else {
|
|
3427
|
+
cueTextLines.push(line);
|
|
3428
|
+
}
|
|
3429
|
+
continue;
|
|
3430
|
+
}
|
|
3431
|
+
transformed.push(line);
|
|
3432
|
+
}
|
|
3433
|
+
flushCueText();
|
|
3434
|
+
return transformed.join("\n");
|
|
3435
|
+
}
|
|
3436
|
+
function escapeRegex(text) {
|
|
3437
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3438
|
+
}
|
|
3439
|
+
function buildStaticReplacementRegex(find, caseSensitive) {
|
|
3440
|
+
const pattern = find.split(/(\s+)/).map((part) => /\s+/.test(part) ? "\\s+" : escapeRegex(part)).join("");
|
|
3441
|
+
const firstNonWhitespaceIndex = find.search(/\S/);
|
|
3442
|
+
const firstNonWhitespace = firstNonWhitespaceIndex >= 0 ? find[firstNonWhitespaceIndex] : void 0;
|
|
3443
|
+
const lastNonWhitespaceMatch = /\S(?=\s*$)/.exec(find);
|
|
3444
|
+
const lastNonWhitespace = lastNonWhitespaceMatch?.[0];
|
|
3445
|
+
const startsAtTextBoundary = firstNonWhitespaceIndex === 0 && !!firstNonWhitespace && /\w/.test(firstNonWhitespace);
|
|
3446
|
+
const endsAtTextBoundary = !!lastNonWhitespace && find.trimEnd().length === find.length && /\w/.test(lastNonWhitespace);
|
|
3447
|
+
const prefix = startsAtTextBoundary ? "(?<!\\w)" : "";
|
|
3448
|
+
const suffix = endsAtTextBoundary ? "(?!\\w)" : "";
|
|
3449
|
+
const flags = caseSensitive === false ? "gi" : "g";
|
|
3450
|
+
return new RegExp(`${prefix}${pattern}${suffix}`, flags);
|
|
3451
|
+
}
|
|
3399
3452
|
function buildReplacementRegex(words) {
|
|
3400
3453
|
const filtered = words.filter((w) => w.length > 0);
|
|
3401
3454
|
if (filtered.length === 0)
|
|
3402
3455
|
return null;
|
|
3403
3456
|
filtered.sort((a, b) => b.length - a.length);
|
|
3404
|
-
const escaped = filtered.map(
|
|
3457
|
+
const escaped = filtered.map(escapeRegex);
|
|
3405
3458
|
const pattern = escaped.join("|");
|
|
3406
3459
|
return new RegExp(`\\b(?:${pattern})\\b`, "gi");
|
|
3407
3460
|
}
|
|
@@ -3453,12 +3506,10 @@ function applyReplacements(rawVtt, replacements) {
|
|
|
3453
3506
|
return { editedVtt: rawVtt, replacements: [] };
|
|
3454
3507
|
}
|
|
3455
3508
|
const records = [];
|
|
3456
|
-
const editedVtt =
|
|
3457
|
-
let result =
|
|
3509
|
+
const editedVtt = transformCueTextBlocks(rawVtt, (cueText, cueStartTime) => {
|
|
3510
|
+
let result = cueText;
|
|
3458
3511
|
for (const { find, replace, caseSensitive } of filtered) {
|
|
3459
|
-
const
|
|
3460
|
-
const flags = caseSensitive === false ? "gi" : "g";
|
|
3461
|
-
const regex = new RegExp(`\\b${escaped}\\b`, flags);
|
|
3512
|
+
const regex = buildStaticReplacementRegex(find, caseSensitive);
|
|
3462
3513
|
result = result.replace(regex, (match) => {
|
|
3463
3514
|
records.push({ cueStartTime, before: match, after: replace });
|
|
3464
3515
|
return replace;
|
|
@@ -4177,19 +4228,30 @@ function getShotsPath(assetId) {
|
|
|
4177
4228
|
return `/video/v1/assets/${assetId}/shots`;
|
|
4178
4229
|
}
|
|
4179
4230
|
function mapManifestShots(shots) {
|
|
4180
|
-
|
|
4181
|
-
|
|
4231
|
+
let usedDeprecatedField = false;
|
|
4232
|
+
const mapped = shots.map((shot, index) => {
|
|
4233
|
+
const { start_time: startTime } = shot;
|
|
4234
|
+
const imageUrl = shot.shot_preview_image_url ?? shot.image_url;
|
|
4235
|
+
if (shot.shot_preview_image_url === void 0 && shot.image_url !== void 0) {
|
|
4236
|
+
usedDeprecatedField = true;
|
|
4237
|
+
}
|
|
4182
4238
|
if (typeof startTime !== "number" || !Number.isFinite(startTime)) {
|
|
4183
4239
|
throw new TypeError(`Invalid shot start_time in shots manifest at index ${index}`);
|
|
4184
4240
|
}
|
|
4185
4241
|
if (typeof imageUrl !== "string" || imageUrl.length === 0) {
|
|
4186
|
-
throw new TypeError(`Invalid shot
|
|
4242
|
+
throw new TypeError(`Invalid shot shot_preview_image_url in shots manifest at index ${index}`);
|
|
4187
4243
|
}
|
|
4188
4244
|
return {
|
|
4189
4245
|
startTime,
|
|
4190
4246
|
imageUrl
|
|
4191
4247
|
};
|
|
4192
4248
|
});
|
|
4249
|
+
if (usedDeprecatedField) {
|
|
4250
|
+
console.warn(
|
|
4251
|
+
"The 'image_url' field in the Mux shots manifest is deprecated and will be removed. Use 'shot_preview_image_url' instead."
|
|
4252
|
+
);
|
|
4253
|
+
}
|
|
4254
|
+
return mapped;
|
|
4193
4255
|
}
|
|
4194
4256
|
async function fetchShotsFromManifest(shotsManifestUrl) {
|
|
4195
4257
|
const response = await fetch(shotsManifestUrl);
|