File size: 1,202 Bytes
f8736b7
 
 
 
 
 
 
 
 
 
 
 
 
c1cbbf2
 
 
 
f8736b7
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

from backend.code_generator import code_generator
from backend.models import models

with gr.Blocks() as codeTab:
    with gr.Row():
        with gr.Column():
            model = gr.Dropdown(choices=models.keys(), value = "gpt-4o-mini", label="Models")
            context = gr.Textbox(label="Context", placeholder="Please provide the business context.", lines=30)
        with gr.Column():
            chatbot = gr.Chatbot(placeholder="<strong>Business Analyst</strong><br>", height="80%")
            msg = gr.Textbox(show_label=False, container=False)
            examples = gr.Examples([["Generate entity code"],
                                    ["Generate Association code"],
                                    ["Generate Persistent Layer code"],
                                    ["Generate Api Layer code"]], msg)
    
    def user(user_message, history):
        return history + [[user_message, None]]
    
    def bot(user_message, history, context, story):
        history[-1][1]="Got it!"
        return history, "ACS"
    

    msg.submit(user, [msg, chatbot], [chatbot], queue=False).then(
        code_generator, [model, msg, chatbot, context], [chatbot]
    )