2003sivaramakrishna commited on
Commit
6cfb449
·
verified ·
1 Parent(s): 89b1e6f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ model_id = "defog/sqlcoder-7b-2"
4
+
5
+ def generate_sql(question):
6
+ prompt = f"### Instruction: Generate a SQL query for: {question}\n### Response:"
7
+
8
+ client = gr.load(f"models/{model_id}")
9
+ return client(prompt)
10
+
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown("# 🤖 Free SQL Generator")
13
+ with gr.Row():
14
+ input_text = gr.Textbox(label="Question", placeholder="e.g. List all users from India")
15
+ output_sql = gr.Code(label="SQL Result", language="sql")
16
+ btn = gr.Button("Generate")
17
+ btn.click(generate_sql, inputs=input_text, outputs=output_sql)
18
+
19
+ demo.launch()