richardr1126 commited on
Commit
1ee50bb
β€’
1 Parent(s): cf129e2

Remove copy button

Browse files
Files changed (3) hide show
  1. app-ngrok.py +0 -3
  2. requirements.txt +1 -2
  3. test.py +0 -74
app-ngrok.py CHANGED
@@ -5,7 +5,6 @@ import requests
5
  from time import sleep
6
  import re
7
  import platform
8
- import pyperclip
9
  # Additional Firebase imports
10
  import firebase_admin
11
  from firebase_admin import credentials, firestore
@@ -164,7 +163,6 @@ with gr.Blocks(theme='gradio/soft') as demo:
164
  output_box = gr.Code(label="Generated SQL", lines=2, interactive=False)
165
 
166
  with gr.Row():
167
- copy_button = gr.Button("πŸ“‹ Copy SQL", variant="secondary")
168
  rate_up = gr.Button("πŸ‘", variant="secondary")
169
  rate_down = gr.Button("πŸ‘Ž", variant="secondary")
170
 
@@ -221,7 +219,6 @@ with gr.Blocks(theme='gradio/soft') as demo:
221
 
222
  # When the button is clicked, call the generate function, inputs are taken from the UI elements, outputs are sent to outputs elements
223
  run_button.click(fn=generate, inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty, format_sql, stop_sequence, log], outputs=output_box, api_name="txt2sql")
224
- copy_button.click(fn=copy_to_clipboard, inputs=[output_box])
225
  clear_button.add([input_text, db_info, output_box])
226
 
227
  # Firebase code - for rating the generated SQL (remove if you don't want to use Firebase)
 
5
  from time import sleep
6
  import re
7
  import platform
 
8
  # Additional Firebase imports
9
  import firebase_admin
10
  from firebase_admin import credentials, firestore
 
163
  output_box = gr.Code(label="Generated SQL", lines=2, interactive=False)
164
 
165
  with gr.Row():
 
166
  rate_up = gr.Button("πŸ‘", variant="secondary")
167
  rate_down = gr.Button("πŸ‘Ž", variant="secondary")
168
 
 
219
 
220
  # When the button is clicked, call the generate function, inputs are taken from the UI elements, outputs are sent to outputs elements
221
  run_button.click(fn=generate, inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty, format_sql, stop_sequence, log], outputs=output_box, api_name="txt2sql")
 
222
  clear_button.add([input_text, db_info, output_box])
223
 
224
  # Firebase code - for rating the generated SQL (remove if you don't want to use Firebase)
requirements.txt CHANGED
@@ -8,5 +8,4 @@ scipy
8
  transformers
9
  accelerate
10
  sqlparse
11
- firebase_admin
12
- pyperclip
 
8
  transformers
9
  accelerate
10
  sqlparse
11
+ firebase_admin
 
test.py DELETED
@@ -1,74 +0,0 @@
1
- import gradio as gr
2
-
3
- def bot(input_message: str, db_info="", temperature=0.1, top_p=0.9, top_k=0, repetition_penalty=1.08, format_sql=True, stop_sequence="Explanation,Note", log=True):
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
- # Gradio UI Code
10
- with gr.Blocks(theme='gradio/soft') as demo:
11
- # Elements stack vertically by default just define elements in order you want them to stack
12
- header = gr.HTML("""
13
- <h1 style="text-align: center">SQL Skeleton WizardCoder Demo</h1>
14
- <h3 style="text-align: center">πŸ•·οΈβ˜ οΈπŸ§™β€β™‚οΈ Generate SQL queries from Natural Language πŸ•·οΈβ˜ οΈπŸ§™β€β™‚οΈ</h3>
15
- """)
16
-
17
- output_box = gr.Code(label="Generated SQL", lines=2, interactive=True)
18
- note = gr.HTML("""<p style="font-size: 12px; text-align: center">⚠️ Should take 30-60s to generate</p>""")
19
- input_text = gr.Textbox(lines=3, placeholder='Write your question here...', label='NL Input')
20
- db_info = gr.Textbox(lines=4, placeholder='Example: | table_01 : column_01 , column_02 | table_02 : column_01 , column_02 | ...', label='Database Info')
21
- format_sql = gr.Checkbox(label="Format SQL + Remove Skeleton", value=True, interactive=True)
22
-
23
- # Generate button UI element
24
- run_button = gr.Button("Generate SQL", variant="primary")
25
-
26
- with gr.Accordion("Options", open=False):
27
- temperature = gr.Slider(label="Temperature", minimum=0.0, maximum=1.0, value=0.2, step=0.1)
28
- top_p = gr.Slider(label="Top-p (nucleus sampling)", minimum=0.0, maximum=1.0, value=0.9, step=0.01)
29
- top_k = gr.Slider(label="Top-k", minimum=0, maximum=200, value=0, step=1)
30
- repetition_penalty = gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, value=1.08, step=0.01)
31
- stop_sequence = gr.Textbox(lines=1, value="Explanation,Note", label='Extra Stop Sequence')
32
-
33
- ## Add statement saying that inputs/outpus are sent to firebase
34
- info = gr.HTML(f"""
35
- <p>🌐 Leveraging the <a href='https://huggingface.co/{quantized_model}'><strong>4-bit GGML version</strong></a> of <a href='https://huggingface.co/{merged_model}'><strong>{merged_model}</strong></a> model.</p>
36
- <p>πŸ”— How it's made: <a href='https://huggingface.co/{initial_model}'><strong>{initial_model}</strong></a> was finetuned to create <a href='https://huggingface.co/{lora_model}'><strong>{lora_model}</strong></a>, then merged together to create <a href='https://huggingface.co/{merged_model}'><strong>{merged_model}</strong></a>.</p>
37
- <p>πŸ“‰ Fine-tuning was performed using QLoRA techniques on the <a href='https://huggingface.co/datasets/{dataset}'><strong>{dataset}</strong></a> dataset. You can view training metrics on the <a href='https://huggingface.co/{lora_model}'><strong>QLoRa adapter HF Repo</strong></a>.</p>
38
- <p>πŸ“Š All inputs/outputs are logged to Firebase to see how the model is doing.</a></p>
39
- """)
40
-
41
- examples = gr.Examples([
42
- ["What is the average, minimum, and maximum age of all singers from France?", "| 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 |"],
43
- ["How many students have dogs?", "| student : stuid , lname , fname , age , sex , major , advisor , city_code | has_pet : stuid , petid | pets : petid , pettype , pet_age , weight | has_pet.stuid = student.stuid | has_pet.petid = pets.petid | pets.pettype = 'Dog' |"],
44
- ], inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty, format_sql, stop_sequence], fn=generate, cache_examples=False if platform.system() == "Windows" or platform.system() == "Darwin" else True, outputs=output_box)
45
-
46
- with gr.Accordion("More Examples", open=False):
47
- examples = gr.Examples([
48
- ["What is the average weight of pets of all students?", "| student : stuid , lname , fname , age , sex , major , advisor , city_code | has_pet : stuid , petid | pets : petid , pettype , pet_age , weight | has_pet.stuid = student.stuid | has_pet.petid = pets.petid |"],
49
- ["How many male singers performed in concerts in the year 2023?", "| 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 |"],
50
- ["For students who have pets, how many pets does each student have? List their ids instead of names.", "| student : stuid , lname , fname , age , sex , major , advisor , city_code | has_pet : stuid , petid | pets : petid , pettype , pet_age , weight | has_pet.stuid = student.stuid | has_pet.petid = pets.petid |"],
51
- ["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 |"],
52
- ["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 |"],
53
- ["Which student has the oldest pet?", "| student : stuid , lname , fname , age , sex , major , advisor , city_code | has_pet : stuid , petid | pets : petid , pettype , pet_age , weight | has_pet.stuid = student.stuid | has_pet.petid = pets.petid |"],
54
- ["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 |"],
55
- ["List all students who don't have pets.", "| student : stuid , lname , fname , age , sex , major , advisor , city_code | has_pet : stuid , petid | pets : petid , pettype , pet_age , weight | has_pet.stuid = student.stuid | has_pet.petid = pets.petid |"],
56
- ], inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty, format_sql, stop_sequence], fn=bot, cache_examples=False, outputs=output_box)
57
-
58
-
59
- readme_content = requests.get(f"https://huggingface.co/{merged_model}/raw/main/README.md").text
60
- readme_content = re.sub('---.*?---', '', readme_content, flags=re.DOTALL) #Remove YAML front matter
61
-
62
- with gr.Accordion("πŸ“– Model Readme", open=True):
63
- readme = gr.Markdown(
64
- readme_content,
65
- )
66
-
67
- with gr.Accordion("More Options:", open=False):
68
- log = gr.Checkbox(label="Log to Firebase", value=True, interactive=True)
69
-
70
- # When the button is clicked, call the generate function, inputs are taken from the UI elements, outputs are sent to outputs elements
71
- run_button.click(fn=bot, inputs=[input_text, db_info, temperature, top_p, top_k, repetition_penalty, format_sql, stop_sequence, log], outputs=output_box, api_name="txt2sql")
72
-
73
-
74
- demo.queue(concurrency_count=1, max_size=20).launch(debug=True)