arya-narrable commited on
Commit
ce2562b
·
verified ·
1 Parent(s): 80949dd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ model_name = "internistai/base-7b-v0.2"
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+ model = AutoModelForCausalLM.from_pretrained(model_name)
7
+
8
+ def chat(message):
9
+ inputs = tokenizer(message, return_tensors="pt")
10
+ outputs = model.generate(**inputs)
11
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
12
+ return response
13
+
14
+ iface = gr.Interface(fn=chat, inputs="text", outputs="text")
15
+ iface.launch()