Commit
·
f2d5c0f
1
Parent(s):
ebca1a4
code generation samples demo
Browse files- .gitattributes +2 -0
- demo.py +56 -0
- problems.json +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
problems.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
all_outputs.json filter=lfs diff=lfs merge=lfs -text
|
demo.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
with open('problems.json') as f:
|
| 7 |
+
problems = json.load(f)
|
| 8 |
+
problem_choices = [q['question_title'] for q in problems]
|
| 9 |
+
|
| 10 |
+
with open('all_outputs.json') as f:
|
| 11 |
+
all_outputs = json.load(f)
|
| 12 |
+
model_choices = list(all_outputs.keys())
|
| 13 |
+
|
| 14 |
+
def update_view(problem_index, model_name):
|
| 15 |
+
code = all_outputs[model_name][problem_index]['code_list'][0]
|
| 16 |
+
|
| 17 |
+
code_viewer = gr.Code(
|
| 18 |
+
label=f"Code for Model {model_name} on {problems[problem_index]['question_title']}",
|
| 19 |
+
language="python",
|
| 20 |
+
lines=10,
|
| 21 |
+
value=code,
|
| 22 |
+
interactive=False,
|
| 23 |
+
)
|
| 24 |
+
return code_viewer
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
with gr.Blocks() as demo:
|
| 29 |
+
## dropdown
|
| 30 |
+
problem_dropdown = gr.Dropdown(
|
| 31 |
+
label="Selected Problem",
|
| 32 |
+
choices=problem_choices,
|
| 33 |
+
value=problem_choices[0],
|
| 34 |
+
type="index"
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
model_dropdown = gr.Dropdown(
|
| 38 |
+
label="Selected Model",
|
| 39 |
+
choices=model_choices,
|
| 40 |
+
value=model_choices[0],
|
| 41 |
+
type="value"
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
code_viewer = (update_view(0, model_choices[0]))
|
| 45 |
+
|
| 46 |
+
problem_dropdown.change(
|
| 47 |
+
update_view,
|
| 48 |
+
inputs=[problem_dropdown, model_dropdown],
|
| 49 |
+
outputs=[code_viewer]
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
## code viewer
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if __name__ == "__main__":
|
| 56 |
+
demo.launch()
|
problems.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:477d1cff3141f8b84e3124c9270260548aa749cc8ce1ba61a7b18626c131ff9b
|
| 3 |
+
size 663137
|