import gradio as gr from nodes.DemandUnderstand import DemandUnderstand from nodes.Coding import Coding from nodes.CodeComplete import CodeComplete from nodes.CodeReviewComment import CodeReviewComment from nodes.CodeReviewModification import CodeReviewModification from nodes.TestErrorSummary import TestErrorSummary from nodes.TestModification import TestModification def process_input(input_text): # Initialize nodes demand = DemandUnderstand() coding = Coding() code_complete = CodeComplete() code_review_comment = CodeReviewComment() code_review_mod = CodeReviewModification() test_error_summary = TestErrorSummary() test_mod = TestModification() # Step 1: Demand Understanding demand_result = demand.func_prompt_enhance(input_text) # Step 2: Coding coding_result = coding.func_coding( assistant_role="Programmer", gui=demand_result["product_vision"], ideas="Innovative Features", language=demand_result["language"], modality=demand_result["modality"], task=demand_result["task"] ) # Step 3: Code Complete code_complete_result = code_complete.func_coding( assistant_role="Programmer", unimplemented_file=coding_result["unimplemented_file"], codes=coding_result["output"], language=demand_result["language"], modality=demand_result["modality"], task=demand_result["task"] ) # Step 4: Code Review Comment review_comment = code_review_comment.generate_comments( assistant_role="Code Reviewer", codes=code_complete_result["output"], ideas="Innovative Features", language=demand_result["language"], modality=demand_result["modality"], task=demand_result["task"] ) # Step 5: Code Review Modification review_mod = code_review_mod.func_coding( assistant_role="Code Reviewer", comments=review_comment["output"], codes=code_complete_result["output"], ideas="Innovative Features", language=demand_result["language"], modality=demand_result["modality"], task=demand_result["task"] ) # Step 6: Test Error Summary error_summary = test_error_summary.summarize_errors( assistant_role="Programmer", test_reports="Initial Test Report", codes=review_mod["output"], language=demand_result["language"] ) # Step 7: Test Modification test_mod_result = test_mod.func_coding( assistant_role="Programmer", error_summary=error_summary["output"], test_reports="Initial Test Report", codes=review_mod["output"], language=demand_result["language"] ) # Compile Results final_output = { "Demand Understanding": demand_result, "Coding": coding_result, "Code Complete": code_complete_result, "Code Review Comment": review_comment, "Code Review Modification": review_mod, "Test Error Summary": error_summary, "Test Modification": test_mod_result } return final_output # Define the Gradio interface with gr.Blocks() as demo: gr.Markdown("# AI-Driven Software Company") with gr.Row(): with gr.Column(): input_text = gr.Textbox(label="Enter your project requirements", lines=4) submit = gr.Button("Generate") with gr.Column(): output = gr.JSON(label="Output") submit.click(process_input, inputs=input_text, outputs=output) if __name__ == "__main__": demo.launch()