Spaces:
Build error
Build error
Update app.py
Browse files3 unmodified lines4567891032 unmodified lines4344454647484950515253545556575859606162636465666768697071727374757677787980818283843 unmodified linesimport ioimport traceback
# Initialize the AI modelmodel_name = "Qwen/Qwen2.5-72B-Instruct"client = InferenceClient(model_name)
32 unmodified lines sys.stdout = old_stdout return output
def solve_math_task(math_task): # Generate Python code for the math task generated_code = llm_inference(f"Create a Python program to solve the following math problem:\n{math_task}") # Execute the generated code execution_result = execute_code(generated_code) return generated_code, execution_result
with 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