Debugging shit
Browse files
app.py
CHANGED
@@ -159,7 +159,7 @@ def random_problem(token: str) -> Dict[str, Any]:
|
|
159 |
|
160 |
return {"problem": problem}
|
161 |
|
162 |
-
# Create Gradio interfaces
|
163 |
generate_interface = gr.Interface(
|
164 |
fn=generate_solution,
|
165 |
inputs=[gr.Textbox(label="Problem Instruction"), gr.Textbox(label="JWT Token")],
|
@@ -171,7 +171,7 @@ generate_interface = gr.Interface(
|
|
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 |
)
|
@@ -190,19 +190,5 @@ demo = gr.TabbedInterface(
|
|
190 |
["Generate Solution", "Stream Solution", "Random Problem"]
|
191 |
)
|
192 |
|
193 |
-
#
|
194 |
-
|
195 |
-
async with gr.Gradio().launch(interface) as app:
|
196 |
-
while True: # Continuous loop for handling new requests
|
197 |
-
instruction = await app.textboxes.get("Problem Instruction")
|
198 |
-
token = await app.textboxes.get("JWT Token")
|
199 |
-
|
200 |
-
try:
|
201 |
-
async for generated_token in await stream_solution(instruction, token):
|
202 |
-
await app.text.write(generated_token) # Update text box with each token
|
203 |
-
except Exception as e:
|
204 |
-
await app.text.write(f"Error: {e}")
|
205 |
-
|
206 |
-
if __name__ == "__main__":
|
207 |
-
loop = asyncio.get_event_loop()
|
208 |
-
loop.run_until_complete(run(demo))
|
|
|
159 |
|
160 |
return {"problem": problem}
|
161 |
|
162 |
+
# Create Gradio interfaces
|
163 |
generate_interface = gr.Interface(
|
164 |
fn=generate_solution,
|
165 |
inputs=[gr.Textbox(label="Problem Instruction"), gr.Textbox(label="JWT Token")],
|
|
|
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 |
)
|
|
|
190 |
["Generate Solution", "Stream Solution", "Random Problem"]
|
191 |
)
|
192 |
|
193 |
+
# Launch the Gradio app
|
194 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|