richardr1126 commited on
Commit
e2ff706
1 Parent(s): 80be5da
Files changed (2) hide show
  1. app.py +8 -8
  2. test.py +7 -7
app.py CHANGED
@@ -84,17 +84,17 @@ def bot(input_message: str, db_info="", temperature=0.1, top_p=0.9, top_k=0, rep
84
  formatted_query = final_query
85
 
86
  # Convert SQL to markdown (not required, but just to show how to use the markdown module)
87
- final_query_markdown = f"```sql\n{formatted_query}\n```"
88
  return final_query_markdown
89
 
90
- with gr.Blocks(css_theme="light") as demo:
91
- header_md = gr.Markdown("""
92
- # SQL Skeleton WizardCoder Demo
93
  """)
94
 
95
- output_box = gr.Code(label="Generated SQL", lines=2, placeholder="Output will appear here after running the model.")
96
  input_text = gr.Textbox(lines=3, placeholder='Input text here...', label='Input Text')
97
- db_info = gr.Textbox(lines=6, placeholder='Example: | table_01 : column_01 , column_02 | table_02 : column_01 , column_02 | ...', label='Database Info')
98
 
99
  with gr.Accordion("Hyperparameters", open=False):
100
  temperature = gr.Slider(label="Temperature", minimum=0.0, maximum=1.0, value=0.1, step=0.1)
@@ -102,7 +102,7 @@ with gr.Blocks(css_theme="light") as demo:
102
  top_k = gr.Slider(label="Top-k", minimum=0, maximum=200, value=0, step=1)
103
  repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.08, step=0.1)
104
 
105
- run_button = gr.Button("Generate SQL")
106
 
107
  examples = gr.Examples([
108
  ["What is the average, minimum, and maximum age for all French singers?", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"],
@@ -112,6 +112,6 @@ with gr.Blocks(css_theme="light") as demo:
112
  ["List the names of all singers who performed in a concert with the theme 'Rock'", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"]
113
  ], inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], fn=bot)
114
 
115
- run_button.click(fn=bot, inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], outputs=output_box)
116
 
117
  demo.launch()
 
84
  formatted_query = final_query
85
 
86
  # Convert SQL to markdown (not required, but just to show how to use the markdown module)
87
+ final_query_markdown = f"{formatted_query}"
88
  return final_query_markdown
89
 
90
+ with gr.Blocks(theme='gradio/soft') as demo:
91
+ header_md = gr.HTML("""
92
+ <h1 style="text-align: center">SQL Skeleton WizardCoder Demo</h1>
93
  """)
94
 
95
+ output_box = gr.Code(label="Generated SQL", lines=2, interactive=True)
96
  input_text = gr.Textbox(lines=3, placeholder='Input text here...', label='Input Text')
97
+ db_info = gr.Textbox(lines=5, placeholder='Example: | table_01 : column_01 , column_02 | table_02 : column_01 , column_02 | ...', label='Database Info')
98
 
99
  with gr.Accordion("Hyperparameters", open=False):
100
  temperature = gr.Slider(label="Temperature", minimum=0.0, maximum=1.0, value=0.1, step=0.1)
 
102
  top_k = gr.Slider(label="Top-k", minimum=0, maximum=200, value=0, step=1)
103
  repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.08, step=0.1)
104
 
105
+ run_button = gr.Button("Generate SQL", variant="primary")
106
 
107
  examples = gr.Examples([
108
  ["What is the average, minimum, and maximum age for all French singers?", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"],
 
112
  ["List the names of all singers who performed in a concert with the theme 'Rock'", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"]
113
  ], inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], fn=bot)
114
 
115
+ run_button.click(fn=bot, inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], outputs=output_box, api_name="txt2sql")
116
 
117
  demo.launch()
test.py CHANGED
@@ -3,15 +3,15 @@ import gradio as gr
3
  def bot(input_message: str, db_info="", temperature=0.1, top_p=0.9, top_k=0, repetition_penalty=1.08):
4
  # For the stripped down version, let's just return a preset output
5
  final_query = "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"
6
- final_query_markdown = f"\n{final_query}\n"
7
  return final_query_markdown
8
 
9
- with gr.Blocks(css_theme="light") as demo:
10
- header_md = gr.Markdown("""
11
- # SQL Skeleton WizardCoder Demo
12
  """)
13
 
14
- output_box = gr.Code(label="Generated SQL", lines=2, placeholder="Output will appear here after running the model.")
15
  input_text = gr.Textbox(lines=3, placeholder='Input text here...', label='Input Text')
16
  db_info = gr.Textbox(lines=6, placeholder='Example: | table_01 : column_01 , column_02 | table_02 : column_01 , column_02 | ...', label='Database Info')
17
 
@@ -21,7 +21,7 @@ with gr.Blocks(css_theme="light") as demo:
21
  top_k = gr.Slider(label="Top-k", minimum=0, maximum=200, value=0, step=1)
22
  repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.08, step=0.1)
23
 
24
- run_button = gr.Button("Generate SQL")
25
 
26
  examples = gr.Examples([
27
  ["What is the average, minimum, and maximum age for all French singers?", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"],
@@ -31,6 +31,6 @@ with gr.Blocks(css_theme="light") as demo:
31
  ["List the names of all singers who performed in a concert with the theme 'Rock'", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"]
32
  ], inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], fn=bot)
33
 
34
- run_button.click(fn=bot, inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], outputs=output_box)
35
 
36
  demo.launch()
 
3
  def bot(input_message: str, db_info="", temperature=0.1, top_p=0.9, top_k=0, repetition_penalty=1.08):
4
  # For the stripped down version, let's just return a preset output
5
  final_query = "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"
6
+ final_query_markdown = f"{final_query}"
7
  return final_query_markdown
8
 
9
+ with gr.Blocks(theme='gradio/soft') as demo:
10
+ header_md = gr.HTML("""
11
+ <h1 style="text-align: center">SQL Skeleton WizardCoder Demo</h1>
12
  """)
13
 
14
+ output_box = gr.Code(label="Generated SQL", lines=2, interactive=True)
15
  input_text = gr.Textbox(lines=3, placeholder='Input text here...', label='Input Text')
16
  db_info = gr.Textbox(lines=6, placeholder='Example: | table_01 : column_01 , column_02 | table_02 : column_01 , column_02 | ...', label='Database Info')
17
 
 
21
  top_k = gr.Slider(label="Top-k", minimum=0, maximum=200, value=0, step=1)
22
  repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.08, step=0.1)
23
 
24
+ run_button = gr.Button("Generate SQL", variant="primary")
25
 
26
  examples = gr.Examples([
27
  ["What is the average, minimum, and maximum age for all French singers?", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"],
 
31
  ["List the names of all singers who performed in a concert with the theme 'Rock'", "| stadium : stadium_id , location , name , capacity , highest , lowest , average | singer : singer_id , name , country , song_name , song_release_year , age , is_male | concert : concert_id , concert_name , theme , stadium_id , year | singer_in_concert : concert_id , singer_id | concert.stadium_id = stadium.stadium_id | singer_in_concert.singer_id = singer.singer_id | singer_in_concert.concert_id = concert.concert_id |"]
32
  ], inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], fn=bot)
33
 
34
+ run_button.click(fn=bot, inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty], outputs=output_box, api_name="txt2sql")
35
 
36
  demo.launch()