Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -20,10 +20,6 @@ const limiter = rateLimit({
|
|
| 20 |
|
| 21 |
const start = `${process.env.start}`;
|
| 22 |
|
| 23 |
-
app.post('/generate', async (req, res) => {
|
| 24 |
-
res.status(500).json({ content: '+ошибка+❗ Вы используете устаревшую версию АромаАрт. Установите версию 1.3.1 и более.-ошибка-' });
|
| 25 |
-
});
|
| 26 |
-
|
| 27 |
app.post('/cr', async (req, res) => {
|
| 28 |
res.json({ content: `{"whate":"🪨", "howe":"ОБНОВИТЕСЬ", "text":"Текущая версия приложения устарела. Установите новую из нашего телеграм канала: @yufi_ru", "succ":"победа", "what":"Версию", "how":"Обновите", "howl":"@yufi_ru"}` });
|
| 29 |
});
|
|
@@ -66,6 +62,45 @@ app.post('/cre', async (req, res) => {
|
|
| 66 |
}
|
| 67 |
});
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
const port = 7860;
|
| 70 |
app.listen(port, () => {
|
| 71 |
console.log(`API сервер запущен на порту ${port}`);
|
|
|
|
| 20 |
|
| 21 |
const start = `${process.env.start}`;
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
app.post('/cr', async (req, res) => {
|
| 24 |
res.json({ content: `{"whate":"🪨", "howe":"ОБНОВИТЕСЬ", "text":"Текущая версия приложения устарела. Установите новую из нашего телеграм канала: @yufi_ru", "succ":"победа", "what":"Версию", "how":"Обновите", "howl":"@yufi_ru"}` });
|
| 25 |
});
|
|
|
|
| 62 |
}
|
| 63 |
});
|
| 64 |
|
| 65 |
+
app.post('/crebeta', async (req, res) => {
|
| 66 |
+
const prompt = req.body.prompt;
|
| 67 |
+
const apiKey = req.body.api || openai_key;
|
| 68 |
+
|
| 69 |
+
if (!prompt) {
|
| 70 |
+
return res.status(400).json("wait"); // Не удалось принять данные
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
try {
|
| 74 |
+
const response = await axios.post('https://api.deepseek.com/v1/chat/completions', {
|
| 75 |
+
messages: [{'role': 'system', 'content': start}, {'role': 'user', 'content': prompt}],
|
| 76 |
+
max_tokens: 2000,
|
| 77 |
+
temperature: 0.24,
|
| 78 |
+
// presence_penalty: 0.0,
|
| 79 |
+
//frequency_penalty: -0.1,
|
| 80 |
+
//model: "gemini-1.5-pro-latest",
|
| 81 |
+
model: "deepseek-chat",
|
| 82 |
+
//model: "gemini-1.5-flash-latest",
|
| 83 |
+
}, {
|
| 84 |
+
headers: {
|
| 85 |
+
'Authorization': `Bearer sk-c0407cb14046455a98ce91053b257994`,
|
| 86 |
+
'Content-Type': 'application/json',
|
| 87 |
+
},
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
|
| 91 |
+
const content = response.data.choices[0].message.content.trim();
|
| 92 |
+
console.log(`\n---\nПользователь: ${prompt}\n Ответ:\n ${content}`);
|
| 93 |
+
res.json({ content });
|
| 94 |
+
} else {
|
| 95 |
+
res.status(500).json({ content: 'errora' }); // Ошибка прочтения
|
| 96 |
+
}
|
| 97 |
+
} catch (error) {
|
| 98 |
+
console.error(error);
|
| 99 |
+
res.status(500).json({ content: 'errorb' }); // ❌ Произошла ошибка сервера при генерации.
|
| 100 |
+
}
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
|
| 104 |
const port = 7860;
|
| 105 |
app.listen(port, () => {
|
| 106 |
console.log(`API сервер запущен на порту ${port}`);
|