syedmoinms commited on
Commit
ce39110
Β·
verified Β·
1 Parent(s): 088dfe0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -1,22 +1,19 @@
1
- from transformers import AutoTokenizer, AutoModelForCausalLM
2
- import torch
3
  from telegram import Update
4
  from telegram.ext import Application, CommandHandler, MessageHandler, filters, CallbackContext
5
 
6
- # βœ… Model Name
7
- model_name = "TheBloke/Pygmalion-13B-SuperHOT-8K-GPTQ"
8
 
9
  # βœ… Load Model
10
- tokenizer = AutoTokenizer.from_pretrained(model_name)
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
- inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
18
- output = model.generate(**inputs, max_new_tokens=200, do_sample=True, temperature=0.7, top_p=0.9)
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: