MasterPiper2112 commited on
Commit
dad87b5
·
verified ·
1 Parent(s): b470112

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +106 -0
app.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from nodes.DemandUnderstand import DemandUnderstand
3
+ from nodes.Coding import Coding
4
+ from nodes.CodeComplete import CodeComplete
5
+ from nodes.CodeReviewComment import CodeReviewComment
6
+ from nodes.CodeReviewModification import CodeReviewModification
7
+ from nodes.TestErrorSummary import TestErrorSummary
8
+ from nodes.TestModification import TestModification
9
+
10
+ def process_input(input_text):
11
+ # Initialize nodes
12
+ demand = DemandUnderstand()
13
+ coding = Coding()
14
+ code_complete = CodeComplete()
15
+ code_review_comment = CodeReviewComment()
16
+ code_review_mod = CodeReviewModification()
17
+ test_error_summary = TestErrorSummary()
18
+ test_mod = TestModification()
19
+
20
+ # Step 1: Demand Understanding
21
+ demand_result = demand.func_prompt_enhance(input_text)
22
+
23
+ # Step 2: Coding
24
+ coding_result = coding.func_coding(
25
+ assistant_role="Programmer",
26
+ gui=demand_result["product_vision"],
27
+ ideas="Innovative Features",
28
+ language=demand_result["language"],
29
+ modality=demand_result["modality"],
30
+ task=demand_result["task"]
31
+ )
32
+
33
+ # Step 3: Code Complete
34
+ code_complete_result = code_complete.func_coding(
35
+ assistant_role="Programmer",
36
+ unimplemented_file=coding_result["unimplemented_file"],
37
+ codes=coding_result["output"],
38
+ language=demand_result["language"],
39
+ modality=demand_result["modality"],
40
+ task=demand_result["task"]
41
+ )
42
+
43
+ # Step 4: Code Review Comment
44
+ review_comment = code_review_comment.generate_comments(
45
+ assistant_role="Code Reviewer",
46
+ codes=code_complete_result["output"],
47
+ ideas="Innovative Features",
48
+ language=demand_result["language"],
49
+ modality=demand_result["modality"],
50
+ task=demand_result["task"]
51
+ )
52
+
53
+ # Step 5: Code Review Modification
54
+ review_mod = code_review_mod.func_coding(
55
+ assistant_role="Code Reviewer",
56
+ comments=review_comment["output"],
57
+ codes=code_complete_result["output"],
58
+ ideas="Innovative Features",
59
+ language=demand_result["language"],
60
+ modality=demand_result["modality"],
61
+ task=demand_result["task"]
62
+ )
63
+
64
+ # Step 6: Test Error Summary
65
+ error_summary = test_error_summary.summarize_errors(
66
+ assistant_role="Programmer",
67
+ test_reports="Initial Test Report",
68
+ codes=review_mod["output"],
69
+ language=demand_result["language"]
70
+ )
71
+
72
+ # Step 7: Test Modification
73
+ test_mod_result = test_mod.func_coding(
74
+ assistant_role="Programmer",
75
+ error_summary=error_summary["output"],
76
+ test_reports="Initial Test Report",
77
+ codes=review_mod["output"],
78
+ language=demand_result["language"]
79
+ )
80
+
81
+ # Compile Results
82
+ final_output = {
83
+ "Demand Understanding": demand_result,
84
+ "Coding": coding_result,
85
+ "Code Complete": code_complete_result,
86
+ "Code Review Comment": review_comment,
87
+ "Code Review Modification": review_mod,
88
+ "Test Error Summary": error_summary,
89
+ "Test Modification": test_mod_result
90
+ }
91
+
92
+ return final_output
93
+
94
+ # Define the Gradio interface
95
+ with gr.Blocks() as demo:
96
+ gr.Markdown("# AI-Driven Software Company")
97
+ with gr.Row():
98
+ with gr.Column():
99
+ input_text = gr.Textbox(label="Enter your project requirements", lines=4)
100
+ submit = gr.Button("Generate")
101
+ with gr.Column():
102
+ output = gr.JSON(label="Output")
103
+ submit.click(process_input, inputs=input_text, outputs=output)
104
+
105
+ if __name__ == "__main__":
106
+ demo.launch()