-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathindex.ts
More file actions
56 lines (47 loc) · 1.78 KB
/
index.ts
File metadata and controls
56 lines (47 loc) · 1.78 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
import 'dotenv/config';
import { Pipe } from '@baseai/core';
import inquirer from 'inquirer';
import ora from 'ora';
import chalk from 'chalk';
import pipeProductEngineeringAgent from './baseai/pipes/product-engineering-agent';
const pipe = new Pipe(pipeProductEngineeringAgent());
async function main() {
const initialSpinner = ora('Checking attached product data...').start();
try {
const { completion: initialProductEngAgentResponse } = await pipe.run({
messages: [{ role: 'user', content: 'I have attached document in the CONTEXT, proceed with your analysis' }],
});
initialSpinner.stop();
console.log(chalk.cyan('Product Engineering Agent response...'));
console.log(initialProductEngAgentResponse);
} catch (error) {
initialSpinner.stop();
console.error(chalk.red('Error processing initial request:'), error);
}
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: productEngAgentResponse } = await pipe.run({
messages: [{ role: 'user', content: userMsg }],
});
spinner.stop();
console.log(chalk.cyan('Agent:'));
console.log(productEngAgentResponse);
} catch (error) {
spinner.stop();
console.error(chalk.red('Error processing your request:'), error);
}
}
}
main();