production #2

Merged
levis merged 3 commits from production into develop 2025-06-07 17:22:57 +00:00
2 changed files with 38 additions and 17 deletions
Showing only changes of commit b05ba61ac1 - Show all commits

View File

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