augray commited on
Commit
a46b4c4
1 Parent(s): ca78baa

dynamic render

Browse files
Files changed (1) hide show
  1. app.py +45 -42
app.py CHANGED
@@ -162,49 +162,52 @@ with gr.Blocks() as demo:
162
  Also, it uses the [dataset-server API](https://redocly.github.io/redoc/?url=https://datasets-server.huggingface.co/openapi.json#operation/isValidDataset).
163
  """)
164
  with gr.Row():
165
- with gr.Column():
166
- search_in = HuggingfaceHubSearch(
167
- label="Search Huggingface Hub",
168
- placeholder="Search for models on Huggingface",
169
- search_type="dataset",
170
- sumbit_on_select=True,
171
- )
172
- query = gr.Textbox(
173
- label="Natural Language Query",
174
- placeholder="Enter a natural language query to generate SQL",
175
- )
176
- sql_out = gr.Code(
177
- label="SQL Query",
178
- interactive=True,
179
- language="sql",
180
- lines=1,
181
- visible=False,
182
- )
183
  with gr.Row():
184
- with gr.Column():
185
- btn = gr.Button("Show Dataset")
186
- with gr.Column():
187
- btn2 = gr.Button("Query Dataset")
188
- with gr.Row():
189
- search_out = gr.HTML(label="Search Results")
190
- with gr.Row():
191
- card_data = gr.Code(label="Card data", language="json", visible=False)
192
- gr.on(
193
- [btn.click, search_in.submit],
194
- fn=get_iframe,
195
- inputs=[search_in],
196
- outputs=[search_out],
197
- ).then(
198
- fn=get_table_info,
199
- inputs=[search_in],
200
- outputs=[card_data],
201
- )
202
- gr.on(
203
- [btn2.click, query.submit],
204
- fn=query_dataset,
205
- inputs=[search_in, card_data, query],
206
- outputs=[sql_out, search_out],
207
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
  if __name__ == "__main__":
210
  demo.launch()
 
162
  Also, it uses the [dataset-server API](https://redocly.github.io/redoc/?url=https://datasets-server.huggingface.co/openapi.json#operation/isValidDataset).
163
  """)
164
  with gr.Row():
165
+ search_in = HuggingfaceHubSearch(
166
+ label="Search Huggingface Hub",
167
+ placeholder="Search for models on Huggingface",
168
+ search_type="dataset",
169
+ sumbit_on_select=True,
170
+ )
 
 
 
 
 
 
 
 
 
 
 
 
171
  with gr.Row():
172
+ query = gr.Textbox(
173
+ label="Natural Language Query",
174
+ placeholder="Enter a natural language query to generate SQL",
175
+ )
176
+ sql_out = gr.Code(
177
+ label="DuckDB SQL Query",
178
+ interactive=True,
179
+ language="sql",
180
+ lines=1,
181
+ visible=False,
182
+ )
183
+
184
+ @gr.render(triggers=[search_in.submit])
185
+ def show_config_split_choices():
186
+ with gr.Row():
187
+ with gr.Column():
188
+ btn = gr.Button("Show Dataset")
189
+ with gr.Column():
190
+ btn2 = gr.Button("Query Dataset")
191
+ with gr.Row():
192
+ search_out = gr.HTML(label="Search Results")
193
+ with gr.Row():
194
+ card_data = gr.Code(label="Card data", language="json", visible=False)
195
+ gr.on(
196
+ [btn.click, search_in.submit],
197
+ fn=get_iframe,
198
+ inputs=[search_in],
199
+ outputs=[search_out],
200
+ ).then(
201
+ fn=get_table_info,
202
+ inputs=[search_in],
203
+ outputs=[card_data],
204
+ )
205
+ gr.on(
206
+ [btn2.click, query.submit],
207
+ fn=query_dataset,
208
+ inputs=[search_in, card_data, query],
209
+ outputs=[sql_out, search_out],
210
+ )
211
 
212
  if __name__ == "__main__":
213
  demo.launch()