NLSQL / app.py
HusnaManakkot's picture
Update app.py
84b4e3d verified
raw
history blame
700 Bytes
import gradio as gr
from transformers import pipeline
# Load the NL2SQL model
model_id = "hrshtsharma2012/NL2SQL-Picard-final"
nl2sql = pipeline("text2text-generation", model=model_id)
def generate_sql(nl_query):
# Generate the SQL query from the natural language input
sql_query = nl2sql(nl_query)[0]["generated_text"]
return sql_query
# Create the Gradio interface
interface = gr.Interface(
fn=generate_sql,
inputs=gr.Textbox(label="Natural Language Query"),
outputs=gr.Textbox(label="SQL Query"),
title="NL to SQL Converter",
description="Enter a natural language query and get the corresponding SQL query.",
)
if __name__ == "__main__":
interface.launch()