develop #1
3
.env
Normal file
3
.env
Normal 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
3
.env.example
Normal 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
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
37
index.js
Normal file
37
index.js
Normal 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
5738
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
29
package.json
Normal file
29
package.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user