adamboom111 commited on
Commit
9749f42
·
verified ·
1 Parent(s): 42749e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -11,10 +11,10 @@ def generate_sql(payload):
11
  schema = payload.get("schema", "")
12
  sample_rows = payload.get("sample_rows", [])
13
 
14
- # Convert sample rows into flat string
15
  rows_text = " ".join([str(row) for row in sample_rows]) if sample_rows else ""
16
 
17
- # Construct prompt for instruction tuning
18
  prompt = (
19
  f"You are a SQL expert.\n"
20
  f"Schema: {schema}\n"
@@ -23,9 +23,8 @@ def generate_sql(payload):
23
  f"Generate SQL:"
24
  )
25
 
26
- # Tokenize and generate SQL
27
  input_ids = tokenizer(prompt, return_tensors="pt").input_ids
28
- outputs = model.generate(input_ids, max_length=256, temperature=0.6)
29
  sql = tokenizer.decode(outputs[0], skip_special_tokens=True)
30
 
31
  return sql
@@ -35,7 +34,8 @@ demo = gr.Interface(
35
  inputs=gr.JSON(label="JSON (question, schema, sample_rows)"),
36
  outputs="text",
37
  title="FLAN-T5 Text-to-SQL",
38
- description="Using FLAN-T5 to generate SQL from natural language and tabular schema."
 
39
  )
40
 
41
  demo.launch()
 
11
  schema = payload.get("schema", "")
12
  sample_rows = payload.get("sample_rows", [])
13
 
14
+ # Convert sample rows to a flat string
15
  rows_text = " ".join([str(row) for row in sample_rows]) if sample_rows else ""
16
 
17
+ # Construct the prompt
18
  prompt = (
19
  f"You are a SQL expert.\n"
20
  f"Schema: {schema}\n"
 
23
  f"Generate SQL:"
24
  )
25
 
 
26
  input_ids = tokenizer(prompt, return_tensors="pt").input_ids
27
+ outputs = model.generate(input_ids, max_length=256, temperature=0.7)
28
  sql = tokenizer.decode(outputs[0], skip_special_tokens=True)
29
 
30
  return sql
 
34
  inputs=gr.JSON(label="JSON (question, schema, sample_rows)"),
35
  outputs="text",
36
  title="FLAN-T5 Text-to-SQL",
37
+ description="Using FLAN-T5 to generate SQL from natural language and tabular schema.",
38
+ allow_flagging="never"
39
  )
40
 
41
  demo.launch()