Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,19 @@
|
|
1 |
-
from
|
2 |
-
import torch
|
3 |
from telegram import Update
|
4 |
from telegram.ext import Application, CommandHandler, MessageHandler, filters, CallbackContext
|
5 |
|
6 |
-
# β
Model
|
7 |
-
|
8 |
|
9 |
# β
Load Model
|
10 |
-
|
11 |
-
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype=torch.float16)
|
12 |
|
13 |
# β
Telegram Bot Token
|
14 |
TELEGRAM_BOT_TOKEN = "7881901341:AAEaE5gndeORmCuyzSwOyf2ELFLXHneCpiw"
|
15 |
|
16 |
def chat(prompt):
|
17 |
-
|
18 |
-
output
|
19 |
-
return tokenizer.decode(output[0], skip_special_tokens=True)
|
20 |
|
21 |
# β
Telegram Commands
|
22 |
async def start(update: Update, context: CallbackContext) -> None:
|
|
|
1 |
+
from llama_cpp import Llama
|
|
|
2 |
from telegram import Update
|
3 |
from telegram.ext import Application, CommandHandler, MessageHandler, filters, CallbackContext
|
4 |
|
5 |
+
# β
Hugging Face Model Path
|
6 |
+
model_path = "TheBloke/Pygmalion-13B-SuperHOT-8K-GPTQ"
|
7 |
|
8 |
# β
Load Model
|
9 |
+
model = Llama.from_pretrained(model_path, model_file="model.gguf", n_ctx=4096)
|
|
|
10 |
|
11 |
# β
Telegram Bot Token
|
12 |
TELEGRAM_BOT_TOKEN = "7881901341:AAEaE5gndeORmCuyzSwOyf2ELFLXHneCpiw"
|
13 |
|
14 |
def chat(prompt):
|
15 |
+
output = model(prompt, max_tokens=200, temperature=0.7, top_p=0.9)
|
16 |
+
return output["choices"][0]["text"]
|
|
|
17 |
|
18 |
# β
Telegram Commands
|
19 |
async def start(update: Update, context: CallbackContext) -> None:
|