Spaces:
Sleeping
Sleeping
File size: 1,013 Bytes
f4f80f2 748a3d0 7b2c62f f4f80f2 7b2c62f b8c4f28 7e713f6 7b2c62f aaa6d98 7e713f6 7b2c62f 7e713f6 aaa6d98 7e713f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
from datasets import load_dataset
# Load the WikiSQL dataset
wikisql_dataset = load_dataset("wikisql", split='train[:100]') # Load a subset of the dataset
# Create a mapping between natural language queries and SQL queries
query_sql_mapping = {item['question']: item['sql']['human_readable'] for item in wikisql_dataset}
def generate_sql_from_user_input(query):
# Look up the SQL query corresponding to the user's input
sql_query = query_sql_mapping.get(query, "No exact match found in the dataset.")
return sql_query
# Create a Gradio interface
interface = gr.Interface(
fn=generate_sql_from_user_input,
inputs=gr.Textbox(label="Enter your natural language query"),
outputs=gr.Textbox(label="SQL Query from Dataset"),
title="NL to SQL using WikiSQL Dataset",
description="This interface returns the SQL query from the WikiSQL dataset that exactly matches your natural language input."
)
# Launch the app
if __name__ == "__main__":
interface.launch()
|