@mux/ai 0.38.0 → 0.40.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.
@@ -1,4 +1,4 @@
1
- export { A as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, j as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, k as ASK_QUESTIONS_MAX_QUESTION_LENGTH, l as AskQuestionsOptions, m as AskQuestionsResult, n as AskQuestionsType, o as AudioTranslationOptions, p as AudioTranslationResult, q as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, r as BurnedInCaptionsOptions, s as BurnedInCaptionsPromptOverrides, u as BurnedInCaptionsPromptSections, v as BurnedInCaptionsResult, C as CaptionReplacement, w as CensorMode, x as Chapter, y as ChapterSystemPromptSections, z as ChaptersOptions, D as ChaptersPromptOverrides, E as ChaptersPromptSections, F as ChaptersResult, G as ChaptersType, H as DEFAULT_DESCRIPTION_LENGTH, J as DEFAULT_SUMMARY_KEYWORD_LIMIT, K as DEFAULT_TITLE_LENGTH, M as EditCaptionsOptions, N as EditCaptionsResult, O as EmbeddingsOptions, P as EmbeddingsResult, Q as EngagementInsightsOptions, R as EngagementInsightsResult, T as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, U as HIVE_SEXUAL_CATEGORIES, V as HIVE_VIOLENCE_CATEGORIES, W as HiveModerationOutput, X as HiveModerationSource, Y as ModerationOptions, Z as ModerationProvider, _ as ModerationResult, $ as MomentInsight, a0 as OverallInsight, a1 as ProfanityDetectionPayload, a2 as Question, a3 as QuestionAnswer, a4 as QuestionAnswerType, a5 as ReplacementRecord, a6 as SpeakerReplacement, a7 as StaticRenditionCleanupOutcome, a8 as SummarizationOptions, a9 as SummarizationPromptOverrides, aa as SummarizationPromptSections, ab as SummaryAndTagsResult, ac as SummaryType, ad as ThumbnailModerationScore, ae as TranslationChunkingOptions, af as TranslationOptions, ag as TranslationPayload, ah as TranslationResult, ai as aggregateTokenUsage, aj as applyOverrideLists, ak as applyReplacements, al as applySpeakerReplacements, am as askQuestions, an as buildReplacementRegex, ao as burnedInCaptionsSchema, ap as censorVttContent, aq as chapterSchema, ar as chaptersSchema, as as createReplacer, at as editCaptions, au as extractTranscriptSegmentsForHotspots, av as generateChapters, aw as generateEmbeddings, ax as generateEngagementInsights, ay as generateVideoEmbeddings, az as getModerationScores, aA as getSummaryAndTags, aB as hasBurnedInCaptions, aC as mapShotsToHotspots, aD as normalizeTranslatedVtt, aE as profanityDetectionSchema, aF as questionAnswerSchema, aG as shouldSplitChunkTranslationError, aH as summarySchema, aI as transformCueText, aJ as translateAudio, aK as translateCaptions, aL as translationSchema, aM as validateNeverTranslateTerms, aN as verifyNeverTranslateTerms } from '../index-BupL84pY.js';
1
+ export { A as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, j as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, k as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, l as ASK_QUESTIONS_MAX_QUESTION_LENGTH, m as AskQuestionsOptions, n as AskQuestionsResult, o as AskQuestionsType, p as AudioTranslationOptions, q as AudioTranslationResult, r as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, s as BurnedInCaptionsOptions, u as BurnedInCaptionsPromptOverrides, v as BurnedInCaptionsPromptSections, w as BurnedInCaptionsResult, C as CaptionReplacement, x as CensorMode, y as Chapter, z as ChapterSystemPromptSections, D as ChaptersOptions, E as ChaptersPromptOverrides, F as ChaptersPromptSections, G as ChaptersResult, H as ChaptersType, J as DEFAULT_DESCRIPTION_LENGTH, K as DEFAULT_SUMMARY_KEYWORD_LIMIT, M as DEFAULT_TITLE_LENGTH, N as EditCaptionsOptions, O as EditCaptionsResult, P as EmbeddingsOptions, Q as EmbeddingsResult, R as EngagementInsightsOptions, T as EngagementInsightsResult, U as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, V as HIVE_SEXUAL_CATEGORIES, W as HIVE_VIOLENCE_CATEGORIES, X as HiveModerationOutput, Y as HiveModerationSource, Z as ModerationOptions, _ as ModerationProvider, $ as ModerationResult, a0 as MomentInsight, a1 as OverallInsight, a2 as ProfanityDetectionPayload, a3 as Question, a4 as QuestionAnswer, a5 as QuestionAnswerType, a6 as ReplacementRecord, a7 as SpeakerReplacement, a8 as StaticRenditionCleanupOutcome, a9 as SummarizationOptions, aa as SummarizationPromptOverrides, ab as SummarizationPromptSections, ac as SummaryAndTagsResult, ad as SummaryType, ae as ThumbnailModerationScore, af as TranslationChunkingOptions, ag as TranslationOptions, ah as TranslationPayload, ai as TranslationResult, aj as aggregateTokenUsage, ak as applyOverrideLists, al as applyReplacements, am as applySpeakerReplacements, an as askQuestions, ao as buildReplacementRegex, ap as burnedInCaptionsSchema, aq as censorVttContent, ar as chapterSchema, as as chaptersSchema, at as createReplacer, au as editCaptions, av as extractTranscriptSegmentsForHotspots, aw as generateChapters, ax as generateEmbeddings, ay as generateEngagementInsights, az as generateVideoEmbeddings, aA as getModerationScores, aB as getSummaryAndTags, aC as hasBurnedInCaptions, aD as mapShotsToHotspots, aE as normalizeTranslatedVtt, aF as profanityDetectionSchema, aG as questionAnswerSchema, aH as shouldSplitChunkTranslationError, aI as summarySchema, aJ as transformCueText, aK as translateAudio, aL as translateCaptions, aM as translationSchema, aN as validateNeverTranslateTerms, aO as verifyNeverTranslateTerms } from '../index-UhRs9t1h.js';
2
2
  import 'zod';
3
3
  import '@ai-sdk/anthropic';
4
4
  import '@ai-sdk/google';
@@ -41,6 +41,10 @@ var EnvSchema = z.object({
41
41
  "Override for Mux stream base URL (defaults to https://stream.mux.com).",
42
42
  "Mux stream URL override"
43
43
  ),
44
+ MUX_BASE_URL: optionalString(
45
+ "Override for the Mux API base URL (defaults to https://api.mux.com).",
46
+ "Mux API base URL override"
47
+ ),
44
48
  // The canary is substring-matched against every LLM output via
45
49
  // `detectLeakReason` ("canary" reason). A too-short override (e.g. a
46
50
  // 3-letter test value like "mux" or "the") would match legitimate
@@ -2521,6 +2525,7 @@ async function fetchTranscriptForAsset(asset, playbackId, options = {}) {
2521
2525
 
2522
2526
  // src/workflows/ask-questions.ts
2523
2527
  var ASK_QUESTIONS_MAX_QUESTION_LENGTH = 600;
2528
+ var ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL = 50;
2524
2529
  var ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH = 150;
2525
2530
  var ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH = 500;
2526
2531
  var questionAnswerSchema = z3.object({
@@ -2923,11 +2928,8 @@ async function analyzeQuestions({
2923
2928
  maxRetries: 0,
2924
2929
  output: Output.object({ schema: responseSchema }),
2925
2930
  experimental_telemetry: { isEnabled: true },
2931
+ system: systemPrompt,
2926
2932
  messages: [
2927
- {
2928
- role: "system",
2929
- content: systemPrompt
2930
- },
2931
2933
  {
2932
2934
  role: "user",
2933
2935
  content: imageDataUrl ? [
@@ -2983,6 +2985,12 @@ async function askQuestionsInternal(assetId, questions, options, collectedUsage)
2983
2985
  if (!questions || questions.length === 0) {
2984
2986
  throw new MuxAiError("At least one question must be provided.", { type: "validation_error" });
2985
2987
  }
2988
+ if (questions.length > ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL) {
2989
+ throw new MuxAiError(
2990
+ `Too many questions: received ${questions.length}, but at most ${ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL} are allowed per call.`,
2991
+ { type: "validation_error" }
2992
+ );
2993
+ }
2986
2994
  questions.forEach((q, idx) => {
2987
2995
  if (!q.question || typeof q.question !== "string" || !q.question.trim()) {
2988
2996
  throw new MuxAiError(
@@ -3335,11 +3343,8 @@ async function analyzeStoryboard({
3335
3343
  maxRetries: 0,
3336
3344
  output: Output2.object({ schema: burnedInCaptionsSchema }),
3337
3345
  experimental_telemetry: { isEnabled: true },
3346
+ system: systemPrompt,
3338
3347
  messages: [
3339
- {
3340
- role: "system",
3341
- content: systemPrompt
3342
- },
3343
3348
  {
3344
3349
  role: "user",
3345
3350
  content: [
@@ -3484,11 +3489,8 @@ async function generateChaptersWithAI({
3484
3489
  model,
3485
3490
  maxRetries: 0,
3486
3491
  output: Output3.object({ schema: chaptersSchema }),
3492
+ system: systemPrompt,
3487
3493
  messages: [
3488
- {
3489
- role: "system",
3490
- content: systemPrompt
3491
- },
3492
3494
  {
3493
3495
  role: "user",
3494
3496
  content: userPrompt
@@ -4260,11 +4262,8 @@ async function identifyProfanityWithAI({
4260
4262
  model,
4261
4263
  maxRetries: 0,
4262
4264
  output: Output4.object({ schema: profanityDetectionSchema }),
4265
+ system: SYSTEM_PROMPT3,
4263
4266
  messages: [
4264
- {
4265
- role: "system",
4266
- content: SYSTEM_PROMPT3
4267
- },
4268
4267
  {
4269
4268
  role: "user",
4270
4269
  content: `Identify all profane words and phrases in the following subtitle transcript. Return each unique profane word or phrase exactly as it appears in the text.
@@ -5379,11 +5378,8 @@ async function generateInsightsWithAI(provider, modelId, systemPrompt, userPromp
5379
5378
  maxRetries: 0,
5380
5379
  output: Output5.object({ schema: engagementInsightsSchema }),
5381
5380
  experimental_telemetry: { isEnabled: true },
5381
+ system: systemPrompt,
5382
5382
  messages: [
5383
- {
5384
- role: "system",
5385
- content: systemPrompt
5386
- },
5387
5383
  {
5388
5384
  role: "user",
5389
5385
  content: [
@@ -6686,11 +6682,8 @@ async function analyzeStoryboard2(imageDataUrl, provider, modelId, userPrompt, s
6686
6682
  description: "Structured summary with title, description, and keywords.",
6687
6683
  schema
6688
6684
  }),
6685
+ system: systemPrompt,
6689
6686
  messages: [
6690
- {
6691
- role: "system",
6692
- content: systemPrompt
6693
- },
6694
6687
  {
6695
6688
  role: "user",
6696
6689
  content: [
@@ -6734,11 +6727,8 @@ async function analyzeAudioOnly(provider, modelId, userPrompt, systemPrompt, des
6734
6727
  description: "Structured summary with title, description, and keywords.",
6735
6728
  schema
6736
6729
  }),
6730
+ system: systemPrompt,
6737
6731
  messages: [
6738
- {
6739
- role: "system",
6740
- content: systemPrompt
6741
- },
6742
6732
  {
6743
6733
  role: "user",
6744
6734
  content: userPrompt
@@ -7802,11 +7792,8 @@ async function translateVttWithAI({
7802
7792
  model,
7803
7793
  maxRetries: 0,
7804
7794
  output: Output7.object({ schema: translationSchema }),
7795
+ system: SYSTEM_PROMPT6,
7805
7796
  messages: [
7806
- {
7807
- role: "system",
7808
- content: SYSTEM_PROMPT6
7809
- },
7810
7797
  {
7811
7798
  role: "user",
7812
7799
  content: `Translate from ${fromLanguageCode} to ${toLanguageCode}:${buildNeverTranslateSection(neverTranslate)}
@@ -7870,11 +7857,8 @@ async function translateCueChunkWithAI({
7870
7857
  model,
7871
7858
  maxRetries: 0,
7872
7859
  output: Output7.object({ schema }),
7860
+ system: CUE_TRANSLATION_SYSTEM_PROMPT,
7873
7861
  messages: [
7874
- {
7875
- role: "system",
7876
- content: CUE_TRANSLATION_SYSTEM_PROMPT
7877
- },
7878
7862
  {
7879
7863
  role: "user",
7880
7864
  content: `Translate from ${fromLanguageCode} to ${toLanguageCode}.
@@ -8289,6 +8273,7 @@ async function translateCaptionsInternal(assetId, trackId, toLanguageCode, optio
8289
8273
  export {
8290
8274
  ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH,
8291
8275
  ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH,
8276
+ ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL,
8292
8277
  ASK_QUESTIONS_MAX_QUESTION_LENGTH,
8293
8278
  DEFAULT_DESCRIPTION_LENGTH,
8294
8279
  DEFAULT_SUMMARY_KEYWORD_LIMIT,