@mux/ai 0.1.2 → 0.1.3
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/LICENSE +10 -18
- package/README.md +493 -171
- package/dist/index-BNnz9P_5.d.mts +144 -0
- package/dist/index-Bnv7tv90.d.ts +477 -0
- package/dist/index-DyTSka2R.d.ts +144 -0
- package/dist/index-vJ5r2FNm.d.mts +477 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +10 -161
- package/dist/index.js +1784 -1304
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2205 -0
- package/dist/index.mjs.map +1 -0
- package/dist/primitives/index.d.mts +3 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +409 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/index.mjs +358 -0
- package/dist/primitives/index.mjs.map +1 -0
- package/dist/types-ktXDZ93V.d.mts +137 -0
- package/dist/types-ktXDZ93V.d.ts +137 -0
- package/dist/workflows/index.d.mts +8 -0
- package/dist/workflows/index.d.ts +8 -0
- package/dist/workflows/index.js +2217 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/index.mjs +2168 -0
- package/dist/workflows/index.mjs.map +1 -0
- package/package.json +103 -30
- package/dist/index.cjs +0 -1773
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -164
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import Mux from '@mux/mux-node';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared credential bag for every workflow. Each property falls back to the
|
|
5
|
+
* corresponding environment variable when omitted.
|
|
6
|
+
*/
|
|
7
|
+
interface MuxAIConfig {
|
|
8
|
+
/** Override for the MUX_TOKEN_ID environment variable. */
|
|
9
|
+
muxTokenId?: string;
|
|
10
|
+
/** Override for the MUX_TOKEN_SECRET environment variable. */
|
|
11
|
+
muxTokenSecret?: string;
|
|
12
|
+
/** Mux signing key ID for signed playback IDs (defaults to the MUX_SIGNING_KEY environment variable). */
|
|
13
|
+
muxSigningKey?: string;
|
|
14
|
+
/** Mux signing key private key for signed playback IDs (defaults to the MUX_PRIVATE_KEY environment variable). */
|
|
15
|
+
muxPrivateKey?: string;
|
|
16
|
+
/** OpenAI API key (defaults to the OPENAI_API_KEY environment variable). */
|
|
17
|
+
openaiApiKey?: string;
|
|
18
|
+
/** Anthropic API key (defaults to the ANTHROPIC_API_KEY environment variable). */
|
|
19
|
+
anthropicApiKey?: string;
|
|
20
|
+
/** Google Generative AI API key (defaults to the GOOGLE_GENERATIVE_AI_API_KEY environment variable). */
|
|
21
|
+
googleApiKey?: string;
|
|
22
|
+
/** Hive Visual Moderation API key (defaults to the HIVE_API_KEY environment variable). */
|
|
23
|
+
hiveApiKey?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Base options mixed into every higher-level workflow configuration.
|
|
27
|
+
*/
|
|
28
|
+
interface MuxAIOptions extends MuxAIConfig {
|
|
29
|
+
/** Optional timeout (ms) for helper utilities that support request limits. */
|
|
30
|
+
timeout?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Optional cancellation signal passed through to underlying AI SDK calls.
|
|
33
|
+
* When aborted, in-flight model requests will be
|
|
34
|
+
* cancelled where supported.
|
|
35
|
+
*/
|
|
36
|
+
abortSignal?: AbortSignal;
|
|
37
|
+
}
|
|
38
|
+
/** Tone controls for the summarization helper. */
|
|
39
|
+
type ToneType = "normal" | "sassy" | "professional";
|
|
40
|
+
/** Common transport for image-based workflows. */
|
|
41
|
+
type ImageSubmissionMode = "url" | "base64";
|
|
42
|
+
/** Result of calling mux-node's asset retrieval helper. */
|
|
43
|
+
type MuxAsset = Awaited<ReturnType<Mux["video"]["assets"]["retrieve"]>>;
|
|
44
|
+
/** Single ready track extracted from a Mux asset. */
|
|
45
|
+
type AssetTextTrack = NonNullable<MuxAsset["tracks"]>[number];
|
|
46
|
+
/** Playback policy type for Mux assets. */
|
|
47
|
+
type PlaybackPolicy = "public" | "signed";
|
|
48
|
+
/** Convenience bundle returned by `getPlaybackIdForAsset`. */
|
|
49
|
+
interface PlaybackAsset {
|
|
50
|
+
asset: MuxAsset;
|
|
51
|
+
playbackId: string;
|
|
52
|
+
/** The policy type of the playback ID ('public' or 'signed'). */
|
|
53
|
+
policy: PlaybackPolicy;
|
|
54
|
+
}
|
|
55
|
+
/** Configuration for token-based chunking. */
|
|
56
|
+
interface TokenChunkingConfig {
|
|
57
|
+
type: "token";
|
|
58
|
+
/** Maximum tokens per chunk. */
|
|
59
|
+
maxTokens: number;
|
|
60
|
+
/** Number of overlapping tokens between chunks. */
|
|
61
|
+
overlap?: number;
|
|
62
|
+
}
|
|
63
|
+
/** Configuration for VTT-aware chunking that respects cue boundaries. */
|
|
64
|
+
interface VTTChunkingConfig {
|
|
65
|
+
type: "vtt";
|
|
66
|
+
/** Maximum tokens per chunk. */
|
|
67
|
+
maxTokens: number;
|
|
68
|
+
/** Number of cues to overlap between chunks (default: 2). */
|
|
69
|
+
overlapCues?: number;
|
|
70
|
+
}
|
|
71
|
+
/** Union type for all chunking strategy configurations. */
|
|
72
|
+
type ChunkingStrategy = TokenChunkingConfig | VTTChunkingConfig;
|
|
73
|
+
/** A single chunk of text extracted from a transcript. */
|
|
74
|
+
interface TextChunk {
|
|
75
|
+
/** Unique identifier for this chunk. */
|
|
76
|
+
id: string;
|
|
77
|
+
/** The text content of the chunk. */
|
|
78
|
+
text: string;
|
|
79
|
+
/** Number of tokens in this chunk. */
|
|
80
|
+
tokenCount: number;
|
|
81
|
+
/** Start time in seconds (if available from timestamped transcript). */
|
|
82
|
+
startTime?: number;
|
|
83
|
+
/** End time in seconds (if available from timestamped transcript). */
|
|
84
|
+
endTime?: number;
|
|
85
|
+
}
|
|
86
|
+
/** A chunk with its embedding vector. */
|
|
87
|
+
interface ChunkEmbedding {
|
|
88
|
+
/** Reference to the chunk ID. */
|
|
89
|
+
chunkId: string;
|
|
90
|
+
/** The embedding vector. */
|
|
91
|
+
embedding: number[];
|
|
92
|
+
/** Optional metadata for this chunk. */
|
|
93
|
+
metadata: {
|
|
94
|
+
startTime?: number;
|
|
95
|
+
endTime?: number;
|
|
96
|
+
tokenCount: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Result of generating embeddings for a video asset. */
|
|
100
|
+
interface VideoEmbeddingsResult {
|
|
101
|
+
/** The Mux asset ID. */
|
|
102
|
+
assetId: string;
|
|
103
|
+
/** Individual chunk embeddings. */
|
|
104
|
+
chunks: ChunkEmbedding[];
|
|
105
|
+
/** Averaged embedding across all chunks. */
|
|
106
|
+
averagedEmbedding: number[];
|
|
107
|
+
/** AI provider used. */
|
|
108
|
+
provider: string;
|
|
109
|
+
/** Model used for embedding generation. */
|
|
110
|
+
model: string;
|
|
111
|
+
/** Additional metadata about the generation. */
|
|
112
|
+
metadata: {
|
|
113
|
+
totalChunks: number;
|
|
114
|
+
totalTokens: number;
|
|
115
|
+
chunkingStrategy: string;
|
|
116
|
+
embeddingDimensions: number;
|
|
117
|
+
generatedAt: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Token usage breakdown returned by AI SDK providers.
|
|
122
|
+
* Used for efficiency and cost analysis.
|
|
123
|
+
*/
|
|
124
|
+
interface TokenUsage {
|
|
125
|
+
/** Number of tokens in the input prompt (text + image). */
|
|
126
|
+
inputTokens?: number;
|
|
127
|
+
/** Number of tokens generated in the output. */
|
|
128
|
+
outputTokens?: number;
|
|
129
|
+
/** Total tokens consumed (input + output). */
|
|
130
|
+
totalTokens?: number;
|
|
131
|
+
/** Tokens used for chain-of-thought reasoning (if applicable). */
|
|
132
|
+
reasoningTokens?: number;
|
|
133
|
+
/** Input tokens served from cache (reduces cost). */
|
|
134
|
+
cachedInputTokens?: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type { AssetTextTrack as A, ChunkingStrategy as C, ImageSubmissionMode as I, MuxAIConfig as M, PlaybackPolicy as P, ToneType as T, VTTChunkingConfig as V, MuxAIOptions as a, MuxAsset as b, PlaybackAsset as c, TokenChunkingConfig as d, TextChunk as e, ChunkEmbedding as f, VideoEmbeddingsResult as g, TokenUsage as h };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { z as AudioTranslationOptions, A as AudioTranslationResult, e as BurnedInCaptionsAnalysis, c as BurnedInCaptionsOptions, b as BurnedInCaptionsPromptOverrides, a as BurnedInCaptionsPromptSections, B as BurnedInCaptionsResult, C as Chapter, l as ChaptersOptions, k as ChaptersResult, j as ChaptersType, E as EmbeddingsOptions, p as HiveModerationOutput, H as HiveModerationSource, q as ModerationOptions, o as ModerationProvider, M as ModerationResult, S as SUMMARY_KEYWORD_LIMIT, x as SummarizationOptions, w as SummarizationPromptOverrides, v as SummarizationPromptSections, u as SummaryAndTagsResult, t as SummaryType, T as ThumbnailModerationScore, G as TranslationOptions, J as TranslationPayload, F as TranslationResult, d as burnedInCaptionsSchema, f as chapterSchema, g as chaptersSchema, m as generateChapters, n as generateVideoEmbeddings, r as getModerationScores, y as getSummaryAndTags, h as hasBurnedInCaptions, s as summarySchema, D as translateAudio, K as translateCaptions, I as translationSchema } from '../index-vJ5r2FNm.mjs';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@ai-sdk/anthropic';
|
|
4
|
+
import '@ai-sdk/google';
|
|
5
|
+
import '@ai-sdk/openai';
|
|
6
|
+
import '../types-ktXDZ93V.mjs';
|
|
7
|
+
import '@mux/mux-node';
|
|
8
|
+
import 'node:buffer';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { z as AudioTranslationOptions, A as AudioTranslationResult, e as BurnedInCaptionsAnalysis, c as BurnedInCaptionsOptions, b as BurnedInCaptionsPromptOverrides, a as BurnedInCaptionsPromptSections, B as BurnedInCaptionsResult, C as Chapter, l as ChaptersOptions, k as ChaptersResult, j as ChaptersType, E as EmbeddingsOptions, p as HiveModerationOutput, H as HiveModerationSource, q as ModerationOptions, o as ModerationProvider, M as ModerationResult, S as SUMMARY_KEYWORD_LIMIT, x as SummarizationOptions, w as SummarizationPromptOverrides, v as SummarizationPromptSections, u as SummaryAndTagsResult, t as SummaryType, T as ThumbnailModerationScore, G as TranslationOptions, J as TranslationPayload, F as TranslationResult, d as burnedInCaptionsSchema, f as chapterSchema, g as chaptersSchema, m as generateChapters, n as generateVideoEmbeddings, r as getModerationScores, y as getSummaryAndTags, h as hasBurnedInCaptions, s as summarySchema, D as translateAudio, K as translateCaptions, I as translationSchema } from '../index-Bnv7tv90.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@ai-sdk/anthropic';
|
|
4
|
+
import '@ai-sdk/google';
|
|
5
|
+
import '@ai-sdk/openai';
|
|
6
|
+
import '../types-ktXDZ93V.js';
|
|
7
|
+
import '@mux/mux-node';
|
|
8
|
+
import 'node:buffer';
|