-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.ts
48 lines (34 loc) · 1.22 KB
/
index.ts
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
import { main } from './compilers/node/compile';
import fs from 'fs';
import path from 'path';
const heroml = `
Generate a list of {{number_of_colors}} colors
--return-json-array-strings
->>>>
Generate a list of {{number_of_colors}} names, whose last names are respectively: {{step_1}}
->>>>
ACTION: Loop
ManyItems: TRUE
ForEveryItemDoThis: Please write a small intro about this color, tell me about any spiritual meaning it has:
{{step_1}}
`;
async function run() {
const initialValues = {
number_of_colors: 4
};
try {
const finalEnvironment = await main(heroml, initialValues);
console.log(finalEnvironment);
// Create the output directory if it does not exist
const outputDir = path.resolve(__dirname, 'outputs');
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
// Define the output path
const outputPath = path.join(outputDir, 'response.json');
// Write the JSON data to the output file
fs.writeFileSync(outputPath, JSON.stringify(finalEnvironment, null, 2), 'utf8');
} catch (error) {
console.error('Error:', error);
}
}