Spaces:
Build error
Build error
File size: 2,497 Bytes
e8248b5 | 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import gradio as gr
import utils.interface_utils as iutils
from api.initiate_pipeline_call import initiate_pipeline_call
from utils.convert_steps import convert_steps
from utils.storage import save_jwt_to_session
from components.interface import create_interface
from components.model_selection import create_model_selection_dropdown
def handle_initiate_pipeline(files, selected_steps, initial_prompt):
"""Processes the file upload and initiates the pipeline."""
if not files:
gr.Warning("Please upload a file/codebase.")
return gr.update(visible=True), gr.update(visible=False)
binary_steps = convert_steps(selected_steps)
# TODO: Do something with prompt
response = initiate_pipeline_call(files, binary_steps)
'''
Delete print below in production
'''
print(response)
save_jwt_to_session(response)
return gr.update(visible=False), gr.update(visible=True)
def create_full_ui():
"""Creates the full UI with a front page and the main interface."""
with gr.Blocks(theme=iutils.custom_theme(), css="style.css") as app:
# TODO: Replace with actual choices
choices = ["ChatGPT", "Claude"]
# Front Page UI
with gr.Column(visible=True) as front_page:
gr.Markdown("# Welcome to Code Repair with LLMs!")
gr.Markdown("## Upload your files/codebase. All steps of the pipeline will be executed on the initial run.")
file_input = gr.Files(
label="Upload Multiple Files / Codebase",
file_types=[".py", ".java", ".c", ".cpp"]
)
gr.Markdown("Python, Java, C++, and .zip files accepted.")
steps = ["Bug Finding", "Pattern Matching", "Patch Generation", "Patch Validation"]
checkboxes = gr.CheckboxGroup(steps, label="Select Desired Steps", value=steps, interactive=False)
create_model_selection_dropdown(choices=choices)
msg = gr.Textbox(label="Prompt", placeholder="Enter prompt (Optional)")
initiate_button = gr.Button("Initiate Pipeline")
# Main Interface UI (Initially Hidden)
with gr.Row(visible=False) as main_interface:
interface = create_interface()
# Button click should happen inside the context
initiate_button.click(
fn=handle_initiate_pipeline,
inputs=[file_input, checkboxes, msg],
outputs=[front_page, main_interface]
)
return app
|