Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -45,6 +45,27 @@ app.post('/imagetopdf', async (req, res) => {
|
|
| 45 |
}
|
| 46 |
})
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
const PORT = process.env.PORT || 7860
|
| 49 |
app.listen(PORT, () => console.log('App running on port', PORT))
|
| 50 |
|
|
@@ -83,4 +104,25 @@ function toPDF(urls) {
|
|
| 83 |
}
|
| 84 |
})
|
| 85 |
}
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
})
|
| 47 |
|
| 48 |
+
app.post('/api/chatgpt', async (req, res) => {
|
| 49 |
+
try {
|
| 50 |
+
console.log(req.body)
|
| 51 |
+
const { prompt, model, status } = req.body
|
| 52 |
+
if (!prompt) return res.json({ success: false, message: 'Required an prompt text!' })
|
| 53 |
+
if (!model) return res.json({ success: false, message: 'Required an model version!' })
|
| 54 |
+
if (!status) return res.json({ success: false, message: 'Required an prompt text!' })
|
| 55 |
+
|
| 56 |
+
if(status !== "user") return res.json({ success: false, message: 'Invalid status!' })
|
| 57 |
+
const response = await acytoo(prompt, model)
|
| 58 |
+
res.json({
|
| 59 |
+
status: "ok",
|
| 60 |
+
result: response
|
| 61 |
+
})
|
| 62 |
+
} catch (e) {
|
| 63 |
+
console.log(e)
|
| 64 |
+
e = String(e)
|
| 65 |
+
res.json({ error: true, message: e === '[object Object]' ? 'Internal Server Error' : e })
|
| 66 |
+
}
|
| 67 |
+
})
|
| 68 |
+
|
| 69 |
const PORT = process.env.PORT || 7860
|
| 70 |
app.listen(PORT, () => console.log('App running on port', PORT))
|
| 71 |
|
|
|
|
| 104 |
}
|
| 105 |
})
|
| 106 |
}
|
| 107 |
+
async function acytoo(text, model) {
|
| 108 |
+
let res = await axios.request({
|
| 109 |
+
method: "POST",
|
| 110 |
+
url: "https://chat.acytoo.com/api/completions",
|
| 111 |
+
data: JSON.stringify({
|
| 112 |
+
key: "",
|
| 113 |
+
messages: [{
|
| 114 |
+
role: "user",
|
| 115 |
+
content: text,
|
| 116 |
+
createAt: "",
|
| 117 |
+
}],
|
| 118 |
+
model: model,
|
| 119 |
+
password: "",
|
| 120 |
+
temprature: 1
|
| 121 |
+
}),
|
| 122 |
+
headres: {
|
| 123 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
|
| 124 |
+
"Origin": "https://chat.acytoo.com"
|
| 125 |
+
}
|
| 126 |
+
})
|
| 127 |
+
return res.data
|
| 128 |
+
}
|