Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from dotenv import load_dotenv | |
| from coder.crew import Coder | |
| import time | |
| load_dotenv(override=True) | |
| def run(assignment): | |
| inputs = { | |
| 'assignment': assignment, | |
| } | |
| if assignment: | |
| gr.Warning(f"Start processing... you many need to wait up to 30 seconds / 开始任务... 你可能要等待30秒", duration=30) | |
| result= Coder().crew().kickoff(inputs=inputs) | |
| output = result.raw | |
| return output | |
| else: | |
| gr.Warning("Please input your task / 请填写任务", duration=3) | |
| # Build the UI | |
| with gr.Blocks(theme="gstaff/sketch") as ui: | |
| gr.Markdown( | |
| """ | |
| # 👨💻 Python Coder by Efay Guo | |
| This is a Python code writer that generates Python code you need and explain it line by line and show you 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 / 开始写代码") | |
| 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) |