develop #1

Merged
levis merged 2 commits from develop into production 2025-06-03 19:48:48 +00:00
6 changed files with 5811 additions and 0 deletions

3
.env Normal file
View File

@ -0,0 +1,3 @@
BOT_TOKEN=7745542423:AAHc3JM1kvO-Z_1OBp1L95T9QWr4jRrbfpY
LLM_API_URL=http://localhost:4001/generate
HF_TOKEN=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

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
BOT_TOKEN=7745542423:AAHc3JM1kvO-Z_1OBp1L95T9QWr4jRrbfpY
LLM_API_URL=http://localhost:4001/generate
HF_TOKEN=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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

37
index.js Normal file
View File

@ -0,0 +1,37 @@
import { Telegraf } from "telegraf";
import axios from "axios";
const botToken = "7745542423:AAHc3JM1kvO-Z_1OBp1L95T9QWr4jRrbfpY";
const bot = new Telegraf(botToken);
const MODEL_URL = "https://llm.miduway.space/generate";
bot.start((ctx) => ctx.reply("Привет! Я — RuGPT-бот. Напиши что-нибудь."));
bot.on("text", async (ctx) => {
const input = ctx.message.text;
ctx.sendChatAction("typing");
try {
const res = await axios.post(MODEL_URL, {
inputs: input,
parameters: {
do_sample: true,
top_k: 50,
top_p: 0.95,
temperature: 1,
},
});
const generated =
res.data.generated_text ||
res.data.generated_texts?.[0] ||
"Не удалось сгенерировать.";
ctx.reply(generated);
} catch (err) {
console.error("Ошибка при запросе к модели:", err.message);
ctx.reply("Произошла ошибка при генерации текста.");
}
});
bot.launch();
console.log("🤖 Бот запущен и использует модель от Сбербанка.");

5738
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "bot-tg-assistent",
"version": "1.0.0",
"description": "Бот для AI ассистента ###",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"repository": {
"type": "git",
"url": "https://gitea.miduway.space/levis/bot-tg-assistent.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@xenova/transformers": "^2.15.1",
"axios": "^1.9.0",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^5.1.0",
"node-telegram-bot-api": "^0.66.0",
"nodemon": "^3.1.10",
"pm2": "^6.0.6",
"telegraf": "^4.15.3"
}
}