Compare commits

..

3 Commits

Author SHA1 Message Date
53012dcbe1 Merge pull request 'production' (#2) from production into develop
Reviewed-on: #2
2025-06-07 17:22:56 +00:00
b05ba61ac1 chore: update index.js
Some checks failed
Deploy Bot / build-and-deploy (push) Failing after 10s
2025-06-07 21:21:59 +04:00
b653c29e0b update deploy.yml
Some checks failed
Deploy Bot / build-and-deploy (push) Failing after 9s
2025-06-07 17:14:46 +00:00
2 changed files with 38 additions and 17 deletions

View File

@ -0,0 +1,23 @@
name: Deploy Bot
on:
push:
branches: [production]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build Docker Image
run: docker build -t my-telegram-bot .
- name: Run Container
run: |
docker stop my-telegram-bot || true
docker rm my-telegram-bot || true
docker run -d --name my-telegram-bot --restart unless-stopped \
-e TELEGRAM_TOKEN=7745542423:AAHc3JM1kvO-Z_1OBp1L95T9QWr4jRrbfpY \
my-telegram-bot

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.");