-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathindex.ts
More file actions
45 lines (37 loc) · 1.34 KB
/
index.ts
File metadata and controls
45 lines (37 loc) · 1.34 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
import 'dotenv/config';
import { Pipe } from '@baseai/core';
import inquirer from 'inquirer';
import ora from 'ora';
import chalk from 'chalk';
import pipeProofreaderAgent from './baseai/pipes/proofreader-agent';
const pipe = new Pipe(pipeProofreaderAgent());
async function main() {
console.log(chalk.green('Hi I am Proofreader, enter \"proofread the attach document from CONTEXT\"!'));
console.log(chalk.yellow('Type "exit" to quit the application.\n'));
while (true) {
const { userMsg } = await inquirer.prompt([
{
type: 'input',
name: 'userMsg',
message: chalk.blue('Enter your query (or type "exit" to quit):'),
},
]);
if (userMsg.toLowerCase() === 'exit') {
console.log(chalk.green('Goodbye!'));
break;
}
const spinner = ora('Processing your request...').start();
try {
const { completion: proofReaderResponse } = await pipe.run({
messages: [{ role: 'user', content: userMsg }],
});
spinner.stop();
console.log(chalk.cyan('Agent:'));
console.log(proofReaderResponse);
} catch (error) {
spinner.stop();
console.error(chalk.red('Error processing your request:'), error);
}
}
}
main();