@mux/ai 0.5.0 → 0.5.2
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-Dmo55n-5.d.ts → index-2oUwgWsE.d.ts} +3 -1
- package/dist/{index-BdpEVCbj.d.ts → index-DgCfxP4T.d.ts} +11 -9
- package/dist/index.d.ts +5 -5
- package/dist/index.js +42 -29
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +14 -2
- package/dist/primitives/index.js.map +1 -1
- package/dist/{types-KcVfWtUl.d.ts → types-BhVuLeSp.d.ts} +0 -6
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +41 -28
- package/dist/workflows/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -71,12 +71,6 @@ declare function decryptFromWorkflow<T>(payload: EncryptedPayload, key: Uint8Arr
|
|
|
71
71
|
interface MuxAIOptions {
|
|
72
72
|
/** Optional timeout (ms) for helper utilities that support request limits. */
|
|
73
73
|
timeout?: number;
|
|
74
|
-
/**
|
|
75
|
-
* Optional cancellation signal passed through to underlying AI SDK calls.
|
|
76
|
-
* When aborted, in-flight model requests will be
|
|
77
|
-
* cancelled where supported.
|
|
78
|
-
*/
|
|
79
|
-
abortSignal?: AbortSignal;
|
|
80
74
|
/**
|
|
81
75
|
* Optional credentials for workflow execution.
|
|
82
76
|
* Use encryptForWorkflow when running in Workflow Dev Kit environments.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { J as AudioTranslationOptions, I as AudioTranslationResult, e as BurnedInCaptionsAnalysis, c as BurnedInCaptionsOptions, b as BurnedInCaptionsPromptOverrides, a as BurnedInCaptionsPromptSections, B as BurnedInCaptionsResult, C as Chapter, o as ChapterSystemPromptSections, n as ChaptersOptions, m as ChaptersPromptOverrides, l as ChaptersPromptSections, k as ChaptersResult, j as ChaptersType, E as EmbeddingsOptions, q as EmbeddingsResult, u as HiveModerationOutput, H as HiveModerationSource, v as ModerationOptions, t as ModerationProvider, M as ModerationResult, S as SUMMARY_KEYWORD_LIMIT, F as SummarizationOptions, D as SummarizationPromptOverrides, A as SummarizationPromptSections, z as SummaryAndTagsResult, y as SummaryType, T as ThumbnailModerationScore, N as TranslationOptions, P as TranslationPayload, L as TranslationResult, d as burnedInCaptionsSchema, f as chapterSchema, g as chaptersSchema, p as generateChapters, r as generateEmbeddings, s as generateVideoEmbeddings, w as getModerationScores, G as getSummaryAndTags, h as hasBurnedInCaptions, x as summarySchema, K as translateAudio, Q as translateCaptions, O as translationSchema } from '../index-
|
|
1
|
+
export { J as AudioTranslationOptions, I as AudioTranslationResult, e as BurnedInCaptionsAnalysis, c as BurnedInCaptionsOptions, b as BurnedInCaptionsPromptOverrides, a as BurnedInCaptionsPromptSections, B as BurnedInCaptionsResult, C as Chapter, o as ChapterSystemPromptSections, n as ChaptersOptions, m as ChaptersPromptOverrides, l as ChaptersPromptSections, k as ChaptersResult, j as ChaptersType, E as EmbeddingsOptions, q as EmbeddingsResult, u as HiveModerationOutput, H as HiveModerationSource, v as ModerationOptions, t as ModerationProvider, M as ModerationResult, S as SUMMARY_KEYWORD_LIMIT, F as SummarizationOptions, D as SummarizationPromptOverrides, A as SummarizationPromptSections, z as SummaryAndTagsResult, y as SummaryType, T as ThumbnailModerationScore, N as TranslationOptions, P as TranslationPayload, L as TranslationResult, d as burnedInCaptionsSchema, f as chapterSchema, g as chaptersSchema, p as generateChapters, r as generateEmbeddings, s as generateVideoEmbeddings, w as getModerationScores, G as getSummaryAndTags, h as hasBurnedInCaptions, x as summarySchema, K as translateAudio, Q as translateCaptions, O as translationSchema } from '../index-DgCfxP4T.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@ai-sdk/anthropic';
|
|
4
4
|
import '@ai-sdk/google';
|
|
5
5
|
import '@ai-sdk/openai';
|
|
6
|
-
import '../types-
|
|
6
|
+
import '../types-BhVuLeSp.js';
|
|
7
7
|
import '@mux/mux-node';
|
package/dist/workflows/index.js
CHANGED
|
@@ -28018,7 +28018,7 @@ var init_dist10 = __esm({
|
|
|
28018
28018
|
});
|
|
28019
28019
|
|
|
28020
28020
|
// src/workflows/burned-in-captions.ts
|
|
28021
|
-
import {
|
|
28021
|
+
import { generateText, Output } from "ai";
|
|
28022
28022
|
import dedent from "dedent";
|
|
28023
28023
|
import { z as z21 } from "zod";
|
|
28024
28024
|
|
|
@@ -28669,7 +28669,7 @@ async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, sh
|
|
|
28669
28669
|
// src/workflows/burned-in-captions.ts
|
|
28670
28670
|
var burnedInCaptionsSchema = z21.object({
|
|
28671
28671
|
hasBurnedInCaptions: z21.boolean(),
|
|
28672
|
-
confidence: z21.number()
|
|
28672
|
+
confidence: z21.number(),
|
|
28673
28673
|
detectedLanguage: z21.string().nullable()
|
|
28674
28674
|
});
|
|
28675
28675
|
var SYSTEM_PROMPT = dedent`
|
|
@@ -28770,9 +28770,9 @@ async function analyzeStoryboard({
|
|
|
28770
28770
|
}) {
|
|
28771
28771
|
"use step";
|
|
28772
28772
|
const model = await createLanguageModelFromConfig(provider, modelId, credentials);
|
|
28773
|
-
const response = await
|
|
28773
|
+
const response = await generateText({
|
|
28774
28774
|
model,
|
|
28775
|
-
schema: burnedInCaptionsSchema,
|
|
28775
|
+
output: Output.object({ schema: burnedInCaptionsSchema }),
|
|
28776
28776
|
experimental_telemetry: { isEnabled: true },
|
|
28777
28777
|
messages: [
|
|
28778
28778
|
{
|
|
@@ -28789,7 +28789,10 @@ async function analyzeStoryboard({
|
|
|
28789
28789
|
]
|
|
28790
28790
|
});
|
|
28791
28791
|
return {
|
|
28792
|
-
result:
|
|
28792
|
+
result: {
|
|
28793
|
+
...response.output,
|
|
28794
|
+
confidence: Math.min(1, Math.max(0, response.output.confidence))
|
|
28795
|
+
},
|
|
28793
28796
|
usage: {
|
|
28794
28797
|
inputTokens: response.usage.inputTokens,
|
|
28795
28798
|
outputTokens: response.usage.outputTokens,
|
|
@@ -28853,7 +28856,7 @@ async function hasBurnedInCaptions(assetId, options = {}) {
|
|
|
28853
28856
|
}
|
|
28854
28857
|
|
|
28855
28858
|
// src/workflows/chapters.ts
|
|
28856
|
-
import {
|
|
28859
|
+
import { generateText as generateText2, Output as Output2 } from "ai";
|
|
28857
28860
|
import dedent2 from "dedent";
|
|
28858
28861
|
import { z as z22 } from "zod";
|
|
28859
28862
|
|
|
@@ -29082,9 +29085,9 @@ async function generateChaptersWithAI({
|
|
|
29082
29085
|
"use step";
|
|
29083
29086
|
const model = await createLanguageModelFromConfig(provider, modelId, credentials);
|
|
29084
29087
|
const response = await withRetry(
|
|
29085
|
-
() =>
|
|
29088
|
+
() => generateText2({
|
|
29086
29089
|
model,
|
|
29087
|
-
schema: chaptersSchema,
|
|
29090
|
+
output: Output2.object({ schema: chaptersSchema }),
|
|
29088
29091
|
messages: [
|
|
29089
29092
|
{
|
|
29090
29093
|
role: "system",
|
|
@@ -29098,7 +29101,7 @@ async function generateChaptersWithAI({
|
|
|
29098
29101
|
})
|
|
29099
29102
|
);
|
|
29100
29103
|
return {
|
|
29101
|
-
chapters: response.
|
|
29104
|
+
chapters: response.output,
|
|
29102
29105
|
usage: {
|
|
29103
29106
|
inputTokens: response.usage.inputTokens,
|
|
29104
29107
|
outputTokens: response.usage.outputTokens,
|
|
@@ -29532,8 +29535,8 @@ async function generateVideoEmbeddings(assetId, options = {}) {
|
|
|
29532
29535
|
// src/primitives/thumbnails.ts
|
|
29533
29536
|
async function getThumbnailUrls(playbackId, duration, options = {}) {
|
|
29534
29537
|
"use step";
|
|
29535
|
-
const { interval = 10, width = 640, shouldSign = false, credentials } = options;
|
|
29536
|
-
|
|
29538
|
+
const { interval = 10, width = 640, shouldSign = false, maxSamples, credentials } = options;
|
|
29539
|
+
let timestamps = [];
|
|
29537
29540
|
if (duration <= 50) {
|
|
29538
29541
|
const spacing = duration / 6;
|
|
29539
29542
|
for (let i = 1; i <= 5; i++) {
|
|
@@ -29544,6 +29547,18 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
|
|
|
29544
29547
|
timestamps.push(time);
|
|
29545
29548
|
}
|
|
29546
29549
|
}
|
|
29550
|
+
if (maxSamples !== void 0 && timestamps.length > maxSamples) {
|
|
29551
|
+
const newTimestamps = [];
|
|
29552
|
+
newTimestamps.push(0);
|
|
29553
|
+
if (maxSamples >= 2) {
|
|
29554
|
+
const spacing = duration / (maxSamples - 1);
|
|
29555
|
+
for (let i = 1; i < maxSamples - 1; i++) {
|
|
29556
|
+
newTimestamps.push(spacing * i);
|
|
29557
|
+
}
|
|
29558
|
+
newTimestamps.push(duration);
|
|
29559
|
+
}
|
|
29560
|
+
timestamps = newTimestamps;
|
|
29561
|
+
}
|
|
29547
29562
|
const baseUrl = `https://image.mux.com/${playbackId}/thumbnail.png`;
|
|
29548
29563
|
const urlPromises = timestamps.map(async (time) => {
|
|
29549
29564
|
if (shouldSign) {
|
|
@@ -29809,6 +29824,7 @@ async function getModerationScores(assetId, options = {}) {
|
|
|
29809
29824
|
thresholds = DEFAULT_THRESHOLDS,
|
|
29810
29825
|
thumbnailInterval = 10,
|
|
29811
29826
|
thumbnailWidth = 640,
|
|
29827
|
+
maxSamples,
|
|
29812
29828
|
maxConcurrent = 5,
|
|
29813
29829
|
imageSubmissionMode = "url",
|
|
29814
29830
|
imageDownloadOptions,
|
|
@@ -29860,6 +29876,7 @@ async function getModerationScores(assetId, options = {}) {
|
|
|
29860
29876
|
interval: thumbnailInterval,
|
|
29861
29877
|
width: thumbnailWidth,
|
|
29862
29878
|
shouldSign: policy === "signed",
|
|
29879
|
+
maxSamples,
|
|
29863
29880
|
credentials
|
|
29864
29881
|
});
|
|
29865
29882
|
if (provider === "openai") {
|
|
@@ -29901,7 +29918,7 @@ async function getModerationScores(assetId, options = {}) {
|
|
|
29901
29918
|
}
|
|
29902
29919
|
|
|
29903
29920
|
// src/workflows/summarization.ts
|
|
29904
|
-
import {
|
|
29921
|
+
import { generateText as generateText3, Output as Output3 } from "ai";
|
|
29905
29922
|
import dedent3 from "dedent";
|
|
29906
29923
|
import { z as z23 } from "zod";
|
|
29907
29924
|
var SUMMARY_KEYWORD_LIMIT = 10;
|
|
@@ -30131,9 +30148,9 @@ function buildUserPrompt3({
|
|
|
30131
30148
|
async function analyzeStoryboard2(imageDataUrl, provider, modelId, userPrompt, systemPrompt, credentials) {
|
|
30132
30149
|
"use step";
|
|
30133
30150
|
const model = await createLanguageModelFromConfig(provider, modelId, credentials);
|
|
30134
|
-
const response = await
|
|
30151
|
+
const response = await generateText3({
|
|
30135
30152
|
model,
|
|
30136
|
-
schema: summarySchema,
|
|
30153
|
+
output: Output3.object({ schema: summarySchema }),
|
|
30137
30154
|
messages: [
|
|
30138
30155
|
{
|
|
30139
30156
|
role: "system",
|
|
@@ -30149,7 +30166,7 @@ async function analyzeStoryboard2(imageDataUrl, provider, modelId, userPrompt, s
|
|
|
30149
30166
|
]
|
|
30150
30167
|
});
|
|
30151
30168
|
return {
|
|
30152
|
-
result: response.
|
|
30169
|
+
result: response.output,
|
|
30153
30170
|
usage: {
|
|
30154
30171
|
inputTokens: response.usage.inputTokens,
|
|
30155
30172
|
outputTokens: response.usage.outputTokens,
|
|
@@ -30162,9 +30179,9 @@ async function analyzeStoryboard2(imageDataUrl, provider, modelId, userPrompt, s
|
|
|
30162
30179
|
async function analyzeAudioOnly(provider, modelId, userPrompt, systemPrompt, credentials) {
|
|
30163
30180
|
"use step";
|
|
30164
30181
|
const model = await createLanguageModelFromConfig(provider, modelId, credentials);
|
|
30165
|
-
const response = await
|
|
30182
|
+
const response = await generateText3({
|
|
30166
30183
|
model,
|
|
30167
|
-
schema: summarySchema,
|
|
30184
|
+
output: Output3.object({ schema: summarySchema }),
|
|
30168
30185
|
messages: [
|
|
30169
30186
|
{
|
|
30170
30187
|
role: "system",
|
|
@@ -30177,7 +30194,7 @@ async function analyzeAudioOnly(provider, modelId, userPrompt, systemPrompt, cre
|
|
|
30177
30194
|
]
|
|
30178
30195
|
});
|
|
30179
30196
|
return {
|
|
30180
|
-
result: response.
|
|
30197
|
+
result: response.output,
|
|
30181
30198
|
usage: {
|
|
30182
30199
|
inputTokens: response.usage.inputTokens,
|
|
30183
30200
|
outputTokens: response.usage.outputTokens,
|
|
@@ -30220,7 +30237,6 @@ async function getSummaryAndTags(assetId, options) {
|
|
|
30220
30237
|
cleanTranscript = true,
|
|
30221
30238
|
imageSubmissionMode = "url",
|
|
30222
30239
|
imageDownloadOptions,
|
|
30223
|
-
abortSignal: _abortSignal,
|
|
30224
30240
|
promptOverrides,
|
|
30225
30241
|
credentials
|
|
30226
30242
|
} = options ?? {};
|
|
@@ -30881,7 +30897,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
30881
30897
|
|
|
30882
30898
|
// src/workflows/translate-captions.ts
|
|
30883
30899
|
import Mux4 from "@mux/mux-node";
|
|
30884
|
-
import {
|
|
30900
|
+
import { generateText as generateText4, Output as Output4 } from "ai";
|
|
30885
30901
|
import { z as z24 } from "zod";
|
|
30886
30902
|
var translationSchema = z24.object({
|
|
30887
30903
|
translation: z24.string()
|
|
@@ -30900,15 +30916,13 @@ async function translateVttWithAI({
|
|
|
30900
30916
|
toLanguageCode,
|
|
30901
30917
|
provider,
|
|
30902
30918
|
modelId,
|
|
30903
|
-
abortSignal,
|
|
30904
30919
|
credentials
|
|
30905
30920
|
}) {
|
|
30906
30921
|
"use step";
|
|
30907
|
-
const
|
|
30908
|
-
const response = await
|
|
30909
|
-
model
|
|
30910
|
-
schema: translationSchema,
|
|
30911
|
-
abortSignal,
|
|
30922
|
+
const model = await createLanguageModelFromConfig(provider, modelId, credentials);
|
|
30923
|
+
const response = await generateText4({
|
|
30924
|
+
model,
|
|
30925
|
+
output: Output4.object({ schema: translationSchema }),
|
|
30912
30926
|
messages: [
|
|
30913
30927
|
{
|
|
30914
30928
|
role: "user",
|
|
@@ -30919,7 +30933,7 @@ ${vttContent}`
|
|
|
30919
30933
|
]
|
|
30920
30934
|
});
|
|
30921
30935
|
return {
|
|
30922
|
-
translatedVtt: response.
|
|
30936
|
+
translatedVtt: response.output.translation,
|
|
30923
30937
|
usage: {
|
|
30924
30938
|
inputTokens: response.usage.inputTokens,
|
|
30925
30939
|
outputTokens: response.usage.outputTokens,
|
|
@@ -31066,7 +31080,6 @@ async function translateCaptions(assetId, fromLanguageCode, toLanguageCode, opti
|
|
|
31066
31080
|
toLanguageCode,
|
|
31067
31081
|
provider: modelConfig.provider,
|
|
31068
31082
|
modelId: modelConfig.modelId,
|
|
31069
|
-
abortSignal: options.abortSignal,
|
|
31070
31083
|
credentials
|
|
31071
31084
|
});
|
|
31072
31085
|
translatedVtt = result.translatedVtt;
|