Spaces:
Running
Running
Updated layout.
Browse files- app/gradio_sample_generator.py +100 -96
app/gradio_sample_generator.py
CHANGED
@@ -177,105 +177,109 @@ with gr.Blocks(title="Task Description Generator") as demo:
|
|
177 |
"Enter a JSON object with 'input' and 'output' fields to generate a task description and additional examples."
|
178 |
)
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
with gr.Row():
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
label="Model Name",
|
195 |
-
choices=[
|
196 |
-
"llama3-70b-8192",
|
197 |
-
"llama3-8b-8192",
|
198 |
-
"llama-3.1-70b-versatile",
|
199 |
-
"llama-3.1-8b-instant",
|
200 |
-
"gemma2-9b-it",
|
201 |
-
],
|
202 |
-
value="llama3-70b-8192",
|
203 |
-
)
|
204 |
-
temperature = gr.Slider(
|
205 |
-
label="Temperature", value=1.0, minimum=0.0, maximum=1.0, step=0.1
|
206 |
-
)
|
207 |
-
generating_batch_size = gr.Slider(
|
208 |
-
label="Generating Batch Size", value=3, minimum=1, maximum=10, step=1
|
209 |
-
)
|
210 |
-
with gr.Row():
|
211 |
-
submit_button = gr.Button("Generate", variant="primary")
|
212 |
-
generate_description_button = gr.Button(
|
213 |
-
"Generate Description", variant="secondary"
|
214 |
-
)
|
215 |
-
|
216 |
-
with gr.Column(scale=1): # Outputs column
|
217 |
-
description_output = gr.Textbox(
|
218 |
-
label="Description", lines=5, show_copy_button=True
|
219 |
-
)
|
220 |
-
with gr.Row():
|
221 |
-
generate_examples_directly_button = gr.Button(
|
222 |
-
"Generate Examples Directly", variant="secondary"
|
223 |
-
)
|
224 |
-
analyze_input_button = gr.Button(
|
225 |
-
"Analyze Input", variant="secondary"
|
226 |
-
)
|
227 |
-
examples_directly_output = gr.DataFrame(
|
228 |
-
label="Examples Directly",
|
229 |
-
headers=["Input", "Output"],
|
230 |
-
interactive=False,
|
231 |
-
datatype=["str", "str"],
|
232 |
-
row_count=(1, "dynamic"),
|
233 |
-
col_count=(2, "fixed"),
|
234 |
-
)
|
235 |
-
input_analysis_output = gr.Textbox(
|
236 |
-
label="Input Analysis", lines=5, show_copy_button=True
|
237 |
-
)
|
238 |
-
generate_briefs_button = gr.Button(
|
239 |
-
"Generate Briefs", variant="secondary"
|
240 |
-
)
|
241 |
-
example_briefs_output = gr.Textbox(
|
242 |
-
label="Example Briefs", lines=5, show_copy_button=True
|
243 |
-
)
|
244 |
-
generate_examples_from_briefs_button = gr.Button(
|
245 |
-
"Generate Examples from Briefs", variant="secondary"
|
246 |
-
)
|
247 |
-
examples_from_briefs_output = gr.DataFrame(
|
248 |
-
label="Examples from Briefs",
|
249 |
-
headers=["Input", "Output"],
|
250 |
-
interactive=False,
|
251 |
-
datatype=["str", "str"],
|
252 |
-
row_count=(1, "dynamic"),
|
253 |
-
col_count=(2, "fixed"),
|
254 |
-
)
|
255 |
-
examples_output = gr.DataFrame(
|
256 |
-
label="Examples",
|
257 |
-
headers=["Input", "Output"],
|
258 |
-
interactive=False,
|
259 |
-
datatype=["str", "str"],
|
260 |
-
row_count=(1, "dynamic"),
|
261 |
-
col_count=(2, "fixed"),
|
262 |
-
)
|
263 |
-
new_example_json = gr.Textbox(
|
264 |
-
label="New Example JSON", lines=5, show_copy_button=True
|
265 |
)
|
266 |
-
|
267 |
-
|
268 |
-
clear_button = gr.ClearButton(
|
269 |
-
[
|
270 |
-
input_df,
|
271 |
-
description_output,
|
272 |
-
input_analysis_output,
|
273 |
-
example_briefs_output,
|
274 |
-
examples_from_briefs_output,
|
275 |
-
examples_output,
|
276 |
-
new_example_json,
|
277 |
-
]
|
278 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
|
280 |
json_file.change(
|
281 |
fn=import_json,
|
|
|
177 |
"Enter a JSON object with 'input' and 'output' fields to generate a task description and additional examples."
|
178 |
)
|
179 |
|
180 |
+
|
181 |
+
input_df = gr.DataFrame(
|
182 |
+
label="Input Examples",
|
183 |
+
headers=["Input", "Output"],
|
184 |
+
datatype=["str", "str"],
|
185 |
+
row_count=(1, "dynamic"),
|
186 |
+
col_count=(2, "fixed"),
|
187 |
+
)
|
188 |
+
with gr.Accordion("Import/Export JSON", open=False):
|
189 |
+
json_file = gr.File(
|
190 |
+
label="Import/Export JSON", file_types=[".json"], type="filepath"
|
191 |
+
)
|
192 |
+
export_button = gr.Button("Export to JSON")
|
193 |
+
|
194 |
+
with gr.Accordion("Model Settings", open=False):
|
195 |
+
model_name = gr.Dropdown(
|
196 |
+
label="Model Name",
|
197 |
+
choices=[
|
198 |
+
"llama3-70b-8192",
|
199 |
+
"llama3-8b-8192",
|
200 |
+
"llama-3.1-70b-versatile",
|
201 |
+
"llama-3.1-8b-instant",
|
202 |
+
"gemma2-9b-it",
|
203 |
+
],
|
204 |
+
value="llama3-70b-8192",
|
205 |
+
)
|
206 |
+
temperature = gr.Slider(
|
207 |
+
label="Temperature", value=1.0, minimum=0.0, maximum=1.0, step=0.1
|
208 |
+
)
|
209 |
+
generating_batch_size = gr.Slider(
|
210 |
+
label="Generating Batch Size", value=3, minimum=1, maximum=10, step=1
|
211 |
+
)
|
212 |
with gr.Row():
|
213 |
+
submit_button = gr.Button("Generate", variant="primary")
|
214 |
+
generate_description_button = gr.Button(
|
215 |
+
"Generate Description", variant="secondary"
|
216 |
+
)
|
217 |
+
|
218 |
+
|
219 |
+
with gr.Accordion("Description and Analysis", open=False):
|
220 |
+
description_output = gr.Textbox(
|
221 |
+
label="Description", lines=5, show_copy_button=True
|
222 |
+
)
|
223 |
+
with gr.Row():
|
224 |
+
generate_examples_directly_button = gr.Button(
|
225 |
+
"Generate Examples Directly", variant="secondary"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
)
|
227 |
+
analyze_input_button = gr.Button(
|
228 |
+
"Analyze Input", variant="secondary"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
)
|
230 |
+
examples_directly_output = gr.DataFrame(
|
231 |
+
label="Examples Directly",
|
232 |
+
headers=["Input", "Output"],
|
233 |
+
interactive=False,
|
234 |
+
datatype=["str", "str"],
|
235 |
+
row_count=(1, "dynamic"),
|
236 |
+
col_count=(2, "fixed"),
|
237 |
+
)
|
238 |
+
input_analysis_output = gr.Textbox(
|
239 |
+
label="Input Analysis", lines=5, show_copy_button=True
|
240 |
+
)
|
241 |
+
with gr.Accordion("Briefs and Examples", open=False):
|
242 |
+
generate_briefs_button = gr.Button(
|
243 |
+
"Generate Briefs", variant="secondary"
|
244 |
+
)
|
245 |
+
example_briefs_output = gr.Textbox(
|
246 |
+
label="Example Briefs", lines=5, show_copy_button=True
|
247 |
+
)
|
248 |
+
generate_examples_from_briefs_button = gr.Button(
|
249 |
+
"Generate Examples from Briefs", variant="secondary"
|
250 |
+
)
|
251 |
+
examples_from_briefs_output = gr.DataFrame(
|
252 |
+
label="Examples from Briefs",
|
253 |
+
headers=["Input", "Output"],
|
254 |
+
interactive=False,
|
255 |
+
datatype=["str", "str"],
|
256 |
+
row_count=(1, "dynamic"),
|
257 |
+
col_count=(2, "fixed"),
|
258 |
+
)
|
259 |
+
examples_output = gr.DataFrame(
|
260 |
+
label="Examples",
|
261 |
+
headers=["Input", "Output"],
|
262 |
+
interactive=False,
|
263 |
+
datatype=["str", "str"],
|
264 |
+
row_count=(1, "dynamic"),
|
265 |
+
col_count=(2, "fixed"),
|
266 |
+
)
|
267 |
+
new_example_json = gr.Textbox(
|
268 |
+
label="New Example JSON", lines=5, show_copy_button=True
|
269 |
+
)
|
270 |
+
append_example_button = gr.Button("Append to Input Examples", variant="secondary")
|
271 |
+
|
272 |
+
clear_button = gr.ClearButton(
|
273 |
+
[
|
274 |
+
input_df,
|
275 |
+
description_output,
|
276 |
+
input_analysis_output,
|
277 |
+
example_briefs_output,
|
278 |
+
examples_from_briefs_output,
|
279 |
+
examples_output,
|
280 |
+
new_example_json,
|
281 |
+
]
|
282 |
+
)
|
283 |
|
284 |
json_file.change(
|
285 |
fn=import_json,
|