File size: 494 Bytes
fd1458a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
import gradio as gr
from transformers import pipeline

pipe = pipeline(
    "text-generation",
    model="Sarveshyadav19/text2sql-qwen-v3"
)

def generate_sql(question):

    prompt = f"""
### Question:
{question}

### SQL:
"""

    result = pipe(
        prompt,
        max_new_tokens=100,
        do_sample=False
    )

    return result[0]["generated_text"]

demo = gr.Interface(
    fn=generate_sql,
    inputs="text",
    outputs="text",
    title="Text to SQL Generator"
)

demo.launch()