menouar commited on
Commit
f80172c
·
1 Parent(s): d898977

Fixing Preview

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. utils/notebook_generator.py +4 -4
app.py CHANGED
@@ -95,6 +95,7 @@ def preview_notebook():
95
  html_path = f"{finetuning_notebook}.html"
96
  with open(html_path, 'w') as f:
97
  f.write(body)
 
98
  return f'<iframe src="file={html_path}" width="100%" height="250px"></iframe>'
99
 
100
 
@@ -158,7 +159,6 @@ def generate_code(components: dict[Component, Any]):
158
 
159
  report_to = get_value(components, REPORT_TO_ID)
160
 
161
- gr.Warning(f"{output_dir}")
162
  if not check_valid_input(output_dir):
163
  gr.Warning("No output_dir is given")
164
 
@@ -190,7 +190,7 @@ def generate_code(components: dict[Component, Any]):
190
 
191
  return gr.Button(
192
  visible=True), f'''<div class="a_custom"><a href="file={file_name}" download={file_name}>
193
- 💾️ Download {finetuning_notebook}.ipynb</a> </div> '''
194
 
195
 
196
  with gr.Blocks(css=css, theme=gr.themes.Soft(text_size='lg', font=["monospace"],
@@ -290,7 +290,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(text_size='lg', font=["monospace"],
290
  preview_btn = gr.Button(f"👀 Preview {finetuning_notebook}.ipynb", variant="primary", visible=False)
291
  download_btn = gr.HTML(show_label=False, visible=True)
292
 
293
- greet_btn.click(fn=generate_code, inputs=all_components, outputs=[preview_btn, download_btn])
294
 
295
  preview_btn.click(fn=preview_notebook, inputs=None, outputs=iframe)
296
 
 
95
  html_path = f"{finetuning_notebook}.html"
96
  with open(html_path, 'w') as f:
97
  f.write(body)
98
+
99
  return f'<iframe src="file={html_path}" width="100%" height="250px"></iframe>'
100
 
101
 
 
159
 
160
  report_to = get_value(components, REPORT_TO_ID)
161
 
 
162
  if not check_valid_input(output_dir):
163
  gr.Warning("No output_dir is given")
164
 
 
190
 
191
  return gr.Button(
192
  visible=True), f'''<div class="a_custom"><a href="file={file_name}" download={file_name}>
193
+ 💾️ Download {finetuning_notebook}.ipynb</a> </div> ''', "<div></div>"
194
 
195
 
196
  with gr.Blocks(css=css, theme=gr.themes.Soft(text_size='lg', font=["monospace"],
 
290
  preview_btn = gr.Button(f"👀 Preview {finetuning_notebook}.ipynb", variant="primary", visible=False)
291
  download_btn = gr.HTML(show_label=False, visible=True)
292
 
293
+ greet_btn.click(fn=generate_code, inputs=all_components, outputs=[preview_btn, download_btn, iframe])
294
 
295
  preview_btn.click(fn=preview_notebook, inputs=None, outputs=iframe)
296
 
utils/notebook_generator.py CHANGED
@@ -87,10 +87,10 @@ def create_datasets_cells(cells: list, dataset: FTDataSet, seed: int):
87
  **Conversational format:**
88
 
89
 
90
- ```python {"messages": [{"role": "system", "content": "You are..."}, {"role": "user", "content": "..."},
91
- {"role": "assistant", "content": "..."}]} {"messages": [{"role": "system", "content": "You are..."}, {"role": "user",
92
- "content": "..."}, {"role": "assistant", "content": "..."}]} {"messages": [{"role": "system", "content": "You
93
- are..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]} """
94
  text_cell1 = nbf.v4.new_markdown_cell(text)
95
  text_cell2 = nbf.v4.new_markdown_cell(text_format)
96
  code = f"""
 
87
  **Conversational format:**
88
 
89
 
90
+ ```python{"messages": [{"role": "system", "content": "You are..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}
91
+ {"messages": [{"role": "system", "content": "You are..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}
92
+ {"messages": [{"role": "system", "content": "You are..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}
93
+ """
94
  text_cell1 = nbf.v4.new_markdown_cell(text)
95
  text_cell2 = nbf.v4.new_markdown_cell(text_format)
96
  code = f"""