richardr1126 commited on
Commit
66983ee
1 Parent(s): d119dc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -10,6 +10,7 @@ from transformers import (
10
  from huggingface_hub import login
11
  import gradio as gr
12
  import torch
 
13
 
14
  login(os.getenv("HF_TOKEN", None))
15
 
@@ -76,34 +77,27 @@ def bot(input_message: str, temperature=0.1, top_p=0.9, top_k=0, repetition_pena
76
 
77
  # Split the text by "|", and get the last element in the list which should be the final query
78
  final_query = partial_text.split("|")[-1].strip()
79
- return final_query
 
 
80
 
81
 
82
  gradio_interface = gr.Interface(
83
  fn=bot,
84
  inputs=[
85
- gr.Textbox(default="Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. ### Instruction: Convert text to sql: 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 | ### Response: "),
86
  gr.Slider(label="Temperature", minimum=0.0, maximum=1.0, value=0.1, step=0.1),
87
  gr.Slider(label="Top-p (nucleus sampling)", minimum=0.0, maximum=1.0, value=0.9, step=0.01),
88
  gr.Slider(label="Top-k", minimum=0, maximum=200, value=0, step=1),
89
  gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.08, step=0.1)
90
  ],
91
- outputs="text",
92
  title="SQL Skeleton WizardCoder Demo",
93
  description="""This interactive tool translates natural language instructions into SQL queries, using a trained model. Type or paste your instructions into the text box and click 'Submit' to generate SQL queries. Use the sliders to adjust the model's temperature, top-p, top-k, and repetition penalty values.""",
94
  examples=[
95
- [
96
- "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. ### Instruction: Convert text to sql: 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 | ### Response: ",
97
- 0.1, 0.9, 0, 1.08
98
- ],
99
- [
100
- "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. ### Instruction: Convert text to sql: Show location and name for all stadiums with a capacity between 5000 and 10000. | 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 | ### Response: ",
101
- 0.1, 0.9, 0, 1.08
102
- ],
103
- [
104
- "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. ### Instruction: Convert text to sql: What are the number of concerts that occurred in the stadium with the largest capacity ? | 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 | ### Response: ",
105
- 0.1, 0.9, 0, 1.08
106
- ]
107
  ]
108
  )
109
  gradio_interface.launch()
 
10
  from huggingface_hub import login
11
  import gradio as gr
12
  import torch
13
+ import markdown
14
 
15
  login(os.getenv("HF_TOKEN", None))
16
 
 
77
 
78
  # Split the text by "|", and get the last element in the list which should be the final query
79
  final_query = partial_text.split("|")[-1].strip()
80
+ # Convert SQL to markdown (not required, but just to show how to use the markdown module)
81
+ final_query_markdown = f'```sql\n{final_query}\n```'
82
+ return markdown.markdown(final_query_markdown)
83
 
84
 
85
  gradio_interface = gr.Interface(
86
  fn=bot,
87
  inputs=[
88
+ gr.Textbox(lines=20, placeholder='Input text here...', label='Input Text'),
89
  gr.Slider(label="Temperature", minimum=0.0, maximum=1.0, value=0.1, step=0.1),
90
  gr.Slider(label="Top-p (nucleus sampling)", minimum=0.0, maximum=1.0, value=0.9, step=0.01),
91
  gr.Slider(label="Top-k", minimum=0, maximum=200, value=0, step=1),
92
  gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.08, step=0.1)
93
  ],
94
+ outputs=gr.outputs.Markdown(),
95
  title="SQL Skeleton WizardCoder Demo",
96
  description="""This interactive tool translates natural language instructions into SQL queries, using a trained model. Type or paste your instructions into the text box and click 'Submit' to generate SQL queries. Use the sliders to adjust the model's temperature, top-p, top-k, and repetition penalty values.""",
97
  examples=[
98
+ ["Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\n\nConvert text to sql: 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 | \n\n### Response:\n\n"],
99
+ ["Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\n\nConvert text to sql: Show location and name for all stadiums with a capacity between 5000 and 10000. | 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 | \n\n### Response:\n\n"],
100
+ ["Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\n\nConvert text to sql: What are the number of concerts that occurred in the stadium with the largest capacity ? | 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 | \n\n### Response:\n\n"],
 
 
 
 
 
 
 
 
 
101
  ]
102
  )
103
  gradio_interface.launch()