Spaces:
Paused
Paused
const axios = require('axios') | |
const {GptModelOld} = require('./models'); | |
const OpenaiRes = async (prompt) => { | |
try { | |
const EncodeUrl = "aHR0cHM6Ly9vcGVuYWktZ3B0LnJlbWl4cHJvamVjdC5vcmcv" | |
let url; | |
try { | |
url = atob(EncodeUrl); | |
} catch (e) { | |
console.error("Could not decode the string! " + e); | |
} | |
const headers = { | |
"Accept": "application/json", | |
"Content-Type": "application/json", | |
"Accept-Language": "en", | |
"Connection": "keep-alive", | |
"Origin": "https://remix.ethereum.org", | |
"Referer": "https://remix.ethereum.org/", | |
"Sec-Fetch-Dest": "empty", | |
"Sec-Fetch-Mode": "cors", | |
"Sec-Fetch-Site": "cross-site", | |
"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" | |
}; | |
const response = await axios.post(url, GptModelOld(prompt), { headers, timeout: 50000 }); | |
if (response.status === 200) { | |
return response.data.choices[0].message.content + "\n\nPowered By xtdevs"; | |
} | |
} catch (error) { | |
console.error("Error:", error.message); | |
return null; | |
} | |
}; | |
module.exports = { OpenaiRes }; |