Spaces:
Build error
Build error
Update app.py
Browse files3 unmodified lines45678932 unmodified lines42434445464748495051525354555657585960613 unmodified linesimport ioimport tracebackmodel_name = "Qwen/Qwen2.5-72B-Instruct"client = InferenceClient(model_name)32 unmodified linessys.stdout = old_stdoutreturn outputwith gr.Blocks() as demo:gr.Markdown("# π Python Helper Chatbot")with gr.Tab("Chat"):chatbot = gr.Chatbot()msg = gr.Textbox(placeholder="Type your message here...")msg.submit(chat, inputs=[msg, chatbot], outputs=[chatbot, chatbot])with gr.Tab("Interpreter"):gr.Markdown("### π₯οΈ Test Your Code")code_input = gr.Code(language="python")run_button = gr.Button("Run Code")code_output = gr.Textbox(label="Output")run_button.click(execute_code, inputs=code_input, outputs=code_output)with gr.Tab("Logs"):gr.Markdown("### π Logs")log_output = gr.Textbox(label="Logs", lines=10, interactive=False)demo.launch()3 unmodified lines4567891032 unmodified lines4344454647484950515253545556575859606162636465666768697071727374757677787980818283843 unmodified linesimport ioimport traceback# Initialize the AI modelmodel_name = "Qwen/Qwen2.5-72B-Instruct"client = InferenceClient(model_name)32 unmodified linessys.stdout = old_stdoutreturn outputdef solve_math_task(math_task):# Generate Python code for the math taskgenerated_code = llm_inference(f"Create a Python program to solve the following math problem:\n{math_task}")# Execute the generated codeexecution_result = execute_code(generated_code)return generated_code, execution_resultwith gr.Blocks() as demo:gr.Markdown("# π Python Helper Chatbot")with gr.Tab("Chat"):chatbot = gr.Chatbot()msg = gr.Textbox(placeholder="Type your message here...")msg.submit(chat, inputs=[msg, chatbot], outputs=[chatbot, chatbot])with gr.Tab("Interpreter"):gr.Markdown("### π₯οΈ Test Your Code")code_input = gr.Code(language="python")run_button = gr.Button("Run Code")code_output = gr.Textbox(label="Output")run_button.click(execute_code, inputs=code_input, outputs=code_output)with gr.Tab("Math Solver"):gr.Markdown("### π Math Task Solver")math_input = gr.Textbox(placeholder="Enter your mathematical task here...", lines=2)solve_button = gr.Button("Solve Task")with gr.Row():generated_code_output = gr.Code(label="Generated Python Code", language="python")with gr.Row():execution_output = gr.Textbox(label="Execution Result", lines=10)solve_button.click(solve_math_task, inputs=math_input, outputs=[generated_code_output, execution_output])with gr.Tab("Logs"):gr.Markdown("### π Logs")log_output = gr.Textbox(label="Logs", lines=10, interactive=False)# Launch the Gradio appdemo.launch()
app.py+23