Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
|
@@ -35,6 +35,7 @@ app.post('/update', async (req, res) => {
|
|
| 35 |
app.post('/pl', async (req, res) => {
|
| 36 |
const prompt = req.body.prompt;
|
| 37 |
const lang = req.body.lang || "ru";
|
|
|
|
| 38 |
const apiKey = req.body.api || getRandomApiKey();
|
| 39 |
|
| 40 |
if (!prompt) {
|
|
@@ -43,11 +44,11 @@ app.post('/pl', async (req, res) => {
|
|
| 43 |
|
| 44 |
try {
|
| 45 |
const response = await axios.post('https://openai-gemini-iota.vercel.app/v1/chat/completions', {
|
| 46 |
-
messages: [{'role': 'system', 'content': `${start}. Отвечай на языке: ${lang}`}
|
| 47 |
max_tokens: 4000,
|
| 48 |
-
temperature: 0.
|
| 49 |
model: "gemini-1.5-pro-002",
|
| 50 |
-
presence_penalty: 0.
|
| 51 |
}, {
|
| 52 |
headers: {
|
| 53 |
'Authorization': `Bearer ${apiKey}`,
|
|
@@ -69,40 +70,7 @@ app.post('/pl', async (req, res) => {
|
|
| 69 |
}
|
| 70 |
});
|
| 71 |
|
| 72 |
-
app.post('/pls', async (req, res) => {
|
| 73 |
-
const prompt = req.body.prompt;
|
| 74 |
-
const apiKey = req.body.api || getRandomApiKey();
|
| 75 |
-
|
| 76 |
-
if (!prompt) {
|
| 77 |
-
return res.status(400).json(`Нет запроса! :${prompt}`); // Не удалось принять данные
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
try {
|
| 81 |
-
const response = await axios.post('https://openai-gemini-iota.vercel.app/v1/chat/completions', {
|
| 82 |
-
messages: [{'role': 'system', 'content': `${start}. Отвечай на языке: ${lang}. Отвечай кратко, но понятно!`}, ,
|
| 83 |
-
...req.body.messages],
|
| 84 |
-
max_tokens: 2000,
|
| 85 |
-
temperature: 0.7,
|
| 86 |
-
model: "gemini-1.5-pro-002",
|
| 87 |
-
presence_penalty: 0.4,
|
| 88 |
-
}, {
|
| 89 |
-
headers: {
|
| 90 |
-
'Authorization': `Bearer ${apiKey}`,
|
| 91 |
-
'Content-Type': 'application/json',
|
| 92 |
-
},
|
| 93 |
-
});
|
| 94 |
|
| 95 |
-
if (response.data.choices && response.data.choices.length > 0 && response.data.choices[0].message) {
|
| 96 |
-
const content = response.data.choices[0].message.content.trim();
|
| 97 |
-
res.json({ content });
|
| 98 |
-
} else {
|
| 99 |
-
res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка прочтения)", "okb":"Ок", "oklink":"", "cancelable":"true"}` });
|
| 100 |
-
}
|
| 101 |
-
} catch (error) {
|
| 102 |
-
console.error(error);
|
| 103 |
-
res.json({ content: `{"error":"", "title":"Ошибка", "text":"Произошла ошибка на сервере. (Ошибка при генерации)", "okb":"Ок", "oklink":"", "cancelable":"true"}` });
|
| 104 |
-
}
|
| 105 |
-
});
|
| 106 |
|
| 107 |
|
| 108 |
const port = 7860;
|
|
|
|
| 35 |
app.post('/pl', async (req, res) => {
|
| 36 |
const prompt = req.body.prompt;
|
| 37 |
const lang = req.body.lang || "ru";
|
| 38 |
+
const chatid = req.body.chatid || "";
|
| 39 |
const apiKey = req.body.api || getRandomApiKey();
|
| 40 |
|
| 41 |
if (!prompt) {
|
|
|
|
| 44 |
|
| 45 |
try {
|
| 46 |
const response = await axios.post('https://openai-gemini-iota.vercel.app/v1/chat/completions', {
|
| 47 |
+
messages: [{'role': 'system', 'content': `Ты врач ${chatid}. ${start}. Отвечай на языке: ${lang}`}],
|
| 48 |
max_tokens: 4000,
|
| 49 |
+
temperature: 0.3,
|
| 50 |
model: "gemini-1.5-pro-002",
|
| 51 |
+
presence_penalty: 0.2,
|
| 52 |
}, {
|
| 53 |
headers: {
|
| 54 |
'Authorization': `Bearer ${apiKey}`,
|
|
|
|
| 70 |
}
|
| 71 |
});
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
const port = 7860;
|