sugiv commited on
Commit
ffa439c
·
1 Parent(s): 771bde2

Gosh this Leetmonkey

Browse files
Files changed (1) hide show
  1. app.py +42 -13
app.py CHANGED
@@ -168,23 +168,52 @@ def api_random_problem(token: str) -> Dict[str, Any]:
168
 
169
  return {"problem": select_random_problem()}
170
 
171
- # Gradio interface
172
- iface = gr.Interface(
173
- fn=[api_generate_solution, api_stream_solution, api_explain_solution, api_random_problem],
174
  inputs=[
175
- gr.Textbox(label="LeetCode Problem"),
176
  gr.Textbox(label="JWT Token")
177
  ],
178
- outputs=[
179
- gr.JSON(label="Generated Solution"),
180
- gr.JSON(label="Streamed Solution"),
181
- gr.JSON(label="Explanation"),
182
- gr.JSON(label="Random Problem")
 
 
 
 
 
183
  ],
184
- title="LeetCode Problem Solver API",
185
- description="Provide a LeetCode problem instruction and a valid JWT token to generate a solution, get an explanation, or retrieve a random problem."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  )
187
 
188
  if __name__ == "__main__":
189
- logger.info("Starting Gradio API")
190
- iface.launch(share=True)
 
168
 
169
  return {"problem": select_random_problem()}
170
 
171
+ generate_interface = gr.Interface(
172
+ fn=api_generate_solution,
 
173
  inputs=[
174
+ gr.Textbox(label="LeetCode Problem Instruction"),
175
  gr.Textbox(label="JWT Token")
176
  ],
177
+ outputs=gr.JSON(label="Generated Solution"),
178
+ title="Generate Solution API",
179
+ description="Provide a LeetCode problem instruction and a valid JWT token to generate a solution."
180
+ )
181
+
182
+ stream_interface = gr.Interface(
183
+ fn=api_stream_solution,
184
+ inputs=[
185
+ gr.Textbox(label="LeetCode Problem Instruction"),
186
+ gr.Textbox(label="JWT Token")
187
  ],
188
+ outputs=gr.JSON(label="Streamed Solution"),
189
+ title="Stream Solution API",
190
+ description="Provide a LeetCode problem instruction and a valid JWT token to stream a solution."
191
+ )
192
+
193
+ explain_interface = gr.Interface(
194
+ fn=api_explain_solution,
195
+ inputs=[
196
+ gr.Textbox(label="Code to Explain"),
197
+ gr.Textbox(label="JWT Token")
198
+ ],
199
+ outputs=gr.JSON(label="Explanation"),
200
+ title="Explain Solution API",
201
+ description="Provide a code snippet and a valid JWT token to get an explanation."
202
+ )
203
+
204
+ random_problem_interface = gr.Interface(
205
+ fn=api_random_problem,
206
+ inputs=[gr.Textbox(label="JWT Token")],
207
+ outputs=gr.JSON(label="Random Problem"),
208
+ title="Random Problem API",
209
+ description="Provide a valid JWT token to get a random LeetCode problem."
210
+ )
211
+
212
+ # Combine interfaces
213
+ demo = gr.TabbedInterface(
214
+ [generate_interface, stream_interface, explain_interface, random_problem_interface],
215
+ ["Generate Solution", "Stream Solution", "Explain Solution", "Random Problem"]
216
  )
217
 
218
  if __name__ == "__main__":
219
+ demo.launch(share=True)