varg.ai-sdk 0.1.0 → 0.4.0-alpha.1
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/.claude/settings.local.json +1 -1
- package/.env.example +3 -0
- package/.github/workflows/ci.yml +23 -0
- package/.husky/README.md +102 -0
- package/.husky/commit-msg +6 -0
- package/.husky/pre-commit +9 -0
- package/.husky/pre-push +6 -0
- package/.size-limit.json +8 -0
- package/.test-hooks.ts +5 -0
- package/CLAUDE.md +10 -3
- package/CONTRIBUTING.md +150 -0
- package/LICENSE.md +53 -0
- package/README.md +56 -209
- package/SKILLS.md +26 -10
- package/biome.json +7 -1
- package/bun.lock +1286 -0
- package/commitlint.config.js +22 -0
- package/docs/index.html +1130 -0
- package/docs/prompting.md +326 -0
- package/docs/react.md +834 -0
- package/docs/sdk.md +812 -0
- package/ffmpeg/CLAUDE.md +68 -0
- package/package.json +48 -8
- package/pipeline/cookbooks/scripts/animate-frames-parallel.ts +84 -0
- package/pipeline/cookbooks/scripts/combine-scenes.sh +53 -0
- package/pipeline/cookbooks/scripts/generate-frames-parallel.ts +99 -0
- package/pipeline/cookbooks/scripts/still-to-video.sh +37 -0
- package/pipeline/cookbooks/text-to-tiktok.md +669 -0
- package/pipeline/cookbooks/trendwatching.md +156 -0
- package/plan.md +281 -0
- package/scripts/.gitkeep +0 -0
- package/src/ai-sdk/cache.ts +142 -0
- package/src/ai-sdk/examples/cached-generation.ts +53 -0
- package/src/ai-sdk/examples/duet-scene-4.ts +53 -0
- package/src/ai-sdk/examples/duet-scene-5-audio.ts +32 -0
- package/src/ai-sdk/examples/duet-video.ts +56 -0
- package/src/ai-sdk/examples/editly-composition.ts +63 -0
- package/src/ai-sdk/examples/editly-test.ts +57 -0
- package/src/ai-sdk/examples/editly-video-test.ts +52 -0
- package/src/ai-sdk/examples/fal-lipsync.ts +43 -0
- package/src/ai-sdk/examples/higgsfield-image.ts +61 -0
- package/src/ai-sdk/examples/music-generation.ts +19 -0
- package/src/ai-sdk/examples/openai-sora.ts +34 -0
- package/src/ai-sdk/examples/replicate-bg-removal.ts +52 -0
- package/src/ai-sdk/examples/simpsons-scene.ts +61 -0
- package/src/ai-sdk/examples/talking-lion.ts +55 -0
- package/src/ai-sdk/examples/video-generation.ts +39 -0
- package/src/ai-sdk/examples/workflow-animated-girl.ts +104 -0
- package/src/ai-sdk/examples/workflow-before-after.ts +114 -0
- package/src/ai-sdk/examples/workflow-character-grid.ts +112 -0
- package/src/ai-sdk/examples/workflow-slideshow.ts +161 -0
- package/src/ai-sdk/file-cache.ts +112 -0
- package/src/ai-sdk/file.ts +238 -0
- package/src/ai-sdk/generate-element.ts +92 -0
- package/src/ai-sdk/generate-music.ts +46 -0
- package/src/ai-sdk/generate-video.ts +165 -0
- package/src/ai-sdk/index.ts +72 -0
- package/src/ai-sdk/music-model.ts +110 -0
- package/src/ai-sdk/providers/editly/editly.test.ts +1108 -0
- package/src/ai-sdk/providers/editly/ffmpeg.ts +60 -0
- package/src/ai-sdk/providers/editly/index.ts +817 -0
- package/src/ai-sdk/providers/editly/layers.ts +776 -0
- package/src/ai-sdk/providers/editly/plan.md +144 -0
- package/src/ai-sdk/providers/editly/types.ts +328 -0
- package/src/ai-sdk/providers/elevenlabs-provider.ts +255 -0
- package/src/ai-sdk/providers/fal-provider.ts +512 -0
- package/src/ai-sdk/providers/higgsfield.ts +379 -0
- package/src/ai-sdk/providers/openai.ts +251 -0
- package/src/ai-sdk/providers/replicate.ts +16 -0
- package/src/ai-sdk/video-model.ts +185 -0
- package/src/cli/commands/find.tsx +137 -0
- package/src/cli/commands/help.tsx +85 -0
- package/src/cli/commands/index.ts +6 -0
- package/src/cli/commands/list.tsx +238 -0
- package/src/cli/commands/render.tsx +71 -0
- package/src/cli/commands/run.tsx +511 -0
- package/src/cli/commands/which.tsx +253 -0
- package/src/cli/index.ts +114 -0
- package/src/cli/quiet.ts +44 -0
- package/src/cli/types.ts +32 -0
- package/src/cli/ui/components/Badge.tsx +29 -0
- package/src/cli/ui/components/DataTable.tsx +51 -0
- package/src/cli/ui/components/Header.tsx +23 -0
- package/src/cli/ui/components/HelpBlock.tsx +44 -0
- package/src/cli/ui/components/KeyValue.tsx +33 -0
- package/src/cli/ui/components/OptionRow.tsx +81 -0
- package/src/cli/ui/components/Separator.tsx +23 -0
- package/src/cli/ui/components/StatusBox.tsx +108 -0
- package/src/cli/ui/components/VargBox.tsx +51 -0
- package/src/cli/ui/components/VargProgress.tsx +36 -0
- package/src/cli/ui/components/VargSpinner.tsx +34 -0
- package/src/cli/ui/components/VargText.tsx +56 -0
- package/src/cli/ui/components/index.ts +19 -0
- package/src/cli/ui/index.ts +12 -0
- package/src/cli/ui/render.ts +35 -0
- package/src/cli/ui/theme.ts +63 -0
- package/src/cli/utils.ts +78 -0
- package/src/core/executor/executor.ts +201 -0
- package/src/core/executor/index.ts +13 -0
- package/src/core/executor/job.ts +214 -0
- package/src/core/executor/pipeline.ts +222 -0
- package/src/core/index.ts +11 -0
- package/src/core/registry/index.ts +9 -0
- package/src/core/registry/loader.ts +149 -0
- package/src/core/registry/registry.ts +221 -0
- package/src/core/registry/resolver.ts +206 -0
- package/src/core/schema/helpers.ts +134 -0
- package/src/core/schema/index.ts +8 -0
- package/src/core/schema/shared.ts +102 -0
- package/src/core/schema/types.ts +279 -0
- package/src/core/schema/validator.ts +92 -0
- package/src/definitions/actions/captions.ts +261 -0
- package/src/definitions/actions/edit.ts +298 -0
- package/src/definitions/actions/image.ts +125 -0
- package/src/definitions/actions/index.ts +114 -0
- package/src/definitions/actions/music.ts +205 -0
- package/src/definitions/actions/sync.ts +128 -0
- package/{action/transcribe/index.ts → src/definitions/actions/transcribe.ts} +63 -90
- package/src/definitions/actions/upload.ts +111 -0
- package/src/definitions/actions/video.ts +163 -0
- package/src/definitions/actions/voice.ts +119 -0
- package/src/definitions/index.ts +23 -0
- package/src/definitions/models/elevenlabs.ts +50 -0
- package/src/definitions/models/flux.ts +56 -0
- package/src/definitions/models/index.ts +36 -0
- package/src/definitions/models/kling.ts +56 -0
- package/src/definitions/models/llama.ts +54 -0
- package/src/definitions/models/nano-banana-pro.ts +102 -0
- package/src/definitions/models/sonauto.ts +68 -0
- package/src/definitions/models/soul.ts +65 -0
- package/src/definitions/models/wan.ts +54 -0
- package/src/definitions/models/whisper.ts +44 -0
- package/src/definitions/skills/index.ts +12 -0
- package/src/definitions/skills/talking-character.ts +87 -0
- package/src/definitions/skills/text-to-tiktok.ts +97 -0
- package/src/index.ts +118 -0
- package/src/providers/apify.ts +269 -0
- package/src/providers/base.ts +264 -0
- package/src/providers/elevenlabs.ts +217 -0
- package/src/providers/fal.ts +392 -0
- package/src/providers/ffmpeg.ts +544 -0
- package/src/providers/fireworks.ts +193 -0
- package/src/providers/groq.ts +149 -0
- package/src/providers/higgsfield.ts +145 -0
- package/src/providers/index.ts +143 -0
- package/src/providers/replicate.ts +147 -0
- package/src/providers/storage.ts +206 -0
- package/src/react/cli.ts +52 -0
- package/src/react/elements.ts +146 -0
- package/src/react/examples/branching.tsx +66 -0
- package/src/react/examples/captions-demo.tsx +37 -0
- package/src/react/examples/character-video.tsx +84 -0
- package/src/react/examples/grid.tsx +53 -0
- package/src/react/examples/layouts-demo.tsx +57 -0
- package/src/react/examples/madi.tsx +60 -0
- package/src/react/examples/music-test.tsx +35 -0
- package/src/react/examples/onlyfans-1m/workflow.tsx +88 -0
- package/src/react/examples/orange-portrait.tsx +41 -0
- package/src/react/examples/split-element-demo.tsx +60 -0
- package/src/react/examples/split-layout-demo.tsx +60 -0
- package/src/react/examples/split.tsx +41 -0
- package/src/react/examples/video-grid.tsx +46 -0
- package/src/react/index.ts +43 -0
- package/src/react/layouts/grid.tsx +28 -0
- package/src/react/layouts/index.ts +2 -0
- package/src/react/layouts/split.tsx +20 -0
- package/src/react/react.test.ts +309 -0
- package/src/react/render.ts +21 -0
- package/src/react/renderers/animate.ts +59 -0
- package/src/react/renderers/captions.ts +297 -0
- package/src/react/renderers/clip.ts +248 -0
- package/src/react/renderers/context.ts +17 -0
- package/src/react/renderers/image.ts +109 -0
- package/src/react/renderers/index.ts +22 -0
- package/src/react/renderers/music.ts +60 -0
- package/src/react/renderers/packshot.ts +84 -0
- package/src/react/renderers/progress.ts +173 -0
- package/src/react/renderers/render.ts +243 -0
- package/src/react/renderers/slider.ts +69 -0
- package/src/react/renderers/speech.ts +53 -0
- package/src/react/renderers/split.ts +91 -0
- package/src/react/renderers/subtitle.ts +16 -0
- package/src/react/renderers/swipe.ts +75 -0
- package/src/react/renderers/title.ts +17 -0
- package/src/react/renderers/utils.ts +124 -0
- package/src/react/renderers/video.ts +127 -0
- package/src/react/runtime/jsx-dev-runtime.ts +43 -0
- package/src/react/runtime/jsx-runtime.ts +35 -0
- package/src/react/types.ts +232 -0
- package/src/studio/index.ts +26 -0
- package/src/studio/scanner.ts +102 -0
- package/src/studio/server.ts +554 -0
- package/src/studio/stages.ts +251 -0
- package/src/studio/step-renderer.ts +279 -0
- package/src/studio/types.ts +60 -0
- package/src/studio/ui/cache.html +303 -0
- package/src/studio/ui/index.html +1820 -0
- package/src/tests/all.test.ts +509 -0
- package/src/tests/index.ts +33 -0
- package/src/tests/unit.test.ts +403 -0
- package/tsconfig.cli.json +8 -0
- package/tsconfig.json +21 -3
- package/TEST_RESULTS.md +0 -122
- package/action/captions/SKILL.md +0 -170
- package/action/captions/index.ts +0 -227
- package/action/edit/SKILL.md +0 -235
- package/action/edit/index.ts +0 -493
- package/action/image/SKILL.md +0 -140
- package/action/image/index.ts +0 -112
- package/action/sync/SKILL.md +0 -136
- package/action/sync/index.ts +0 -187
- package/action/transcribe/SKILL.md +0 -179
- package/action/video/SKILL.md +0 -116
- package/action/video/index.ts +0 -135
- package/action/voice/SKILL.md +0 -125
- package/action/voice/index.ts +0 -201
- package/index.ts +0 -38
- package/lib/README.md +0 -144
- package/lib/ai-sdk/fal.ts +0 -106
- package/lib/ai-sdk/replicate.ts +0 -107
- package/lib/elevenlabs.ts +0 -382
- package/lib/fal.ts +0 -478
- package/lib/ffmpeg.ts +0 -467
- package/lib/fireworks.ts +0 -235
- package/lib/groq.ts +0 -246
- package/lib/higgsfield.ts +0 -176
- package/lib/remotion/SKILL.md +0 -823
- package/lib/remotion/cli.ts +0 -115
- package/lib/remotion/functions.ts +0 -283
- package/lib/remotion/index.ts +0 -19
- package/lib/remotion/templates.ts +0 -73
- package/lib/replicate.ts +0 -304
- package/output.txt +0 -1
- package/test-import.ts +0 -7
- package/test-services.ts +0 -97
- package/utilities/s3.ts +0 -147
package/lib/replicate.ts
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* replicate.com api wrapper for video/image generation
|
|
5
|
-
* supports models like minimax, kling, luma, stable diffusion
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import Replicate from "replicate";
|
|
9
|
-
|
|
10
|
-
const replicate = new Replicate({
|
|
11
|
-
auth: process.env.REPLICATE_API_TOKEN || "",
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// types
|
|
15
|
-
export interface RunVideoOptions {
|
|
16
|
-
model: string;
|
|
17
|
-
input: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface RunImageOptions {
|
|
21
|
-
model: string;
|
|
22
|
-
input: Record<string, unknown>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// core functions
|
|
26
|
-
export async function runModel(model: string, input: Record<string, unknown>) {
|
|
27
|
-
console.log(`[replicate] running ${model}...`);
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const output = await replicate.run(model as `${string}/${string}`, {
|
|
31
|
-
input,
|
|
32
|
-
});
|
|
33
|
-
console.log(`[replicate] completed`);
|
|
34
|
-
return output;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error(`[replicate] error:`, error);
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function runVideo(options: RunVideoOptions) {
|
|
42
|
-
const { model, input } = options;
|
|
43
|
-
|
|
44
|
-
if (!model || !input) {
|
|
45
|
-
throw new Error("model and input are required");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return await runModel(model, input);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function runImage(options: RunImageOptions) {
|
|
52
|
-
const { model, input } = options;
|
|
53
|
-
|
|
54
|
-
if (!model || !input) {
|
|
55
|
-
throw new Error("model and input are required");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return await runModel(model, input);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// popular models
|
|
62
|
-
export const MODELS = {
|
|
63
|
-
// video generation
|
|
64
|
-
VIDEO: {
|
|
65
|
-
MINIMAX: "minimax/video-01",
|
|
66
|
-
KLING: "fofr/kling-v1.5",
|
|
67
|
-
LUMA: "fofr/ltx-video",
|
|
68
|
-
RUNWAY_GEN3: "replicate/runway-gen3-turbo",
|
|
69
|
-
WAN_2_5: "wan-video/wan-2.5-i2v",
|
|
70
|
-
},
|
|
71
|
-
// image generation
|
|
72
|
-
IMAGE: {
|
|
73
|
-
FLUX_PRO: "black-forest-labs/flux-1.1-pro",
|
|
74
|
-
FLUX_DEV: "black-forest-labs/flux-dev",
|
|
75
|
-
FLUX_SCHNELL: "black-forest-labs/flux-schnell",
|
|
76
|
-
STABLE_DIFFUSION: "stability-ai/sdxl",
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// cli
|
|
81
|
-
async function cli() {
|
|
82
|
-
const args = process.argv.slice(2);
|
|
83
|
-
const command = args[0];
|
|
84
|
-
|
|
85
|
-
if (!command || command === "help") {
|
|
86
|
-
console.log(`
|
|
87
|
-
usage:
|
|
88
|
-
bun run lib/replicate.ts <command> [args]
|
|
89
|
-
|
|
90
|
-
commands:
|
|
91
|
-
video <model> <prompt> [imageUrl] generate video
|
|
92
|
-
image <model> <prompt> generate image
|
|
93
|
-
minimax <prompt> [imageUrl] generate video with minimax-01
|
|
94
|
-
kling <prompt> [imageUrl] generate video with kling-v1.5
|
|
95
|
-
wan <imageUrl> <audioUrl> <prompt> generate talking video with wan 2.5
|
|
96
|
-
flux <prompt> generate image with flux-dev
|
|
97
|
-
list list recent predictions
|
|
98
|
-
get <predictionId> get prediction by id
|
|
99
|
-
help show this help
|
|
100
|
-
|
|
101
|
-
examples:
|
|
102
|
-
bun run lib/replicate.ts minimax "person walking on beach"
|
|
103
|
-
bun run lib/replicate.ts minimax "camera zoom in" https://example.com/img.jpg
|
|
104
|
-
bun run lib/replicate.ts kling "cinematic city scene"
|
|
105
|
-
bun run lib/replicate.ts wan https://image.jpg https://audio.mp3 "person talking to camera"
|
|
106
|
-
bun run lib/replicate.ts flux "cyberpunk cityscape"
|
|
107
|
-
bun run lib/replicate.ts video "minimax/video-01" "dancing robot"
|
|
108
|
-
bun run lib/replicate.ts image "black-forest-labs/flux-dev" "sunset landscape"
|
|
109
|
-
|
|
110
|
-
environment:
|
|
111
|
-
REPLICATE_API_TOKEN - your replicate api token
|
|
112
|
-
`);
|
|
113
|
-
process.exit(0);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
switch (command) {
|
|
118
|
-
case "minimax": {
|
|
119
|
-
const prompt = args[1];
|
|
120
|
-
const imageUrl = args[2];
|
|
121
|
-
|
|
122
|
-
if (!prompt) {
|
|
123
|
-
throw new Error("prompt is required");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const input: Record<string, unknown> = { prompt };
|
|
127
|
-
if (imageUrl) {
|
|
128
|
-
input.first_frame_image = imageUrl;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const output = await runVideo({
|
|
132
|
-
model: MODELS.VIDEO.MINIMAX,
|
|
133
|
-
input,
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
console.log(`[replicate] minimax output:`, output);
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
case "kling": {
|
|
141
|
-
const prompt = args[1];
|
|
142
|
-
const imageUrl = args[2];
|
|
143
|
-
|
|
144
|
-
if (!prompt) {
|
|
145
|
-
throw new Error("prompt is required");
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const input: Record<string, unknown> = { prompt };
|
|
149
|
-
if (imageUrl) {
|
|
150
|
-
input.image = imageUrl;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const output = await runVideo({
|
|
154
|
-
model: MODELS.VIDEO.KLING,
|
|
155
|
-
input,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
console.log(`[replicate] kling output:`, output);
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
case "wan": {
|
|
163
|
-
const imageUrl = args[1];
|
|
164
|
-
const audioUrl = args[2];
|
|
165
|
-
const prompt = args[3];
|
|
166
|
-
const duration = args[4] ? Number.parseInt(args[4], 10) : 10;
|
|
167
|
-
const resolution = args[5] || "480p";
|
|
168
|
-
|
|
169
|
-
if (!imageUrl || !audioUrl || !prompt) {
|
|
170
|
-
throw new Error("imageUrl, audioUrl, and prompt are required");
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const input: Record<string, unknown> = {
|
|
174
|
-
image: imageUrl,
|
|
175
|
-
audio: audioUrl,
|
|
176
|
-
prompt,
|
|
177
|
-
duration,
|
|
178
|
-
resolution,
|
|
179
|
-
enable_prompt_expansion: true,
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
console.log(`[replicate] running wan 2.5...`);
|
|
183
|
-
console.log(`[replicate] this may take 3-5 minutes...`);
|
|
184
|
-
|
|
185
|
-
const output = await runVideo({
|
|
186
|
-
model: MODELS.VIDEO.WAN_2_5,
|
|
187
|
-
input,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
console.log(`[replicate] wan 2.5 output:`, output);
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
case "list": {
|
|
195
|
-
console.log(`[replicate] fetching recent predictions...`);
|
|
196
|
-
const predictions = await replicate.predictions.list();
|
|
197
|
-
|
|
198
|
-
console.log(`\nrecent predictions:\n`);
|
|
199
|
-
for (const pred of predictions.results.slice(0, 10)) {
|
|
200
|
-
console.log(`id: ${pred.id}`);
|
|
201
|
-
console.log(`status: ${pred.status}`);
|
|
202
|
-
console.log(`model: ${pred.version}`);
|
|
203
|
-
console.log(`created: ${pred.created_at}`);
|
|
204
|
-
if (pred.output) {
|
|
205
|
-
console.log(
|
|
206
|
-
`output: ${JSON.stringify(pred.output).substring(0, 100)}...`,
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
console.log(`---`);
|
|
210
|
-
}
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
case "get": {
|
|
215
|
-
const predictionId = args[1];
|
|
216
|
-
|
|
217
|
-
if (!predictionId) {
|
|
218
|
-
throw new Error("predictionId is required");
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
console.log(`[replicate] fetching prediction ${predictionId}...`);
|
|
222
|
-
const prediction = await replicate.predictions.get(predictionId);
|
|
223
|
-
|
|
224
|
-
console.log(`\nstatus: ${prediction.status}`);
|
|
225
|
-
console.log(`model: ${prediction.version}`);
|
|
226
|
-
console.log(`created: ${prediction.created_at}`);
|
|
227
|
-
|
|
228
|
-
if (prediction.status === "succeeded") {
|
|
229
|
-
console.log(`\noutput:`);
|
|
230
|
-
console.log(JSON.stringify(prediction.output, null, 2));
|
|
231
|
-
} else if (prediction.status === "failed") {
|
|
232
|
-
console.log(`\nerror: ${prediction.error}`);
|
|
233
|
-
} else {
|
|
234
|
-
console.log(`\nstill processing...`);
|
|
235
|
-
}
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
case "flux": {
|
|
240
|
-
const prompt = args[1];
|
|
241
|
-
|
|
242
|
-
if (!prompt) {
|
|
243
|
-
throw new Error("prompt is required");
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const output = await runImage({
|
|
247
|
-
model: MODELS.IMAGE.FLUX_DEV,
|
|
248
|
-
input: { prompt },
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
console.log(`[replicate] flux output:`, output);
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
case "video": {
|
|
256
|
-
const model = args[1];
|
|
257
|
-
const prompt = args[2];
|
|
258
|
-
const imageUrl = args[3];
|
|
259
|
-
|
|
260
|
-
if (!model || !prompt) {
|
|
261
|
-
throw new Error("model and prompt are required");
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const input: Record<string, unknown> = { prompt };
|
|
265
|
-
if (imageUrl) {
|
|
266
|
-
input.image = imageUrl;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const output = await runVideo({ model, input });
|
|
270
|
-
console.log(`[replicate] video output:`, output);
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
case "image": {
|
|
275
|
-
const model = args[1];
|
|
276
|
-
const prompt = args[2];
|
|
277
|
-
|
|
278
|
-
if (!model || !prompt) {
|
|
279
|
-
throw new Error("model and prompt are required");
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const output = await runImage({
|
|
283
|
-
model,
|
|
284
|
-
input: { prompt },
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
console.log(`[replicate] image output:`, output);
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
default:
|
|
292
|
-
console.error(`unknown command: ${command}`);
|
|
293
|
-
console.log(`run 'bun run lib/replicate.ts help' for usage`);
|
|
294
|
-
process.exit(1);
|
|
295
|
-
}
|
|
296
|
-
} catch (error) {
|
|
297
|
-
console.error(`[replicate] error:`, error);
|
|
298
|
-
process.exit(1);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (import.meta.main) {
|
|
303
|
-
cli();
|
|
304
|
-
}
|
package/output.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Let's say I've just joined the Roark team as a marketer and I want to add a new article to the website to boost our SEO. The devs won't get to this task anytime soon, but thanks to YoloCode AI, I can take care of it myself. Any changes I make show up instantly on the right so I can see exactly how it looked in production before opening a pull request. So now I'm ready to submit and push this feature and here we go!
|
package/test-import.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { generateImage, imageToVideo, uploadFromUrl } from "./index";
|
|
2
|
-
|
|
3
|
-
console.log("✓ imports successful");
|
|
4
|
-
console.log("available functions:");
|
|
5
|
-
console.log("- generateImage:", typeof generateImage);
|
|
6
|
-
console.log("- imageToVideo:", typeof imageToVideo);
|
|
7
|
-
console.log("- uploadFromUrl:", typeof uploadFromUrl);
|
package/test-services.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* test script for all sdk services
|
|
5
|
-
* saves all media files to media/ directory
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { generateImage as generateFalImage } from "./lib/ai-sdk/fal";
|
|
9
|
-
import { generateImage as generateReplicateImage } from "./lib/ai-sdk/replicate";
|
|
10
|
-
import { textToSpeech } from "./lib/elevenlabs";
|
|
11
|
-
import { runImage } from "./lib/replicate";
|
|
12
|
-
|
|
13
|
-
async function testFalImage() {
|
|
14
|
-
console.log("\n=== testing fal image generation ===");
|
|
15
|
-
|
|
16
|
-
const result = await generateFalImage({
|
|
17
|
-
prompt: "a cozy coffee shop interior with warm lighting",
|
|
18
|
-
model: "fal-ai/flux/dev",
|
|
19
|
-
aspectRatio: "16:9",
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (result.image.uint8Array) {
|
|
23
|
-
const filename = "media/fal-coffee-shop.png";
|
|
24
|
-
await Bun.write(filename, result.image.uint8Array);
|
|
25
|
-
console.log(`✓ saved to ${filename}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function testReplicateImage() {
|
|
30
|
-
console.log("\n=== testing replicate image generation ===");
|
|
31
|
-
|
|
32
|
-
const result = await generateReplicateImage({
|
|
33
|
-
prompt: "a mystical forest with glowing mushrooms",
|
|
34
|
-
model: "black-forest-labs/flux-dev",
|
|
35
|
-
aspectRatio: "1:1",
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
if (result.image.uint8Array) {
|
|
39
|
-
const filename = "media/replicate-forest.png";
|
|
40
|
-
await Bun.write(filename, result.image.uint8Array);
|
|
41
|
-
console.log(`✓ saved to ${filename}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function testReplicateClient() {
|
|
46
|
-
console.log("\n=== testing replicate client (flux) ===");
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const output = await runImage({
|
|
50
|
-
model: "black-forest-labs/flux-schnell",
|
|
51
|
-
input: { prompt: "a serene zen garden with cherry blossoms" },
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// output is array of FileOutput objects
|
|
55
|
-
if (Array.isArray(output) && output[0]) {
|
|
56
|
-
const imageUrl = output[0].toString();
|
|
57
|
-
console.log(`✓ generated image: ${imageUrl}`);
|
|
58
|
-
|
|
59
|
-
// download and save
|
|
60
|
-
const response = await fetch(imageUrl);
|
|
61
|
-
const buffer = await response.arrayBuffer();
|
|
62
|
-
const filename = "media/replicate-zen-garden.png";
|
|
63
|
-
await Bun.write(filename, buffer);
|
|
64
|
-
console.log(`✓ saved to ${filename}`);
|
|
65
|
-
}
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error("✗ replicate client error:", error);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async function testElevenlabs() {
|
|
72
|
-
console.log("\n=== testing elevenlabs tts ===");
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
await textToSpeech({
|
|
76
|
-
text: "welcome to varg ai sdk, your complete video production toolkit",
|
|
77
|
-
voiceId: "21m00Tcm4TlvDq8ikWAM",
|
|
78
|
-
outputPath: "media/welcome.mp3",
|
|
79
|
-
});
|
|
80
|
-
console.log("✓ saved to media/welcome.mp3");
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.error("✗ elevenlabs error:", error);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async function main() {
|
|
87
|
-
console.log("🚀 testing varg.ai sdk services...\n");
|
|
88
|
-
|
|
89
|
-
await testFalImage();
|
|
90
|
-
await testReplicateImage();
|
|
91
|
-
await testReplicateClient();
|
|
92
|
-
await testElevenlabs();
|
|
93
|
-
|
|
94
|
-
console.log("\n✨ all tests complete! check media/ directory");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
main().catch(console.error);
|
package/utilities/s3.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/**
|
|
3
|
-
* cloudflare r2 / s3 storage wrapper
|
|
4
|
-
* usage: bun run utilities/s3.ts <command> <args>
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
GetObjectCommand,
|
|
9
|
-
PutObjectCommand,
|
|
10
|
-
S3Client,
|
|
11
|
-
} from "@aws-sdk/client-s3";
|
|
12
|
-
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
13
|
-
|
|
14
|
-
const client = new S3Client({
|
|
15
|
-
region: "auto",
|
|
16
|
-
endpoint: process.env.CLOUDFLARE_R2_API_URL,
|
|
17
|
-
credentials: {
|
|
18
|
-
accessKeyId: process.env.CLOUDFLARE_ACCESS_KEY_ID || "",
|
|
19
|
-
secretAccessKey: process.env.CLOUDFLARE_ACCESS_SECRET || "",
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const BUCKET = process.env.CLOUDFLARE_R2_BUCKET || "m";
|
|
24
|
-
|
|
25
|
-
export async function uploadFile(
|
|
26
|
-
filePath: string,
|
|
27
|
-
objectKey: string,
|
|
28
|
-
): Promise<string> {
|
|
29
|
-
console.log(`[s3] uploading ${filePath} to ${objectKey}`);
|
|
30
|
-
|
|
31
|
-
const file = Bun.file(filePath);
|
|
32
|
-
const buffer = await file.arrayBuffer();
|
|
33
|
-
|
|
34
|
-
await client.send(
|
|
35
|
-
new PutObjectCommand({
|
|
36
|
-
Bucket: BUCKET,
|
|
37
|
-
Key: objectKey,
|
|
38
|
-
Body: new Uint8Array(buffer),
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
return getPublicUrl(objectKey);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export async function uploadFromUrl(
|
|
46
|
-
url: string,
|
|
47
|
-
objectKey: string,
|
|
48
|
-
): Promise<string> {
|
|
49
|
-
console.log(`[s3] downloading from ${url}`);
|
|
50
|
-
|
|
51
|
-
const response = await fetch(url);
|
|
52
|
-
const buffer = await response.arrayBuffer();
|
|
53
|
-
|
|
54
|
-
console.log(`[s3] uploading to ${objectKey}`);
|
|
55
|
-
|
|
56
|
-
await client.send(
|
|
57
|
-
new PutObjectCommand({
|
|
58
|
-
Bucket: BUCKET,
|
|
59
|
-
Key: objectKey,
|
|
60
|
-
Body: new Uint8Array(buffer),
|
|
61
|
-
}),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return getPublicUrl(objectKey);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function generatePresignedUrl(
|
|
68
|
-
objectKey: string,
|
|
69
|
-
expiresIn = 3600,
|
|
70
|
-
): Promise<string> {
|
|
71
|
-
const command = new GetObjectCommand({
|
|
72
|
-
Bucket: BUCKET,
|
|
73
|
-
Key: objectKey,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return await getSignedUrl(client, command, { expiresIn });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function getPublicUrl(objectKey: string): string {
|
|
80
|
-
const endpoint = process.env.CLOUDFLARE_R2_API_URL || "";
|
|
81
|
-
|
|
82
|
-
if (endpoint.includes("localhost")) {
|
|
83
|
-
return `${endpoint}/${BUCKET}/${objectKey}`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return `http://s3.varg.ai/${BUCKET}/${objectKey}`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// cli runner
|
|
90
|
-
if (import.meta.main) {
|
|
91
|
-
const [command, ...args] = process.argv.slice(2);
|
|
92
|
-
|
|
93
|
-
switch (command) {
|
|
94
|
-
case "upload": {
|
|
95
|
-
if (!args[0] || !args[1]) {
|
|
96
|
-
console.log(`
|
|
97
|
-
usage:
|
|
98
|
-
bun run utilities/s3.ts upload <filePath> <objectKey>
|
|
99
|
-
`);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
const uploadResult = await uploadFile(args[0], args[1]);
|
|
103
|
-
console.log(uploadResult);
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
case "upload_from_url": {
|
|
108
|
-
if (!args[0] || !args[1]) {
|
|
109
|
-
console.log(`
|
|
110
|
-
usage:
|
|
111
|
-
bun run utilities/s3.ts upload_from_url <url> <objectKey>
|
|
112
|
-
`);
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
const urlUploadResult = await uploadFromUrl(args[0], args[1]);
|
|
116
|
-
console.log(urlUploadResult);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
case "presigned_url": {
|
|
121
|
-
if (!args[0]) {
|
|
122
|
-
console.log(`
|
|
123
|
-
usage:
|
|
124
|
-
bun run utilities/s3.ts presigned_url <objectKey> [expiresIn]
|
|
125
|
-
`);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
const expiresIn = args[1] ? Number.parseInt(args[1], 10) : 3600;
|
|
129
|
-
if (Number.isNaN(expiresIn)) {
|
|
130
|
-
console.error("expiresIn must be a valid number");
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
const presignedUrl = await generatePresignedUrl(args[0], expiresIn);
|
|
134
|
-
console.log(presignedUrl);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
default:
|
|
139
|
-
console.log(`
|
|
140
|
-
usage:
|
|
141
|
-
bun run utilities/s3.ts upload <filePath> <objectKey>
|
|
142
|
-
bun run utilities/s3.ts upload_from_url <url> <objectKey>
|
|
143
|
-
bun run utilities/s3.ts presigned_url <objectKey> [expiresIn]
|
|
144
|
-
`);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
}
|