Rooni commited on
Commit
a97fdfd
·
verified ·
1 Parent(s): f16210d

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +28 -44
server.js CHANGED
@@ -25,18 +25,25 @@ const limiter = rateLimit({
25
 
26
  // Применение ограничителя скорости перед обработчиком маршрута /pl и /crebeta
27
  app.use('/pl', limiter);
28
- app.use('/crebeta', limiter);
29
 
30
  const start = `${process.env.start}`;
31
  const startconnect = `${process.env.startconnect}`;
32
 
33
- app.post('/cr', async (req, res) => {
34
- res.json({ content: `{"whate":"🪨", "howe":"ОБНОВИТЕСЬ", "text":"Текущая версия приложения устарела. Установите новую из нашего телеграм канала: @yufi_ru", "succ":"победа", "what":"Версию", "how":"Обновите", "howl":"@yufi_ru"}` });
35
  });
36
 
37
  app.post('/pl', async (req, res) => {
38
  const prompt = req.body.prompt;
39
  const apiKey = req.body.api || getRandomApiKey();
 
 
 
 
 
 
 
40
 
41
  if (!prompt) {
42
  return res.status(400).json("wait"); // Не удалось принять данные
@@ -44,7 +51,7 @@ app.post('/pl', async (req, res) => {
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: 2000,
49
  temperature: 0.19,
50
  model: "gemini-1.5-pro-001",
@@ -57,54 +64,29 @@ app.post('/pl', async (req, res) => {
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
- console.log(`\n---\nПользователь: ${prompt}\n Ответ:\n ${content}`);
61
  res.json({ content });
62
  } else {
63
- res.status(500).json({ content: 'errora' }); // Ошибка прочтения
 
64
  }
65
  } catch (error) {
66
  console.error(error);
67
- res.status(500).json({ content: 'errorb' }); // ❌ Произошла ошибка сервера при генерации.
 
68
  }
69
  });
70
 
71
- app.post('/cre', async (req, res) => {
72
  const prompt = req.body.prompt;
73
  const apiKey = req.body.api || getRandomApiKey();
 
74
 
75
- if (!prompt) {
76
- return res.status(400).json("wait"); // Не удалось принять данные
77
- }
78
-
79
- try {
80
- const response = await axios.post('https://vercel.com/roonis-projects/openai-gemini/v1/chat/completions', {
81
- messages: [{'role': 'system', 'content': start}, {'role': 'system', 'content': 'И ОБЯЗАТЕЛЬНО, всегда в конце "text" проси обновить приложение, уведомляя о том, что скоро в жтой версии перестанешь отвечать!'}, {'role': 'user', 'content': prompt}],
82
- max_tokens: 2000,
83
- temperature: 0.19,
84
- model: "gemini-1.5-pro-001",
85
- }, {
86
- headers: {
87
- 'Authorization': `Bearer ${apiKey}`,
88
- 'Content-Type': 'application/json',
89
- },
90
- });
91
-
92
- if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
93
- const content = response.data.choices[0].message.content.trim();
94
- console.log(`\n---\nПользователь: ${prompt}\n Ответ:\n ${content}`);
95
- res.json({ content });
96
- } else {
97
- res.status(500).json({ content: 'errora' }); // Ошибка прочтения
98
- }
99
- } catch (error) {
100
- console.error(error);
101
- res.status(500).json({ content: 'errorb' }); // ❌ Произошла ошибка сервера при генерации.
102
  }
103
- });
104
-
105
- app.post('/crebeta', async (req, res) => {
106
- const prompt = req.body.prompt;
107
- const apiKey = req.body.api || getRandomApiKey();
108
 
109
  if (!prompt) {
110
  return res.status(400).json("wait"); // Не удалось принять данные
@@ -112,7 +94,7 @@ app.post('/crebeta', async (req, res) => {
112
 
113
  try {
114
  const response = await axios.post('https://geminiyufi.vercel.app/v1/chat/completions', {
115
- messages: [{'role': 'system', 'content': startconnect}, {'role': 'user', 'content': prompt}],
116
  max_tokens: 2000,
117
  temperature: 0.24,
118
  model: "gemini-1.5-pro-001",
@@ -125,14 +107,16 @@ app.post('/crebeta', async (req, res) => {
125
 
126
  if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
127
  const content = response.data.choices[0].message.content.trim();
128
- console.log(`\n---\nПользователь: ${prompt}\n Ответ:\n ${content}`);
129
  res.json({ content });
130
  } else {
131
- res.status(500).json({ content: 'errora' }); // Ошибка прочтения
 
132
  }
133
  } catch (error) {
134
  console.error(error);
135
- res.status(500).json({ content: 'errorb' }); // ❌ Произошла ошибка сервера при генерации.
 
136
  }
137
  });
138
 
 
25
 
26
  // Применение ограничителя скорости перед обработчиком маршрута /pl и /crebeta
27
  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"` });
35
  });
36
 
37
  app.post('/pl', async (req, res) => {
38
  const prompt = req.body.prompt;
39
  const apiKey = req.body.api || getRandomApiKey();
40
+ const prs = "";
41
+
42
+ if (req.body.mode = "1") {
43
+ prs = start;
44
+ }else{
45
+ prs = startconnect;
46
+ }
47
 
48
  if (!prompt) {
49
  return res.status(400).json("wait"); // Не удалось принять данные
 
51
 
52
  try {
53
  const response = await axios.post('https://openai-gemini-iota.vercel.app/v1/chat/completions', {
54
+ messages: [{'role': 'system', 'content': prs}, {'role': 'user', 'content': prompt}],
55
  max_tokens: 2000,
56
  temperature: 0.19,
57
  model: "gemini-1.5-pro-001",
 
64
 
65
  if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
66
  const content = response.data.choices[0].message.content.trim();
67
+ // console.log(`\n---\nПользователь: ${prompt}\n Ответ:\n ${content}`);
68
  res.json({ content });
69
  } else {
70
+ //res.status(500).json({ content: 'errora' }); // Ошибка прочтения
71
+ res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка прочтения)", "okb":"Ок", "oklink":"", "cancelable":"true"` })
72
  }
73
  } catch (error) {
74
  console.error(error);
75
+ //res.status(500).json({ content: 'errorb' }); // ❌ Произошла ошибка сервера при генерации.
76
+ res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка при генерации)", "okb":"Ок", "oklink":"", "cancelable":"true"` })
77
  }
78
  });
79
 
80
+ app.post('/plbeta', async (req, res) => {
81
  const prompt = req.body.prompt;
82
  const apiKey = req.body.api || getRandomApiKey();
83
+ const prs = "";
84
 
85
+ if (req.body.mode = "1") {
86
+ prs = start;
87
+ }else{
88
+ prs = startconnect;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
 
 
 
 
 
90
 
91
  if (!prompt) {
92
  return res.status(400).json("wait"); // Не удалось принять данные
 
94
 
95
  try {
96
  const response = await axios.post('https://geminiyufi.vercel.app/v1/chat/completions', {
97
+ messages: [{'role': 'system', 'content': prs}, {'role': 'user', 'content': prompt}],
98
  max_tokens: 2000,
99
  temperature: 0.24,
100
  model: "gemini-1.5-pro-001",
 
107
 
108
  if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
109
  const content = response.data.choices[0].message.content.trim();
110
+ // console.log(`\n---\nПользователь: ${prompt}\n Ответ:\n ${content}`);
111
  res.json({ content });
112
  } else {
113
+ //res.status(500).json({ content: 'errora' }); // Ошибка прочтения
114
+ res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка прочтения)", "okb":"Ок", "oklink":"", "cancelable":"true"` })
115
  }
116
  } catch (error) {
117
  console.error(error);
118
+ //res.status(500).json({ content: 'errorb' }); // ❌ Произошла ошибка сервера при генерации.
119
+ res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка при генерации)", "okb":"Ок", "oklink":"", "cancelable":"true"` })
120
  }
121
  });
122