Compare commits
6 Commits
9e86273368
...
develop
Author | SHA1 | Date | |
---|---|---|---|
53012dcbe1 | |||
b05ba61ac1 | |||
b653c29e0b | |||
124f367b5e | |||
0950698242 | |||
c569b0d586 |
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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
|
23
.gitea/workflows/deploy.yml
Normal file
23
.gitea/workflows/deploy.yml
Normal 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
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
35
index.js
Normal file
35
index.js
Normal file
@ -0,0 +1,35 @@
|
||||
import { Telegraf } from "telegraf";
|
||||
import axios from "axios";
|
||||
|
||||
const botToken = "7745542423:AAHc3JM1kvO-Z_1OBp1L95T9QWr4jRrbfpY"; // замени на свой
|
||||
const bot = new Telegraf(botToken);
|
||||
|
||||
// Новый 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 response = await axios.post(OLLAMA_URL, {
|
||||
model: "mistral:instruct",
|
||||
prompt: input,
|
||||
stream: false,
|
||||
});
|
||||
|
||||
const generated =
|
||||
response.data.response || "Не удалось сгенерировать ответ.";
|
||||
ctx.reply(generated.trim());
|
||||
} catch (err) {
|
||||
console.error("Ошибка при запросе к Ollama:", err.message);
|
||||
ctx.reply("Произошла ошибка при генерации текста.");
|
||||
}
|
||||
});
|
||||
|
||||
bot.launch();
|
||||
console.log("🤖 Бот запущен и использует Ollama + Mistral.");
|
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