Spaces:
Runtime error
Runtime error
create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load pipeline for text2sql
|
5 |
+
pipe = pipeline("text2text-generation", model="mrm8488/t5-base-finetuned-wikiSQL")
|
6 |
+
|
7 |
+
def generate_sql(query):
|
8 |
+
result = pipe(f"translate English to SQL: {query}")
|
9 |
+
return result[0]['generated_text']
|
10 |
+
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=generate_sql,
|
13 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your natural language query..."),
|
14 |
+
outputs="text",
|
15 |
+
title="SQL Query Generator",
|
16 |
+
description="Enter a natural language question and get a SQL query."
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch()
|