Rooni commited on
Commit
efaa50c
·
verified ·
1 Parent(s): ae689e6

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +39 -1
server.js CHANGED
@@ -24,7 +24,7 @@ app.post('/cr', async (req, res) => {
24
  res.json({ content: `{"whate":"🪨", "howe":"ОБНОВИТЕСЬ", "text":"Текущая версия приложения устарела. Установите новую из нашего телеграм канала: @yufi_ru", "succ":"победа", "what":"Версию", "how":"Обновите", "howl":"@yufi_ru"}` });
25
  });
26
 
27
- app.post('/cre', async (req, res) => {
28
  const prompt = req.body.prompt;
29
  const apiKey = req.body.api || openai_key;
30
 
@@ -62,6 +62,44 @@ app.post('/cre', async (req, res) => {
62
  }
63
  });
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  app.post('/crebeta', async (req, res) => {
66
  const prompt = req.body.prompt;
67
  const apiKey = req.body.api || openai_key;
 
24
  res.json({ content: `{"whate":"🪨", "howe":"ОБНОВИТЕСЬ", "text":"Текущая версия приложения устарела. Установите новую из нашего телеграм канала: @yufi_ru", "succ":"победа", "what":"Версию", "how":"Обновите", "howl":"@yufi_ru"}` });
25
  });
26
 
27
+ app.post('/pl', async (req, res) => {
28
  const prompt = req.body.prompt;
29
  const apiKey = req.body.api || openai_key;
30
 
 
62
  }
63
  });
64
 
65
+ app.post('/cre', 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': 'system', 'content': 'И ОБЯЗАТЕЛЬНО в конце "текст" проси обновить приложение!'}, {'role': 'user', 'content': prompt}],
76
+ max_tokens: 2000,
77
+ temperature: 0.6,
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 ${apiKey}`,
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
  app.post('/crebeta', async (req, res) => {
104
  const prompt = req.body.prompt;
105
  const apiKey = req.body.api || openai_key;