-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample.ts
24 lines (19 loc) · 888 Bytes
/
example.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
const ChatGPT = require('./lib/cjs/index.js').default;
// create new instance of ChatGPT
const chatGPT = new ChatGPT(process.env.API_KEY || '');
const example = async () => {
let response = await chatGPT.ask('Who is James Bond?');
console.log('\nWho is James Bond?\n>>>', response);
response = await chatGPT.ask('How many movies were filmed?');
console.log('\nHow many movies were filmed?\n>>>', response);
response = await chatGPT.ask('Which actors played him?');
console.log('\nWhich actors played him?\n>>>', response);
response = await chatGPT.retry();
console.log('\n[retry]\n>>>', response);
//response = await chatGPT.retry('Reverse the list');
//console.log('\n[retry] Reverse the list\n>>>', response);
//chatGPT.resetConversation();
//response = await chatGPT.ask('Who wrote the books?');
//console.log('\nWho wrote the books?\n>>>', response);
};
example();