File size: 1,280 Bytes
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
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)