Spaces:
Sleeping
Sleeping
Aleksandr Maiorov
commited on
Commit
·
2b0aafa
1
Parent(s):
1783e45
v0.6.2 - просто апи для генерации текста
Browse files- пробую разные настройки для ускорения генерации;
app.py
CHANGED
@@ -42,8 +42,9 @@ try:
|
|
42 |
LLM = Llama.from_pretrained(
|
43 |
repo_id=REPO_ID,
|
44 |
filename='Vikhr-Qwen-2.5-1.5b-Instruct-Q8_0.gguf',
|
45 |
-
n_gpu_layers=-1,
|
46 |
n_threads=2,
|
|
|
|
|
47 |
n_ctx=4096,
|
48 |
temperature=0.3,
|
49 |
num_return_sequences=1,
|
|
|
42 |
LLM = Llama.from_pretrained(
|
43 |
repo_id=REPO_ID,
|
44 |
filename='Vikhr-Qwen-2.5-1.5b-Instruct-Q8_0.gguf',
|
|
|
45 |
n_threads=2,
|
46 |
+
n_batch=4096,
|
47 |
+
n_gpu_layers=-1,
|
48 |
n_ctx=4096,
|
49 |
temperature=0.3,
|
50 |
num_return_sequences=1,
|
bot.py
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
import asyncio
|
2 |
-
import logging
|
3 |
-
import os
|
4 |
-
|
5 |
-
from dotenv import load_dotenv
|
6 |
-
from telegram import Update
|
7 |
-
from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes
|
8 |
-
|
9 |
-
load_dotenv()
|
10 |
-
TOKEN = os.environ.get("TELEGRAM_TOKEN")
|
11 |
-
logging.log(logging.INFO, TOKEN)
|
12 |
-
|
13 |
-
|
14 |
-
# Команды
|
15 |
-
async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
16 |
-
await update.message.reply_text("Привет! Я простой бот. Напиши что-нибудь, и я повторю!")
|
17 |
-
|
18 |
-
|
19 |
-
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
20 |
-
await update.message.reply_text("Доступные команды:\n/start - начать общение\n/help - помощь")
|
21 |
-
|
22 |
-
|
23 |
-
# Обработка текстовых сообщений
|
24 |
-
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
25 |
-
text = update.message.text
|
26 |
-
print(f"User ({update.message.chat.id}): {text}")
|
27 |
-
await update.message.reply_text(f"Вы написали: {text}")
|
28 |
-
|
29 |
-
|
30 |
-
# Ошибки
|
31 |
-
async def error(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
32 |
-
print(f"Update {update} caused error {context.error}")
|
33 |
-
|
34 |
-
|
35 |
-
# Запуск бота
|
36 |
-
async def start_bot():
|
37 |
-
print(f"Starting bot...${TOKEN}")
|
38 |
-
app = Application.builder().token(TOKEN).build()
|
39 |
-
|
40 |
-
# Регистрация команд
|
41 |
-
app.add_handler(CommandHandler("start", start_command))
|
42 |
-
app.add_handler(CommandHandler("help", help_command))
|
43 |
-
|
44 |
-
# Регистрация обработчика сообщений
|
45 |
-
app.add_handler(MessageHandler(filters.TEXT, handle_message))
|
46 |
-
|
47 |
-
# Регистрация обработчика ошибок
|
48 |
-
app.add_error_handler(error)
|
49 |
-
|
50 |
-
# Опрос сервера
|
51 |
-
print("Polling...")
|
52 |
-
await app.run_polling(timeout=3)
|
53 |
-
|
54 |
-
|
55 |
-
if __name__ == "__main__":
|
56 |
-
asyncio.run(start_bot()) # З
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|