Files
bot-tg-assistent/index.js
2025-06-03 23:47:05 +04:00

38 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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("🤖 Бот запущен и использует модель от Сбербанка.");