Spaces:
Sleeping
Sleeping
augray
commited on
Commit
•
a46b4c4
1
Parent(s):
ca78baa
dynamic render
Browse files
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 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
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 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
)
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
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()
|