Pravincoder commited on
Commit
aa693d4
·
1 Parent(s): e2eb65e

app.py done!

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer, AutoModel
4
+
5
+ device = "cuda" if torch.cuda.is_available() else "cpu"
6
+
7
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-13b-chat-hf",trust_remote_code=True)
8
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-13b-chat-hf", trust_remote_code=True).float()
9
+
10
+
11
+ def chat(message,history):
12
+ for response,history in model.stream_chat(tokenizer,message,history,max_length=2048,top_p=0.7,temperature=1):
13
+ yield response
14
+
15
+ gr.ChatInterface(chat,
16
+ title="llama2 (Play AI chat at aironheart.com For FREE!)",
17
+ description="""
18
+ Hi guys! I am a solo developer and I made an app: __ProChat__.
19
+
20
+ """,
21
+ ).queue(1).launch()