Vipitis commited on
Commit
9f8916a
1 Parent(s): 3c0111d

fix dropdown after generation

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +9 -6
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *.pyc
app.py CHANGED
@@ -510,7 +510,7 @@ def alter_body(old_code, func_id, funcs_list: list, temperature, max_new_tokens,
510
  print(f"{generated_body=}")
511
  altered_code = old_code[:func_start_idx] + identifier_str + generated_body + old_code[body_end_idx:]
512
  print(f"{altered_code=}") #we get here successfully
513
- yield altered_code, pipeline #yield once so it updates? -> works... gg
514
  return altered_code, pipeline #never gets used by the code block? maybe I need to yield it first? but works in the ov_notebook
515
 
516
  def add_history(func_id, orig_rtn, gened_rtn, history):
@@ -588,7 +588,7 @@ with gr.Blocks() as site:
588
  bot_md = gr.Markdown(outro_text)
589
  sample_pass = gr.State(value={})
590
  pipe = gr.State(value=PIPE)
591
- pipe.value=_make_pipeline("Vipitis/santacoder-finetuned-Shadertoys-fine") # set a default like this?
592
  funcs = gr.State(value=[])
593
  # funcs.value.append(list_dropdown(sample_code.value)[0]) #to circumvent the json issue?
594
  # hist_state = gr.State(Value={})
@@ -597,7 +597,10 @@ with gr.Blocks() as site:
597
  model_cp.submit(fn=_make_pipeline, inputs=[model_cp], outputs=[pipe]) # how can we trigger this on load?
598
  sample_idx.release(fn=grab_sample, inputs=[sample_idx], outputs=[sample_pass, sample_code, source_embed])
599
  gen_return_button.click(fn=alter_return, inputs=[sample_code, func_dropdown, pipe], outputs=[sample_code])
600
- gen_func_button.click(fn=alter_body, inputs=[sample_code, func_dropdown, funcs, temperature, max_new_tokens, top_p, repetition_penalty, pipe], outputs=[sample_code, pipe])
601
- sample_code.change(fn=list_dropdown, inputs=[sample_code], outputs=[funcs, func_dropdown]) # to update this after generation, so spans aren't messed up
602
- sample_code.change(fn=make_iframe, inputs=[sample_code], outputs=[our_embed]) #twice could cause issues, find better ways.
603
- site.launch(enable_queue=True)
 
 
 
 
510
  print(f"{generated_body=}")
511
  altered_code = old_code[:func_start_idx] + identifier_str + generated_body + old_code[body_end_idx:]
512
  print(f"{altered_code=}") #we get here successfully
513
+ yield altered_code, pipeline #yield once so it updates? -> works... gg but doesn't seem to do it for the dropdown
514
  return altered_code, pipeline #never gets used by the code block? maybe I need to yield it first? but works in the ov_notebook
515
 
516
  def add_history(func_id, orig_rtn, gened_rtn, history):
 
588
  bot_md = gr.Markdown(outro_text)
589
  sample_pass = gr.State(value={})
590
  pipe = gr.State(value=PIPE)
591
+ pipe.value=_make_pipeline("Vipitis/santacoder-finetuned-Shadertoys-fine") # set a default like this?
592
  funcs = gr.State(value=[])
593
  # funcs.value.append(list_dropdown(sample_code.value)[0]) #to circumvent the json issue?
594
  # hist_state = gr.State(Value={})
 
597
  model_cp.submit(fn=_make_pipeline, inputs=[model_cp], outputs=[pipe]) # how can we trigger this on load?
598
  sample_idx.release(fn=grab_sample, inputs=[sample_idx], outputs=[sample_pass, sample_code, source_embed])
599
  gen_return_button.click(fn=alter_return, inputs=[sample_code, func_dropdown, pipe], outputs=[sample_code])
600
+ gen_func_button.click(fn=alter_body, inputs=[sample_code, func_dropdown, funcs, temperature, max_new_tokens, top_p, repetition_penalty, pipe], outputs=[sample_code, pipe]).then(
601
+ fn=list_dropdown, inputs=[sample_code], outputs=[funcs, func_dropdown]
602
+ )
603
+ sample_code.change(fn=list_dropdown, inputs=[sample_code], outputs=[funcs, func_dropdown]).then(
604
+ fn=make_iframe, inputs=[sample_code], outputs=[our_embed])
605
+ site.queue()
606
+ site.launch()