Files changed (1) hide show
  1. app.py +21 -35
app.py CHANGED
@@ -62,41 +62,27 @@ def main(
62
  generated_text = seq["generated_text"].replace(prompt, "")
63
  return generated_text
64
 
65
- with gr.Blocks(css=css) as demo:
66
- gr.Markdown(title)
67
- gr.Markdown(description)
68
- with gr.Row(equal_height=True):
69
- with gr.Column(variant="default"):
70
- interface_input = gr.Textbox(
71
- lines=3,
72
- label="Instruction",
73
- placeholder="Anything you want to ask Magicoder ?",
74
- value="Write a snake game in Python using the turtle library (the game is created by Magicoder).",
75
- )
76
- temperature = gr.Slider(minimum=0, maximum=1, value=0, label="Temperature")
77
- max_new_tokens = gr.Slider(
78
- minimum=1, maximum=2048, step=1, value=2048, label="Max tokens"
79
- )
80
- submit = gr.Button(value="Generate")
81
- gr.Examples(
82
- examples=[
83
- ["Write a snake game in Python using the turtle library (the game is created by Magicoder)."],
84
- ["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."],
85
- ["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."],
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__":