File size: 1,532 Bytes
6231986
 
 
888db36
6231986
 
 
 
 
 
 
 
 
 
 
26b90bf
888db36
8231377
888db36
26b90bf
 
 
 
8231377
888db36
6231986
 
 
8231377
6231986
 
 
888db36
6231986
888db36
6231986
 
 
 
 
 
8231377
6231986
 
888db36
 
6231986
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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)