-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.mjs
More file actions
62 lines (55 loc) · 1.73 KB
/
example.mjs
File metadata and controls
62 lines (55 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import fs from 'node:fs';
import process from 'node:process';
import repl from 'node:repl';
import {
Weaver,
WebContentAsMarkdown,
StandardWriter,
StandardDirectorV2,
StandardChoreographer,
StandardAssets,
BrowserAssetGenerator,
BingImageSearchAssetGenerator,
AzureSpeech,
BackgroundCropper,
} from './dist/src/index.js';
// eslint-disable-next-line
global.readStory = () => {
const json = fs.readFileSync('./try.json');
return JSON.parse(json);
};
global.saveStory = weaver => {
fs.writeFileSync('./try.json', JSON.stringify(weaver.story, null, 2));
// eslint-disable-next-line
console.log('saved');
};
global.weaver = new Weaver({
openaiApiKey: process.env.OPENAI_API_KEY,
supabaseUrl: 'http://localhost:54321',
supabaseServiceRoleKey:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU',
storageBucket: 'assets',
storagePrefix: 'testuser',
story: global.readStory(),
});
global.content = new WebContentAsMarkdown('https://news.ycombinator.com', new StandardWriter(), {
executablePath: '/opt/homebrew/bin/chromium',
});
global.director = new StandardDirectorV2();
global.choreographer = new StandardChoreographer();
global.assets = new StandardAssets(
{
image: new BackgroundCropper(
process.env.REPLICATE_API_KEY,
new BingImageSearchAssetGenerator(process.env.BING_IMAGE_SEARCH_KEY)
),
screenshot: new BrowserAssetGenerator({ executablePath: '/opt/homebrew/bin/chromium' }),
},
true
);
global.speech = new AzureSpeech(process.env.AZURE_SPEECH_KEY);
const local = repl.start({ useGlobal: true });
local.on('exit', () => {
// eslint-disable-next-line
process.exit();
});