Spaces:
Running
Running
Update server.js
Browse files
server.js
CHANGED
@@ -28,7 +28,6 @@ app.use('/pl', limiter);
|
|
28 |
app.use('/plbeta', limiter);
|
29 |
|
30 |
const start = `${process.env.start}`;
|
31 |
-
const startconnect = `${process.env.startconnect}`;
|
32 |
|
33 |
app.post('/update', async (req, res) => {
|
34 |
res.json({ content: `{"error":"", "title":"Требуется обновление", "text":"Текущая версия приложения устарела. Установите новую из нашего телеграм канала: @yufi_ru", "okb":"Обновить", "oklink":"https://t.me/yufi_ru", "cancelable":"false"}` });
|
@@ -38,13 +37,6 @@ app.post('/pl', async (req, res) => {
|
|
38 |
const prompt = req.body.prompt;
|
39 |
const apiKey = req.body.api || getRandomApiKey();
|
40 |
|
41 |
-
let prs; // Объявление переменной prs перед использованием
|
42 |
-
|
43 |
-
if (req.body.mode === "1") {
|
44 |
-
prs = start;
|
45 |
-
} else {
|
46 |
-
prs = startconnect;
|
47 |
-
}
|
48 |
|
49 |
if (!prompt) {
|
50 |
return res.status(400).json("wait"); // Не удалось принять данные
|
@@ -52,51 +44,10 @@ app.post('/pl', async (req, res) => {
|
|
52 |
|
53 |
try {
|
54 |
const response = await axios.post('https://openai-gemini-iota.vercel.app/v1/chat/completions', {
|
55 |
-
messages: [{'role': 'system', 'content':
|
56 |
-
max_tokens:
|
57 |
-
temperature: 0.
|
58 |
-
model: "gemini-1.5-pro-
|
59 |
-
}, {
|
60 |
-
headers: {
|
61 |
-
'Authorization': `Bearer ${apiKey}`,
|
62 |
-
'Content-Type': 'application/json',
|
63 |
-
},
|
64 |
-
});
|
65 |
-
|
66 |
-
if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
|
67 |
-
const content = response.data.choices[0].message.content.trim();
|
68 |
-
res.json({ content });
|
69 |
-
} else {
|
70 |
-
res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка прочтения)", "okb":"Ок", "oklink":"", "cancelable":"true"}` });
|
71 |
-
}
|
72 |
-
} catch (error) {
|
73 |
-
console.error(error);
|
74 |
-
res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка при генерации)", "okb":"Ок", "oklink":"", "cancelable":"true"}` });
|
75 |
-
}
|
76 |
-
});
|
77 |
-
|
78 |
-
app.post('/plbeta', async (req, res) => {
|
79 |
-
const prompt = req.body.prompt;
|
80 |
-
const apiKey = req.body.api || getRandomApiKey();
|
81 |
-
|
82 |
-
let prs; // Объявление переменной prs перед использованием
|
83 |
-
|
84 |
-
if (req.body.mode === "1") {
|
85 |
-
prs = start;
|
86 |
-
} else {
|
87 |
-
prs = startconnect;
|
88 |
-
}
|
89 |
-
|
90 |
-
if (!prompt) {
|
91 |
-
return res.status(400).json("wait"); // Не удалось принять данные
|
92 |
-
}
|
93 |
-
|
94 |
-
try {
|
95 |
-
const response = await axios.post('https://geminiyufi.vercel.app/v1/chat/completions', {
|
96 |
-
messages: [{'role': 'system', 'content': prs}, {'role': 'user', 'content': prompt}],
|
97 |
-
max_tokens: 2000,
|
98 |
-
temperature: 0.24,
|
99 |
-
model: "gemini-1.5-pro-001",
|
100 |
}, {
|
101 |
headers: {
|
102 |
'Authorization': `Bearer ${apiKey}`,
|
@@ -106,7 +57,6 @@ app.post('/plbeta', async (req, res) => {
|
|
106 |
|
107 |
if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
|
108 |
const content = response.data.choices[0].message.content.trim();
|
109 |
-
console.log(`\n---\nПользователь: ${prompt}\n Ответ:\n ${content}`);
|
110 |
res.json({ content });
|
111 |
} else {
|
112 |
res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка прочтения)", "okb":"Ок", "oklink":"", "cancelable":"true"}` });
|
|
|
28 |
app.use('/plbeta', limiter);
|
29 |
|
30 |
const start = `${process.env.start}`;
|
|
|
31 |
|
32 |
app.post('/update', async (req, res) => {
|
33 |
res.json({ content: `{"error":"", "title":"Требуется обновление", "text":"Текущая версия приложения устарела. Установите новую из нашего телеграм канала: @yufi_ru", "okb":"Обновить", "oklink":"https://t.me/yufi_ru", "cancelable":"false"}` });
|
|
|
37 |
const prompt = req.body.prompt;
|
38 |
const apiKey = req.body.api || getRandomApiKey();
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
if (!prompt) {
|
42 |
return res.status(400).json("wait"); // Не удалось принять данные
|
|
|
44 |
|
45 |
try {
|
46 |
const response = await axios.post('https://openai-gemini-iota.vercel.app/v1/chat/completions', {
|
47 |
+
messages: [{'role': 'system', 'content': start}, {'role': 'user', 'content': prompt}],
|
48 |
+
max_tokens: 3000,
|
49 |
+
temperature: 0.7,
|
50 |
+
model: "gemini-1.5-pro-002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}, {
|
52 |
headers: {
|
53 |
'Authorization': `Bearer ${apiKey}`,
|
|
|
57 |
|
58 |
if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
|
59 |
const content = response.data.choices[0].message.content.trim();
|
|
|
60 |
res.json({ content });
|
61 |
} else {
|
62 |
res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка прочтения)", "okb":"Ок", "oklink":"", "cancelable":"true"}` });
|