File size: 796 Bytes
aa693d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import torch
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoModel

device = "cuda" if torch.cuda.is_available() else "cpu"

tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-13b-chat-hf",trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-13b-chat-hf", trust_remote_code=True).float()


def chat(message,history):
    for response,history in model.stream_chat(tokenizer,message,history,max_length=2048,top_p=0.7,temperature=1):
        yield response

gr.ChatInterface(chat,
                 title="llama2 (Play AI chat at aironheart.com For FREE!)",
                description="""
Hi guys! I am a solo developer and I made an app: __ProChat__.  

                 """,
                 ).queue(1).launch()