Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
@@ -4,6 +4,7 @@ const axios = require('axios')
|
|
4 |
|
5 |
const {startServer} = require('./lifestyle');
|
6 |
const {GptModelOld} = require('./models.js');
|
|
|
7 |
|
8 |
var Database = require('./database.js');
|
9 |
var CheckMilWare = require('./midware.js');
|
@@ -20,45 +21,12 @@ app.use(async (req, res, next) => {
|
|
20 |
|
21 |
app.get('/api/test', async (req, res) => {
|
22 |
try {
|
23 |
-
// console.log("Test", req)
|
24 |
res.send("Hello world")
|
25 |
} catch (error) {
|
26 |
res.status(401).json({error: error.message})
|
27 |
}
|
28 |
})
|
29 |
|
30 |
-
const OpenaiRes = async (prompt) => {
|
31 |
-
try {
|
32 |
-
const EncodeUrl = "aHR0cHM6Ly9vcGVuYWktZ3B0LnJlbWl4cHJvamVjdC5vcmcv"
|
33 |
-
let url;
|
34 |
-
try {
|
35 |
-
url = atob(EncodeUrl);
|
36 |
-
} catch (e) {
|
37 |
-
console.error("Could not decode the string! " + e);
|
38 |
-
}
|
39 |
-
const headers = {
|
40 |
-
"Accept": "application/json",
|
41 |
-
"Content-Type": "application/json",
|
42 |
-
"Accept-Language": "en",
|
43 |
-
"Connection": "keep-alive",
|
44 |
-
"Origin": "https://remix.ethereum.org",
|
45 |
-
"Referer": "https://remix.ethereum.org/",
|
46 |
-
"Sec-Fetch-Dest": "empty",
|
47 |
-
"Sec-Fetch-Mode": "cors",
|
48 |
-
"Sec-Fetch-Site": "cross-site",
|
49 |
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"
|
50 |
-
};
|
51 |
-
const response = await axios.post(url, GptModelOld(prompt), { headers, timeout: 50000 });
|
52 |
-
if (response.status === 200) {
|
53 |
-
return response.data.choices[0].message.content + "\n\nPowered By xtdevs";
|
54 |
-
}
|
55 |
-
// console.log("Response:", response)
|
56 |
-
} catch (error) {
|
57 |
-
console.error("Error:", error.message);
|
58 |
-
return null;
|
59 |
-
}
|
60 |
-
};
|
61 |
-
|
62 |
app.get('/api/gpt-old', async (req, res) => {
|
63 |
try {
|
64 |
const query = req.query.query;
|
@@ -69,5 +37,4 @@ app.get('/api/gpt-old', async (req, res) => {
|
|
69 |
}
|
70 |
});
|
71 |
|
72 |
-
|
73 |
startServer(app);
|
|
|
4 |
|
5 |
const {startServer} = require('./lifestyle');
|
6 |
const {GptModelOld} = require('./models.js');
|
7 |
+
const {OpenaiRes} = require('./scrapper.js');
|
8 |
|
9 |
var Database = require('./database.js');
|
10 |
var CheckMilWare = require('./midware.js');
|
|
|
21 |
|
22 |
app.get('/api/test', async (req, res) => {
|
23 |
try {
|
|
|
24 |
res.send("Hello world")
|
25 |
} catch (error) {
|
26 |
res.status(401).json({error: error.message})
|
27 |
}
|
28 |
})
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
app.get('/api/gpt-old', async (req, res) => {
|
31 |
try {
|
32 |
const query = req.query.query;
|
|
|
37 |
}
|
38 |
});
|
39 |
|
|
|
40 |
startServer(app);
|