asoria HF staff commited on
Commit
ab6348d
·
1 Parent(s): d97974e

Change UI layout

Browse files
Files changed (1) hide show
  1. app.py +51 -52
app.py CHANGED
@@ -22,12 +22,9 @@ from nbconvert import HTMLExporter
22
  load_dotenv()
23
 
24
  HF_TOKEN = os.getenv("HF_TOKEN")
25
- NOTEBOOKS_REPOSITORY = os.getenv("NOTEBOOKS_REPOSITORY")
26
  assert HF_TOKEN is not None, "You need to set HF_TOKEN in your environment variables"
27
- assert (
28
- NOTEBOOKS_REPOSITORY is not None
29
- ), "You need to set NOTEBOOKS_REPOSITORY in your environment variables"
30
 
 
31
 
32
  BASE_DATASETS_SERVER_URL = "https://datasets-server.huggingface.co"
33
  HEADERS = {"Accept": "application/json", "Content-Type": "application/json"}
@@ -208,41 +205,40 @@ with gr.Blocks(
208
  css=css,
209
  ) as demo:
210
  gr.Markdown("# 🤖 Dataset notebook creator 🕵️")
211
- with gr.Row(equal_height=True):
212
- with gr.Column(scale=2):
213
- text_input = gr.Textbox(label="Suggested notebook type", visible=False)
214
-
215
- dataset_name = HuggingfaceHubSearch(
216
- label="Hub Dataset ID",
217
- placeholder="Search for dataset id on Huggingface",
218
- search_type="dataset",
219
- value="",
220
- )
221
-
222
- dataset_samples = gr.Examples(
223
- examples=[
224
- [
225
- "scikit-learn/iris",
226
- "Try this dataset for Exploratory Data Analysis",
227
- ],
228
- [
229
- "infinite-dataset-hub/GlobaleCuisineRecipes",
230
- "Try this dataset for Embeddings generation",
231
- ],
232
- [
233
- "infinite-dataset-hub/GlobalBestSellersSummaries",
234
- "Try this dataset for RAG generation",
235
- ],
236
- ],
237
- inputs=[dataset_name, text_input],
238
- cache_examples=False,
239
- )
240
-
241
- @gr.render(inputs=dataset_name)
242
- def embed(name):
243
- if not name:
244
- return gr.Markdown("### No dataset provided")
245
- html_code = f"""
246
  <iframe
247
  src="https://huggingface.co/datasets/{name}/embed/viewer/default/train"
248
  frameborder="0"
@@ -250,19 +246,22 @@ with gr.Blocks(
250
  height="350px"
251
  ></iframe>
252
  """
253
- return gr.HTML(value=html_code, elem_classes="viewer")
254
-
255
- with gr.Row():
256
- generate_eda_btn = gr.Button("Exploratory Data Analysis")
257
- generate_embedding_btn = gr.Button("Embeddings")
258
- generate_rag_btn = gr.Button("RAG")
259
- generate_training_btn = gr.Button(
260
- "Training - Coming soon", interactive=False
261
- )
262
-
263
- with gr.Column(scale=2):
264
- code_component = gr.HTML(elem_id="box")
265
- go_to_notebook = gr.Markdown("", visible=True)
 
 
 
266
 
267
  generate_eda_btn.click(
268
  generate_eda_cells,
 
22
  load_dotenv()
23
 
24
  HF_TOKEN = os.getenv("HF_TOKEN")
 
25
  assert HF_TOKEN is not None, "You need to set HF_TOKEN in your environment variables"
 
 
 
26
 
27
+ NOTEBOOKS_REPOSITORY = "asoria/dataset-notebook-creator-content"
28
 
29
  BASE_DATASETS_SERVER_URL = "https://datasets-server.huggingface.co"
30
  HEADERS = {"Accept": "application/json", "Content-Type": "application/json"}
 
205
  css=css,
206
  ) as demo:
207
  gr.Markdown("# 🤖 Dataset notebook creator 🕵️")
208
+ text_input = gr.Textbox(label="Suggested notebook type", visible=False)
209
+
210
+ gr.Markdown("## 1. Select and preview a dataset from Huggingface Hub")
211
+ dataset_name = HuggingfaceHubSearch(
212
+ label="Hub Dataset ID",
213
+ placeholder="Search for dataset id on Huggingface",
214
+ search_type="dataset",
215
+ value="",
216
+ )
217
+
218
+ dataset_samples = gr.Examples(
219
+ examples=[
220
+ [
221
+ "scikit-learn/iris",
222
+ "Try this dataset for Exploratory Data Analysis",
223
+ ],
224
+ [
225
+ "infinite-dataset-hub/GlobaleCuisineRecipes",
226
+ "Try this dataset for Embeddings generation",
227
+ ],
228
+ [
229
+ "infinite-dataset-hub/GlobalBestSellersSummaries",
230
+ "Try this dataset for RAG generation",
231
+ ],
232
+ ],
233
+ inputs=[dataset_name, text_input],
234
+ cache_examples=False,
235
+ )
236
+
237
+ @gr.render(inputs=dataset_name)
238
+ def embed(name):
239
+ if not name:
240
+ return gr.Markdown("### No dataset provided")
241
+ html_code = f"""
 
242
  <iframe
243
  src="https://huggingface.co/datasets/{name}/embed/viewer/default/train"
244
  frameborder="0"
 
246
  height="350px"
247
  ></iframe>
248
  """
249
+ return gr.HTML(value=html_code, elem_classes="viewer")
250
+
251
+ gr.Markdown("## 2. Select the type of notebook you want to generate")
252
+ with gr.Row():
253
+ with gr.Column():
254
+ generate_eda_btn = gr.Button("EDA", size="sm")
255
+ with gr.Column():
256
+ generate_embedding_btn = gr.Button("Embeddings", size="sm")
257
+ with gr.Column():
258
+ generate_rag_btn = gr.Button("RAG", size="sm")
259
+ with gr.Column():
260
+ generate_training_btn = gr.Button("Training", interactive=False, size="sm")
261
+
262
+ gr.Markdown("## 3. Notebook code result")
263
+ code_component = gr.HTML(elem_id="box")
264
+ go_to_notebook = gr.Markdown("", visible=True)
265
 
266
  generate_eda_btn.click(
267
  generate_eda_cells,