HusnaManakkot commited on
Commit
50aa5cd
Β·
verified Β·
1 Parent(s): f0fdee5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -6,10 +6,12 @@ tokenizer = AutoTokenizer.from_pretrained("hrshtsharma2012/NL2SQL-Picard-final")
6
  model = AutoModelForSeq2SeqLM.from_pretrained("hrshtsharma2012/NL2SQL-Picard-final")
7
 
8
  def generate_sql(query):
9
- input_text = "translate English to SQL: " + query
10
  inputs = tokenizer(input_text, return_tensors="pt", padding=True)
11
  outputs = model.generate(**inputs, max_length=512)
12
  sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
 
13
  return sql_query
14
 
15
  # Create a Gradio interface
@@ -18,9 +20,10 @@ interface = gr.Interface(
18
  inputs=gr.Textbox(lines=2, placeholder="Enter your natural language query here..."),
19
  outputs="text",
20
  title="NL to SQL with Picard",
21
- description="This model converts natural language queries into SQL using the Picard model. Enter your query!"
22
  )
23
 
24
  # Launch the app
25
  if __name__ == "__main__":
26
  interface.launch()
 
 
6
  model = AutoModelForSeq2SeqLM.from_pretrained("hrshtsharma2012/NL2SQL-Picard-final")
7
 
8
  def generate_sql(query):
9
+ input_text = "SQL: " + query
10
  inputs = tokenizer(input_text, return_tensors="pt", padding=True)
11
  outputs = model.generate(**inputs, max_length=512)
12
  sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
13
+ # Remove the "SQL: " prefix from the output
14
+ sql_query = sql_query.replace("SQL: ", "")
15
  return sql_query
16
 
17
  # Create a Gradio interface
 
20
  inputs=gr.Textbox(lines=2, placeholder="Enter your natural language query here..."),
21
  outputs="text",
22
  title="NL to SQL with Picard",
23
+ description="This model converts natural language queries into SQL. Enter your query!"
24
  )
25
 
26
  # Launch the app
27
  if __name__ == "__main__":
28
  interface.launch()
29
+