Spaces:
Sleeping
Sleeping
Update app.py
Browse filesswitched to from a gr.Blocks() to a gr.Interface() layout, and caching examples.
PS: after merging this, it will take a little bit more time to launch because it will run each example and cashe the output , so wait a little bit until it finishes building up.
if you want to disable this behaviour just set up `cache_examples=False`
app.py
CHANGED
@@ -62,41 +62,27 @@ def main(
|
|
62 |
generated_text = seq["generated_text"].replace(prompt, "")
|
63 |
return generated_text
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
["Build a simple neural network in Python using Pytorch to classify handwritten digits from the MNIST dataset. You should use CNN as the model structure, train the model for 5 epochs, draw a chart of the training loss, and show the final result."],
|
87 |
-
],
|
88 |
-
inputs = [interface_input]
|
89 |
-
)
|
90 |
-
with gr.Column(variant="default"):
|
91 |
-
with gr.Tab("Output", elem_id="q-output"):
|
92 |
-
output = gr.Markdown(
|
93 |
-
label="Output"
|
94 |
-
)
|
95 |
-
submit.click(
|
96 |
-
evaluate_magicoder,
|
97 |
-
inputs=[interface_input, temperature, max_new_tokens],
|
98 |
-
outputs=[output],
|
99 |
-
)
|
100 |
demo.queue().launch()
|
101 |
|
102 |
if __name__ == "__main__":
|
|
|
62 |
generated_text = seq["generated_text"].replace(prompt, "")
|
63 |
return generated_text
|
64 |
|
65 |
+
# componenents
|
66 |
+
interface_input = gr.Textbox(
|
67 |
+
lines=3,
|
68 |
+
label="Instruction",
|
69 |
+
placeholder="Anything you want to ask Magicoder ?",
|
70 |
+
value="Write a snake game in Python using the turtle library (the game is created by Magicoder).",
|
71 |
+
)
|
72 |
+
|
73 |
+
temperature = gr.Slider(minimum=0, maximum=1, value=0, label="Temperature")
|
74 |
+
max_new_tokens = gr.Slider(
|
75 |
+
minimum=1, maximum=2048, step=1, value=2048, label="Max tokens"
|
76 |
+
)
|
77 |
+
output = gr.Markdown(label="Output")
|
78 |
+
examples = [
|
79 |
+
["Write a snake game in Python using the turtle library (the game is created by Magicoder).",0,2048],
|
80 |
+
["Build a console-based Othello game in Java with row and column numbers shown on the board. The game should end when there are no more valid moves for either player.",0,2048],
|
81 |
+
["Write a gradio (3.48.0) application for the following use case: Take an input image and return a 45 degree clockwise rotated image. You should also add text description under the output showing the rotation degree.",0,2048],
|
82 |
+
["Build a simple neural network in Python using Pytorch to classify handwritten digits from the MNIST dataset. You should use CNN as the model structure, train the model for 5 epochs, draw a chart of the training loss, and show the final result.",0,2048],
|
83 |
+
]
|
84 |
+
# interface
|
85 |
+
demo = gr.Interface(evaluate_magicoder,inputs = [interface_input,temperature,max_new_tokens],outputs=[output],examples = examples,cache_examples=True,title=title,description=description,css=css)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
demo.queue().launch()
|
87 |
|
88 |
if __name__ == "__main__":
|