-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (25 loc) · 942 Bytes
/
server.js
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
import dotenv from 'dotenv'
import { OpenIA } from './src/aplication/index.js'
import { Interface } from './src/presenter/index.js';
(async ()=> {
dotenv.config()
const IAService = new OpenIA();
const presenter = new Interface();
presenter.write(`\n\nOPEN IA INTERFACE\n\n`)
ListenInteractive(1)
function ListenInteractive(interaction){
presenter.write(`=== INTERAÇÃO Nº${interaction} ===\n`)
presenter.write(`Digite uma mensagem: `)
presenter.listenLine((msg) => {
presenter.write("ChatGPT : ")
const content = msg.replace("Digite uma mensagem: ", '')
IAService.chatSync(content, {
onRead: (response) => presenter.write(response),
onFinish: () => {
presenter.write(`\n\n`)
ListenInteractive(interaction + 1)
}
})
})
}
})()