sugiv commited on
Commit
1fdd050
·
1 Parent(s): c154108

Debugging shit

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -116,13 +116,6 @@ Here's the complete Python function implementation:
116
  formatted_code = extract_and_format_code(generated_text)
117
  return {"solution": formatted_code}
118
 
119
- @gr.Interface(
120
- fn=stream_solution,
121
- inputs=[gr.Textbox(label="Problem Instruction"), gr.Textbox(label="JWT Token")],
122
- outputs=gr.JSON(), # Changed output format to JSON for easier parsing
123
- title="Generate Solution API",
124
- description="Provide a LeetCode problem instruction and a valid JWT token to generate a solution."
125
- )
126
  async def stream_solution(instruction: str, token: str):
127
  if not verify_token(token):
128
  raise Exception("Invalid token")
@@ -175,6 +168,14 @@ generate_interface = gr.Interface(
175
  description="Provide a LeetCode problem instruction and a valid JWT token to generate a solution."
176
  )
177
 
 
 
 
 
 
 
 
 
178
  random_problem_interface = gr.Interface(
179
  fn=random_problem,
180
  inputs=gr.Textbox(label="JWT Token"),
@@ -185,9 +186,9 @@ random_problem_interface = gr.Interface(
185
 
186
  # Combine interfaces
187
  demo = gr.TabbedInterface(
188
- [generate_interface, random_problem_interface],
189
- ["Generate Solution", "Random Problem"]
190
  )
191
 
192
  # Launch the Gradio app
193
- demo.launch()
 
116
  formatted_code = extract_and_format_code(generated_text)
117
  return {"solution": formatted_code}
118
 
 
 
 
 
 
 
 
119
  async def stream_solution(instruction: str, token: str):
120
  if not verify_token(token):
121
  raise Exception("Invalid token")
 
168
  description="Provide a LeetCode problem instruction and a valid JWT token to generate a solution."
169
  )
170
 
171
+ stream_interface = gr.Interface(
172
+ fn=stream_solution,
173
+ inputs=[gr.Textbox(label="Problem Instruction"), gr.Textbox(label="JWT Token")],
174
+ outputs=gr.Text(),
175
+ title="Stream Solution API",
176
+ description="Provide a LeetCode problem instruction and a valid JWT token to stream a solution."
177
+ )
178
+
179
  random_problem_interface = gr.Interface(
180
  fn=random_problem,
181
  inputs=gr.Textbox(label="JWT Token"),
 
186
 
187
  # Combine interfaces
188
  demo = gr.TabbedInterface(
189
+ [generate_interface, stream_interface, random_problem_interface],
190
+ ["Generate Solution", "Stream Solution", "Random Problem"]
191
  )
192
 
193
  # Launch the Gradio app
194
+ demo.launch()