chore: update index.js
Some checks failed
Deploy Bot / build-and-deploy (push) Failing after 10s

This commit is contained in:
2025-06-07 21:21:59 +04:00
parent b653c29e0b
commit b05ba61ac1

View File

@ -1,37 +1,35 @@
import { Telegraf } from "telegraf";
import axios from "axios";
const botToken = "7745542423:AAHc3JM1kvO-Z_1OBp1L95T9QWr4jRrbfpY";
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-бот. Напиши что-нибудь."));
// Новый API Ollama
const OLLAMA_URL = "http://localhost:11434/api/generate";
bot.start((ctx) =>
ctx.reply("Привет! Я — Mistral-бoт через Ollama. Напиши что-нибудь.")
);
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 response = await axios.post(OLLAMA_URL, {
model: "mistral:instruct",
prompt: input,
stream: false,
});
const generated =
res.data.generated_text ||
res.data.generated_texts?.[0] ||
"Не удалось сгенерировать.";
ctx.reply(generated);
response.data.response || "Не удалось сгенерировать ответ.";
ctx.reply(generated.trim());
} catch (err) {
console.error("Ошибка при запросе к модели:", err.message);
console.error("Ошибка при запросе к Ollama:", err.message);
ctx.reply("Произошла ошибка при генерации текста.");
}
});
bot.launch();
console.log("🤖 Бот запущен и использует модель от Сбербанка.");
console.log("🤖 Бот запущен и использует Ollama + Mistral.");