import gradio as gr from dotenv import load_dotenv from coder.crew import Coder load_dotenv(override=True) def run(assignment): inputs = { 'assignment': assignment, } result= Coder().crew().kickoff(inputs=inputs) output = result.raw return output # Build the UI with gr.Blocks(theme="soft") as ui: gr.Markdown( """ # 👨‍💻 Python Coder by Efay Guo This is a code writing tool that generates any Python code you want and explain it line by line and show your the final result. 这是一个用于写Pyton代码的Agent,不仅可以帮你写代码,也会给你每行进行解释,展示程序最后的结果 """ ) query_textbox = gr.Textbox(label="What code would you like to write? / 您想实现什么代码功能?", placeholder="write a a beautifulsoup micro service or 写一个flask微服务框架") run_button = gr.Button("Start Writing Code / 开始写代码", variant="huggingface") report = gr.Markdown(label="Report") run_button.click(fn=run, inputs=query_textbox, outputs=report,show_progress="full") query_textbox.submit(fn=run, inputs=query_textbox, outputs=report, show_progress="full") ui.launch(inbrowser=True)