| 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] | |
| ) |