hssan98 commited on
Commit
deb0e91
1 Parent(s): ca26c31

Create app.py

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