burhan112 commited on
Commit
fc2bdb8
·
verified ·
1 Parent(s): 4d5ef83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -20
app.py CHANGED
@@ -170,26 +170,17 @@ def respond(message, history, max_tokens):
170
  for response in generate_pseudocode(message, max_tokens):
171
  yield response
172
 
173
- # Gradio UI setup with Blocks
174
- with gr.Blocks(title="C++ to Pseudocode Transformer") as demo:
175
- gr.Markdown("## C++ to Pseudocode Converter")
176
- gr.Markdown("Enter C++ code below and press Submit to generate pseudocode.")
177
- cpp_input = gr.Textbox(
178
- label="C++ Code",
179
- placeholder="e.g., 'int x = 5; for(int i=0; i<x; i++) cout << i;'",
180
- lines=5
181
- )
182
- submit_btn = gr.Button("Submit", variant="primary")
183
- pseudocode_output = gr.Textbox(
184
- label="Generated Pseudocode",
185
- lines=5
186
- )
187
-
188
- submit_btn.click(
189
- fn=respond,
190
- inputs=[cpp_input, gr.State(value=[]), gr.Slider(minimum=10, maximum=1000, value=50, step=1, visible=False)],
191
- outputs=pseudocode_output
192
- )
193
 
194
  if __name__ == "__main__":
195
  demo.launch()
 
170
  for response in generate_pseudocode(message, max_tokens):
171
  yield response
172
 
173
+ # Gradio interface
174
+ demo = gr.ChatInterface(
175
+ respond,
176
+ chatbot=gr.Chatbot(label="C++ to Pseudocode Generator"),
177
+ textbox=gr.Textbox(placeholder="Enter C++ code (e.g., 'int x = 5; for(int i=0; i<x; i++) cout << i;')", label="C++ Code"),
178
+ additional_inputs=[
179
+ gr.Slider(minimum=10, maximum=1000, value=50, step=1, label="Max tokens"),
180
+ ],
181
+ title="C++ to Pseudocode Transformer",
182
+ description="Convert C++ code to pseudocode using a custom transformer trained on the SPoC dataset.",
183
+ )
 
 
 
 
 
 
 
 
 
184
 
185
  if __name__ == "__main__":
186
  demo.launch()