-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (51 loc) · 1.5 KB
/
index.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const axios = require("axios");
const base = "hapi.majidapi.ir/bardia"
module.exports = {
gpt: ({model = "GPT-4", prompt = ""}) => {
let v = "4";
switch (model) {
case "GPT-4":
v = "4";
break;
case "GPT-3":
v = "3";
break;
case "GPT-3.5-turbo":
v = "3-5/turbo";
break;
default:
v = "4";
}
return new Promise((resolve, reject) => {
axios.get(`${base}/gpt/${v}?q=${prompt}`)
.then(r => {
resolve(r.data.result);
})
.catch(err => {
reject("An error has occurred");
});
})
},
textToImage: ({model = "default", prompt = ""}) => {
return new Promise((resolve, reject) => {
axios.get(`${base}/tti?model=${model}&p=${prompt}`)
.then(r => {
resolve(r.data.result);
})
.catch(err => {
reject("An error has occurred");
});
})
},
dalle3: ({prompt = ""}) => {
return new Promise((resolve, reject) => {
axios.get(`${base}/dalle3?p=${prompt}`)
.then(r => {
resolve(r.data.result);
})
.catch(err => {
reject("An error has occurred");
});
})
}
}