Team Ai
Apppublic

vineyard03/Code-Repair-With-LLMs

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
front_page.py66 linesDownload Raw Back to components
1import gradio as gr2import utils.interface_utils as iutils3 4from api.initiate_pipeline_call import initiate_pipeline_call5from utils.convert_steps import convert_steps6from utils.storage import save_jwt_to_session7from components.interface import create_interface8from components.model_selection import create_model_selection_dropdown9 10def handle_initiate_pipeline(files, selected_steps, initial_prompt):11    """Processes the file upload and initiates the pipeline."""12    if not files:13        gr.Warning("Please upload a file/codebase.")14        return gr.update(visible=True), gr.update(visible=False)15    16    binary_steps = convert_steps(selected_steps)17 18    # TODO: Do something with prompt19    response = initiate_pipeline_call(files, binary_steps)20    '''21        Delete print below in production22    '''23    print(response)24    save_jwt_to_session(response)  25 26    return gr.update(visible=False), gr.update(visible=True)27 28def create_full_ui():29    """Creates the full UI with a front page and the main interface."""30    with gr.Blocks(theme=iutils.custom_theme(), css="style.css") as app:31        # TODO: Replace with actual choices32        choices = ["ChatGPT", "Claude"]33 34        # Front Page UI35        with gr.Column(visible=True) as front_page:36            gr.Markdown("# Welcome to Code Repair with LLMs!")37            gr.Markdown("## Upload your files/codebase. All steps of the pipeline will be executed on the initial run.")38 39            file_input = gr.Files(40                label="Upload Multiple Files / Codebase",41                file_types=[".py", ".java", ".c", ".cpp"]42            )43            gr.Markdown("Python, Java, C++, and .zip files accepted.")44 45 46            steps = ["Bug Finding", "Pattern Matching", "Patch Generation", "Patch Validation"]47            checkboxes = gr.CheckboxGroup(steps, label="Select Desired Steps", value=steps, interactive=False)48 49            create_model_selection_dropdown(choices=choices)50 51            msg = gr.Textbox(label="Prompt", placeholder="Enter prompt (Optional)")52            initiate_button = gr.Button("Initiate Pipeline")53 54        # Main Interface UI (Initially Hidden)55        with gr.Row(visible=False) as main_interface:56            interface = create_interface()57 58        # Button click should happen inside the context59        initiate_button.click(60            fn=handle_initiate_pipeline,61            inputs=[file_input, checkboxes, msg],62            outputs=[front_page, main_interface]63        )64 65    return app66