davidberenstein1957 HF staff commited on
Commit
8f8b860
β€’
1 Parent(s): 2377601

feat: warning when no dataset is selected

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -16,6 +16,8 @@ client = InferenceClient(
16
 
17
 
18
  def get_iframe(hub_repo_id, sql_query=None):
 
 
19
  if sql_query:
20
  sql_query = urllib.parse.quote(sql_query)
21
  url = f"https://huggingface.co/datasets/{hub_repo_id}/embed/viewer?sql_console=true&sql={sql_query}"
@@ -97,7 +99,7 @@ with gr.Blocks() as demo:
97
  placeholder="Enter a natural language query to generate SQL",
98
  )
99
  with gr.Row():
100
- sql_out = gr.Code(label="SQL Query")
101
  with gr.Row():
102
  btn2 = gr.Button("Query Dataset")
103
 
@@ -116,7 +118,7 @@ with gr.Blocks() as demo:
116
  fn=query_dataset,
117
  inputs=[search_in, features, query],
118
  outputs=[sql_out, search_out],
119
- )
120
 
121
  if __name__ == "__main__":
122
  demo.launch()
 
16
 
17
 
18
  def get_iframe(hub_repo_id, sql_query=None):
19
+ if not hub_repo_id:
20
+ raise ValueError("Hub repo id is required")
21
  if sql_query:
22
  sql_query = urllib.parse.quote(sql_query)
23
  url = f"https://huggingface.co/datasets/{hub_repo_id}/embed/viewer?sql_console=true&sql={sql_query}"
 
99
  placeholder="Enter a natural language query to generate SQL",
100
  )
101
  with gr.Row():
102
+ sql_out = gr.Code(label="SQL Query", interactive=True, language="sql", lines=1)
103
  with gr.Row():
104
  btn2 = gr.Button("Query Dataset")
105
 
 
118
  fn=query_dataset,
119
  inputs=[search_in, features, query],
120
  outputs=[sql_out, search_out],
121
+ )z
122
 
123
  if __name__ == "__main__":
124
  demo.launch()