ICAS03 commited on
Commit
843279f
·
1 Parent(s): 2127f72

made minor edits

Browse files
Files changed (5) hide show
  1. Project.py +152 -158
  2. app.py +1 -1
  3. code_modifier.py +50 -33
  4. page_prompts_config.py +1 -1
  5. step_handlers.py +3 -3
Project.py CHANGED
@@ -165,177 +165,171 @@ class Project:
165
  }
166
  )
167
 
168
- ## Functions that interact with the steps button handler ##
169
- # Generate Scope & Components
170
- def v4_generate_prd_and_components(progress=gr.Progress()):
171
- """Generate PRD and components from project details"""
172
- progress(0, desc="Progress 1: Generating PRD from Q&A...")
173
- generated_prd = state.quotation_project.execute_prompt(
174
- "generate_prd",
175
- {
176
- "project_detail": state.quotation_project.get_project_detail()
177
- }
178
- )
179
-
180
- # Step 2: Generate Components
181
- progress(0.4, desc="Progress 2: Generating Planning & Testing Component...")
182
- plan_test_component_list = state.quotation_project.execute_prompt(
183
- "generate_plan_test_components",
184
- {
185
- "generated_prd": state.quotation_project.generated_prd
186
- }
187
- )
188
-
189
- progress(0.7, desc="Progress 3: Generating Development Components...")
190
- dev_component_list = state.quotation_project.execute_prompt(
191
- "generate_dev_components",
192
- {
193
- "generated_prd": state.quotation_project.generated_prd
194
- }
195
- )
196
-
197
- progress(1.0, desc="Complete!")
198
- return [
199
- generated_prd,
200
- generated_prd,
201
- plan_test_component_list,
202
- plan_test_component_list,
203
- dev_component_list,
204
- dev_component_list,
205
- "Generated PRD and Component List! Click Generate Final Quotation To Generate Quotation"
206
- ]
207
-
208
- # Generate Plan & Test Mandays + Quotation based on components
209
- def v4_generate_mandays_and_quotation(plan_test_component, dev_component, progress=gr.Progress()):
210
- state.quotation_project.generated_plan_test_components = plan_test_component
211
- state.quotation_project.generated_dev_components = dev_component
212
-
213
- # Generate Plan & Test Mandays
214
- progress(0.5, desc="Progress 1: Generating Mandays for Plan & Test Components...")
215
- plan_test_mandays = state.quotation_project.execute_prompt(
216
- "generate_plan_test_mandays",
217
- {
218
- "generated_plan_test_components": plan_test_component
219
- }
220
- )
221
-
222
- # Generate Dev Mandays
223
- progress(0.7, desc="Progress 2: Generating Mandays for Dev Components...")
224
- dev_mandays = state.quotation_project.execute_prompt(
225
- "generate_dev_mandays",
226
- {
227
- "generated_dev_components": dev_component
228
- }
229
- )
230
-
231
- print(f"Dev Mandays Result: {dev_mandays}")
232
-
233
- # Convert the results into dataframe
234
- try:
235
- plan_test_df = pd.read_csv(StringIO(plan_test_mandays), on_bad_lines='skip')
236
- dev_df = pd.read_csv(StringIO(dev_mandays), on_bad_lines='skip')
237
-
238
- # Standardize column names to lowercase
239
- plan_test_df.columns = plan_test_df.columns.str.lower()
240
- dev_df.columns = dev_df.columns.str.lower()
241
 
242
- # Validate and standardize column names
243
- required_plan_test_columns = ['component', 'mandays', 'description']
244
- required_dev_columns = ['component', 'subcomponent', 'mandays', 'description']
 
 
 
 
 
245
 
246
- # Check and fix plan_test columns
247
- if not all(col in plan_test_df.columns for col in required_plan_test_columns):
248
- raise ValueError(f"Plan & Test CSV missing required columns. Expected: {required_plan_test_columns}")
 
 
 
 
249
 
250
- # Check and fix dev columns
251
- if not all(col in dev_df.columns for col in required_dev_columns):
252
- raise ValueError(f"Dev CSV missing required columns. Expected: {required_dev_columns}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
- # Convert mandays to numeric, replacing empty values with 0
255
- plan_test_df['mandays'] = pd.to_numeric(plan_test_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
256
- dev_df['mandays'] = pd.to_numeric(dev_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
 
 
 
 
 
 
 
257
 
258
- total_mandays, total_cost, estimated_months = calculate_mandays_and_costs(plan_test_df, dev_df)
 
 
 
259
 
260
- progress(1.0, desc="Complete!")
261
- cost_summary = f"""
262
- Total Mandays: {total_mandays:.2f}
263
- Total Cost: ${total_cost:,.2f}
264
- ({estimated_months:.2}months)
265
- """
266
- return [plan_test_df, dev_df, "Generated Quotation!", cost_summary]
267
-
268
- except Exception as e:
269
- error_message = f"Error processing CSV data: {str(e)}"
270
- return [None, None, error_message, "Error calculating costs"]
271
-
272
- # Generate BD & Tech SOW
273
- def v4_generate_sow(generated_prd, plan_test_component, dev_component, cost, progress=gr.Progress()):
274
- state.quotation_project.generated_plan_test_components = plan_test_component
275
- state.quotation_project.generated_dev_components = dev_component
276
- state.quotation_project.quotation_cost = cost
277
-
278
- # Generate general SOW
279
- progress(0.4, desc="Progress 1: Drafting SOW")
280
- general_sow = state.quotation_project.execute_prompt(
281
- "generate_BD_SOW",
282
- {
283
- "generated_prd": generated_prd,
284
- "generated_plan_test_components": plan_test_component,
285
- "generated_dev_components": dev_component,
286
- "quotation_cost": cost
287
- }
288
- )
289
-
290
- # Generate Technical SOW
291
- progress(0.8, desc="Progress 2: Drafting Technical SOW")
292
- detailed_sow_json = state.quotation_project.execute_prompt(
293
- "generate_Tech_SOW",
294
- {
295
- "generated_plan_test_components": plan_test_component,
296
- "generated_dev_components": dev_component
297
- }
298
- )
 
 
 
 
 
 
 
 
 
 
 
299
 
300
- try:
301
- # Parse detailed_sow into a JSON object
302
- detailed_sow_json = json.loads(detailed_sow_json)
 
 
 
 
 
 
303
 
304
- # Extract required fields
305
- scope_summary = detailed_sow_json.get("scope_summary", "")
306
- modules_and_functional_requirements = detailed_sow_json.get("modules_and_functional_requirements", "")
307
- out_of_scope = detailed_sow_json.get("out_of_scope", "")
308
- system_flow = detailed_sow_json.get("system_flow", "")
309
 
310
- # Combine all fields into detailed_sow
311
- detailed_sow = f"{scope_summary}\n\n{modules_and_functional_requirements}\n\n{out_of_scope}\n\n{system_flow}"
 
 
 
312
 
313
- # Create final SOW
314
- final_general_sow = f"**Hi , some sections of this SOW is generated seprately from the main draft. youll have to move this to the right spot manually ;)\n **Project Quotation:**\n{cost}\n{modules_and_functional_requirements}\n\n {general_sow}\nEOF"
315
- return [final_general_sow,final_general_sow, detailed_sow, detailed_sow, "Generated SOW!"]
316
- except Exception as e:
317
- return ["Error generating SOW", "Error: " + str(e), "Failed to generate SOW"]
318
 
319
- # Recalculate costs based on modified dataframe values
320
- def v4_recalculate_cost(plan_test_df, dev_df):
321
- """Recalculate costs based on modified dataframe values"""
322
- try:
323
- # Convert mandays columns to numeric, replacing empty values with 0
324
- plan_test_df['mandays'] = pd.to_numeric(plan_test_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
325
- dev_df['mandays'] = pd.to_numeric(dev_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
326
-
327
- # Calculate totals
328
- total_mandays, total_cost, estimated_months = calculate_mandays_and_costs(plan_test_df, dev_df)
329
 
330
- cost_summary = f"""
331
- Total Mandays: {total_mandays:.2f}
332
- Total Cost: ${total_cost:,.2f}
333
- ({estimated_months:.2}months)
334
- """
335
- return f"Successfully Updated Quotation. SessionID:{state.quotation_project.session_id}", cost_summary
336
- except Exception as e:
337
- return f"Error recalculating costs: {str(e)}", f"Error recalculating costs: {str(e)}"
 
338
 
 
 
 
 
 
 
 
 
339
 
340
  def update_display_mode(mode, content):
341
  if mode == "Textbox":
 
165
  }
166
  )
167
 
168
+ def generate_prd_and_components(self, progress=gr.Progress()):
169
+ """Generate PRD and components from project details"""
170
+ progress(0, desc="Progress 1: Generating PRD from Q&A...")
171
+ generated_prd = self.execute_prompt(
172
+ "generate_prd",
173
+ {
174
+ "project_detail": self.get_project_detail()
175
+ }
176
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
+ # Step 2: Generate Components
179
+ progress(0.4, desc="Progress 2: Generating Planning & Testing Component...")
180
+ plan_test_component_list = self.execute_prompt(
181
+ "generate_plan_test_components",
182
+ {
183
+ "generated_prd": self.generated_prd
184
+ }
185
+ )
186
 
187
+ progress(0.7, desc="Progress 3: Generating Development Components...")
188
+ dev_component_list = self.execute_prompt(
189
+ "generate_dev_components",
190
+ {
191
+ "generated_prd": self.generated_prd
192
+ }
193
+ )
194
 
195
+ progress(1.0, desc="Complete!")
196
+ return [
197
+ generated_prd,
198
+ generated_prd,
199
+ plan_test_component_list,
200
+ plan_test_component_list,
201
+ dev_component_list,
202
+ dev_component_list,
203
+ "Generated PRD and Component List! Click Generate Final Quotation To Generate Quotation"
204
+ ]
205
+
206
+ def generate_mandays_and_quotation(self, plan_test_component, dev_component, progress=gr.Progress()):
207
+ self.generated_plan_test_components = plan_test_component
208
+ self.generated_dev_components = dev_component
209
+
210
+ # Generate Plan & Test Mandays
211
+ progress(0.5, desc="Progress 1: Generating Mandays for Plan & Test Components...")
212
+ plan_test_mandays = self.execute_prompt(
213
+ "generate_plan_test_mandays",
214
+ {
215
+ "generated_plan_test_components": plan_test_component
216
+ }
217
+ )
218
 
219
+ # Generate Dev Mandays
220
+ progress(0.7, desc="Progress 2: Generating Mandays for Dev Components...")
221
+ dev_mandays = self.execute_prompt(
222
+ "generate_dev_mandays",
223
+ {
224
+ "generated_dev_components": dev_component
225
+ }
226
+ )
227
+
228
+ print(f"Dev Mandays Result: {dev_mandays}")
229
 
230
+ # Convert the results into dataframe
231
+ try:
232
+ plan_test_df = pd.read_csv(StringIO(plan_test_mandays), on_bad_lines='skip')
233
+ dev_df = pd.read_csv(StringIO(dev_mandays), on_bad_lines='skip')
234
 
235
+ # Standardize column names to lowercase
236
+ plan_test_df.columns = plan_test_df.columns.str.lower()
237
+ dev_df.columns = dev_df.columns.str.lower()
238
+
239
+ # Validate and standardize column names
240
+ required_plan_test_columns = ['component', 'mandays', 'description']
241
+ required_dev_columns = ['component', 'subcomponent', 'mandays', 'description']
242
+
243
+ # Check and fix plan_test columns
244
+ if not all(col in plan_test_df.columns for col in required_plan_test_columns):
245
+ raise ValueError(f"Plan & Test CSV missing required columns. Expected: {required_plan_test_columns}")
246
+
247
+ # Check and fix dev columns
248
+ if not all(col in dev_df.columns for col in required_dev_columns):
249
+ raise ValueError(f"Dev CSV missing required columns. Expected: {required_dev_columns}")
250
+
251
+ # Convert mandays to numeric, replacing empty values with 0
252
+ plan_test_df['mandays'] = pd.to_numeric(plan_test_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
253
+ dev_df['mandays'] = pd.to_numeric(dev_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
254
+
255
+ total_mandays, total_cost, estimated_months = calculate_mandays_and_costs(plan_test_df, dev_df)
256
+
257
+ progress(1.0, desc="Complete!")
258
+ cost_summary = f"""
259
+ Total Mandays: {total_mandays:.2f}
260
+ Total Cost: ${total_cost:,.2f}
261
+ ({estimated_months:.2}months)
262
+ """
263
+ return [plan_test_df, dev_df, "Generated Quotation!", cost_summary]
264
+
265
+ except Exception as e:
266
+ error_message = f"Error processing CSV data: {str(e)}"
267
+ return [None, None, error_message, "Error calculating costs"]
268
+
269
+ def generate_sow(self, generated_prd, plan_test_component, dev_component, cost, progress=gr.Progress()):
270
+ self.generated_plan_test_components = plan_test_component
271
+ self.generated_dev_components = dev_component
272
+ self.quotation_cost = cost
273
+
274
+ # Generate general SOW
275
+ progress(0.4, desc="Progress 1: Drafting SOW")
276
+ general_sow = self.execute_prompt(
277
+ "generate_BD_SOW",
278
+ {
279
+ "generated_prd": generated_prd,
280
+ "generated_plan_test_components": plan_test_component,
281
+ "generated_dev_components": dev_component,
282
+ "quotation_cost": cost
283
+ }
284
+ )
285
 
286
+ # Generate Technical SOW
287
+ progress(0.8, desc="Progress 2: Drafting Technical SOW")
288
+ detailed_sow_json = self.execute_prompt(
289
+ "generate_Tech_SOW",
290
+ {
291
+ "generated_plan_test_components": plan_test_component,
292
+ "generated_dev_components": dev_component
293
+ }
294
+ )
295
 
296
+ try:
297
+ # Parse detailed_sow into a JSON object
298
+ detailed_sow_json = json.loads(detailed_sow_json)
 
 
299
 
300
+ # Extract required fields
301
+ scope_summary = detailed_sow_json.get("scope_summary", "")
302
+ modules_and_functional_requirements = detailed_sow_json.get("modules_and_functional_requirements", "")
303
+ out_of_scope = detailed_sow_json.get("out_of_scope", "")
304
+ system_flow = detailed_sow_json.get("system_flow", "")
305
 
306
+ # Combine all fields into detailed_sow
307
+ detailed_sow = f"{scope_summary}\n\n{modules_and_functional_requirements}\n\n{out_of_scope}\n\n{system_flow}"
 
 
 
308
 
309
+ # Create final SOW
310
+ final_general_sow = f"**Hi , some sections of this SOW is generated seprately from the main draft. youll have to move this to the right spot manually ;)\n **Project Quotation:**\n{cost}\n{modules_and_functional_requirements}\n\n {general_sow}\nEOF"
311
+ return [final_general_sow, final_general_sow, detailed_sow, detailed_sow, "Generated SOW!"]
312
+ except Exception as e:
313
+ return ["Error generating SOW", "Error: " + str(e), "Failed to generate SOW"]
 
 
 
 
 
314
 
315
+ def recalculate_cost(self, plan_test_df, dev_df):
316
+ """Recalculate costs based on modified dataframe values"""
317
+ try:
318
+ # Convert mandays columns to numeric, replacing empty values with 0
319
+ plan_test_df['mandays'] = pd.to_numeric(plan_test_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
320
+ dev_df['mandays'] = pd.to_numeric(dev_df['mandays'].replace('', '0'), errors='coerce').fillna(0)
321
+
322
+ # Calculate totals
323
+ total_mandays, total_cost, estimated_months = calculate_mandays_and_costs(plan_test_df, dev_df)
324
 
325
+ cost_summary = f"""
326
+ Total Mandays: {total_mandays:.2f}
327
+ Total Cost: ${total_cost:,.2f}
328
+ ({estimated_months:.2}months)
329
+ """
330
+ return f"Successfully Updated Quotation. SessionID:{self.session_id}", cost_summary
331
+ except Exception as e:
332
+ return f"Error recalculating costs: {str(e)}", f"Error recalculating costs: {str(e)}"
333
 
334
  def update_display_mode(mode, content):
335
  if mode == "Textbox":
app.py CHANGED
@@ -301,7 +301,7 @@ with gr.Blocks(title="v3 Page Quotation Chatbot (with SOW)", css=custom_css) as
301
  setup_all_handlers(step_buttons, all_components, page_progress_update, quotation_cost)
302
 
303
  page_recalc_btn.click(
304
- fn=v4_recalculate_cost,
305
  inputs=[
306
  all_components['generate_plan_test_mandays']['generated_plan_test_mandays_dataframe'],
307
  all_components['generate_dev_mandays']['generated_dev_mandays_dataframe'],
 
301
  setup_all_handlers(step_buttons, all_components, page_progress_update, quotation_cost)
302
 
303
  page_recalc_btn.click(
304
+ fn=state.quotation_project.recalculate_cost,
305
  inputs=[
306
  all_components['generate_plan_test_mandays']['generated_plan_test_mandays_dataframe'],
307
  all_components['generate_dev_mandays']['generated_dev_mandays_dataframe'],
code_modifier.py CHANGED
@@ -93,7 +93,17 @@ def clean_ai_response(response: str) -> str:
93
  def analyze_config_structure(config_content: str, project_content: str, current_handlers: str) -> Dict:
94
  """First AI: Analyzes the current config structure and determines required changes"""
95
  analysis_prompt = f"""
96
- You are an expert software analyzer. Your task is to analyze and focus on the configuration structure and validate the relationships between components.
 
 
 
 
 
 
 
 
 
 
97
 
98
  1. OUTPUT AND INPUT VALIDATION RULES:
99
  - Not all outputs/inputs require UI component mappings
@@ -121,8 +131,8 @@ def analyze_config_structure(config_content: str, project_content: str, current_
121
 
122
  4. NAMING CONVENTION (Source of Truth: Config File)
123
  MUST CHECK:
124
- - Prompt names (e.g., "generate_dev_components")
125
- - Component names (e.g., "generated_Tech_SOW_text")
126
  - Input/Output references
127
 
128
  WHERE TO CHECK:
@@ -139,7 +149,7 @@ def analyze_config_structure(config_content: str, project_content: str, current_
139
 
140
  Context Files:
141
  1. Current Config:
142
- {config_content}y
143
 
144
  2. Project.py:
145
  {project_content}
@@ -147,7 +157,7 @@ def analyze_config_structure(config_content: str, project_content: str, current_
147
  3. step_handlers.py:
148
  {current_handlers}
149
 
150
- Return a JSON analysis with this EXACT structure:
151
  {{
152
  "component_mappings": {{
153
  "outputs": [
@@ -234,39 +244,40 @@ def generate_code_updates(analysis_result: Dict) -> Dict:
234
  Analysis Result:
235
  {json.dumps(analysis_result, indent=2)}
236
 
237
- Generate a JSON response with this EXACT structure:
238
  {{
239
  "Project.py": {{
240
- "updates": [
241
- {{
242
- "location": "exact_location",
243
- "explanation": "detailed_explanation",
244
- "old_code": "existing_code",
245
- "new_code": "updated_code"
246
- }}
247
- ]
248
  }},
249
  "step_handlers.py": {{
250
  "updates": [
251
  {{
252
- "location": "exact_location",
253
- "explanation": "detailed_explanation",
254
- "old_code": "existing_code",
255
- "new_code": "updated_code"
 
 
 
 
 
 
 
 
256
  }}
257
  ]
258
  }}
259
  }}
260
 
261
  Requirements:
262
- 1. Maintain exact function signatures
263
- 2. Preserve existing code structure
264
- 3. Only generate the specific changes needed
265
- 4. Include clear comments explaining changes
266
- 5. Each file must have an 'updates' array, even if empty
 
267
 
268
  IMPORTANT: Return ONLY the JSON object, without any markdown formatting or explanation.
269
- Do not include ```json or ``` markers.
270
  """
271
 
272
  try:
@@ -280,12 +291,14 @@ def generate_code_updates(analysis_result: Dict) -> Dict:
280
  if "step_handlers.py" not in parsed_result:
281
  parsed_result["step_handlers.py"] = {"updates": []}
282
 
283
- # Ensure updates array exists
284
- if "updates" not in parsed_result["Project.py"]:
285
- parsed_result["Project.py"]["updates"] = []
286
- if "updates" not in parsed_result["step_handlers.py"]:
287
- parsed_result["step_handlers.py"]["updates"] = []
288
-
 
 
289
  return parsed_result
290
 
291
  except Exception as e:
@@ -335,6 +348,10 @@ def apply_handler_updates(updates: List[Dict]) -> bool:
335
  content = f.read()
336
 
337
  for update in updates:
 
 
 
 
338
  if update['type'] == 'component':
339
  # Update component references
340
  content = content.replace(update['old_code'], update['new_code'])
@@ -345,9 +362,9 @@ def apply_handler_updates(updates: List[Dict]) -> bool:
345
  content = re.sub(pattern, replacement, content)
346
  elif update['type'] == 'output':
347
  # Update output parameters
348
- pattern = rf"outputs=\[([^\]]*)\]"
349
- replacement = f"outputs=[{update['new_code']}]"
350
- content = re.sub(pattern, replacement, content)
351
 
352
  with open('step_handlers.py', 'w') as f:
353
  f.write(content)
 
93
  def analyze_config_structure(config_content: str, project_content: str, current_handlers: str) -> Dict:
94
  """First AI: Analyzes the current config structure and determines required changes"""
95
  analysis_prompt = f"""
96
+ You are an expert software engineer performing a comprehensive analysis.You must analyze the current state of the code WITHOUT relying on any previous context or memory.
97
+
98
+ IMPORTANT RULES:
99
+ 1. ONLY analyze the code provided in this prompt
100
+ 2. DO NOT reference or recall any previous analyses
101
+ 3. DO NOT suggest changes based on previous versions
102
+ 4. ONLY compare against the current files provided
103
+ 5. IGNORE any remembered patterns or previous suggestions
104
+
105
+ Your task is to analyze and focus on the configuration structure and validate the relationships between components.
106
+
107
 
108
  1. OUTPUT AND INPUT VALIDATION RULES:
109
  - Not all outputs/inputs require UI component mappings
 
131
 
132
  4. NAMING CONVENTION (Source of Truth: Config File)
133
  MUST CHECK:
134
+ - Prompt names (e.g., "generate_dev_components" --> "generate_development_components")
135
+ - Component names (e.g., "generated_Tech_SOW_text" --> "generated_technical_sow_text")
136
  - Input/Output references
137
 
138
  WHERE TO CHECK:
 
149
 
150
  Context Files:
151
  1. Current Config:
152
+ {config_content}
153
 
154
  2. Project.py:
155
  {project_content}
 
157
  3. step_handlers.py:
158
  {current_handlers}
159
 
160
+ Return a JSON analysis with this EXACT structure as shown as an example below:
161
  {{
162
  "component_mappings": {{
163
  "outputs": [
 
244
  Analysis Result:
245
  {json.dumps(analysis_result, indent=2)}
246
 
247
+ Generate a JSON response with this EXACT structure as shown as an example below:
248
  {{
249
  "Project.py": {{
250
+ "updates": []
 
 
 
 
 
 
 
251
  }},
252
  "step_handlers.py": {{
253
  "updates": [
254
  {{
255
+ "type": "output", # Must be one of: component, input, output
256
+ "location": "step_handlers.py - Step 3 Output Mapping",
257
+ "explanation": "Mismatch in prompt name; 'generate_Tech_SOW' should be 'generate_Technical_SOW'",
258
+ "old_code": "output_name = 'generate_Tech_SOW'",
259
+ "new_code": "output_name = 'generate_Technical_SOW'"
260
+ }},
261
+ {{
262
+ "type": "component",
263
+ "location": "step_handlers.py - Step 3 Component Names",
264
+ "explanation": "Component names should reflect the correct prompt name",
265
+ "old_code": "generated_Tech_SOW_text, generated_Tech_SOW_markdown",
266
+ "new_code": "generated_Technical_SOW_text, generated_Technical_SOW_markdown"
267
  }}
268
  ]
269
  }}
270
  }}
271
 
272
  Requirements:
273
+ 1. Each update MUST include 'type' field with one of: component, input, output
274
+ 2. Maintain exact function signatures
275
+ 3. Preserve existing code structure
276
+ 4. Only generate the specific changes needed
277
+ 5. Include clear comments explaining changes
278
+ 6. Each file must have an 'updates' array, even if empty
279
 
280
  IMPORTANT: Return ONLY the JSON object, without any markdown formatting or explanation.
 
281
  """
282
 
283
  try:
 
291
  if "step_handlers.py" not in parsed_result:
292
  parsed_result["step_handlers.py"] = {"updates": []}
293
 
294
+ # Ensure updates array exists and has required fields
295
+ for file_updates in parsed_result.values():
296
+ if "updates" not in file_updates:
297
+ file_updates["updates"] = []
298
+ for update in file_updates["updates"]:
299
+ if "type" not in update:
300
+ update["type"] = "component" # Default type if missing
301
+
302
  return parsed_result
303
 
304
  except Exception as e:
 
348
  content = f.read()
349
 
350
  for update in updates:
351
+ if not update.get('type') or not update.get('old_code') or not update.get('new_code'):
352
+ print(f"Skipping invalid update: {update}")
353
+ continue
354
+
355
  if update['type'] == 'component':
356
  # Update component references
357
  content = content.replace(update['old_code'], update['new_code'])
 
362
  content = re.sub(pattern, replacement, content)
363
  elif update['type'] == 'output':
364
  # Update output parameters
365
+ old_code = update['old_code'].strip()
366
+ new_code = update['new_code'].strip()
367
+ content = content.replace(old_code, new_code)
368
 
369
  with open('step_handlers.py', 'w') as f:
370
  f.write(content)
page_prompts_config.py CHANGED
@@ -595,7 +595,7 @@ PROMPTS = {
595
  - Use one of the following:
596
  - Visual Representation: Diagram illustrating workflows or data flows between modules.
597
  - Textual Description: Detailed explanation of the processes and transitions
598
- - Use bullet point, ensure simplicity and avoid overly technical langua
599
  #### **5. Modules and Functional Requirements Breakdown**
600
  - LEAVE THIS BLANK
601
  #### **6. Acceptance Criteria**
 
595
  - Use one of the following:
596
  - Visual Representation: Diagram illustrating workflows or data flows between modules.
597
  - Textual Description: Detailed explanation of the processes and transitions
598
+ - Use bullet point, ensure simplicity and avoid overly technical language
599
  #### **5. Modules and Functional Requirements Breakdown**
600
  - LEAVE THIS BLANK
601
  #### **6. Acceptance Criteria**
step_handlers.py CHANGED
@@ -3,7 +3,7 @@ from Project import *
3
  def setup_all_handlers(step_buttons, all_components, page_progress_update, quotation_cost):
4
  """Set up all step handlers with the provided UI components"""
5
  step_buttons['Step 1 : Scope & Components'].click(
6
- fn=v4_generate_prd_and_components,
7
  inputs=[],
8
  outputs=[
9
  all_components['generate_prd']['generated_prd_text'],
@@ -17,7 +17,7 @@ def setup_all_handlers(step_buttons, all_components, page_progress_update, quota
17
  )
18
 
19
  step_buttons['Step 2 : Planning & Testing Mandays'].click(
20
- fn=v4_generate_mandays_and_quotation,
21
  inputs=[
22
  all_components['generate_plan_test_components']['generated_plan_test_components_text'],
23
  all_components['generate_dev_components']['generated_dev_components_text']
@@ -31,7 +31,7 @@ def setup_all_handlers(step_buttons, all_components, page_progress_update, quota
31
  )
32
 
33
  step_buttons['Step 3 : SOW Doc'].click(
34
- fn=v4_generate_sow,
35
  inputs=[
36
  all_components['generate_prd']['generated_prd_text'],
37
  all_components['generate_plan_test_components']['generated_plan_test_components_text'],
 
3
  def setup_all_handlers(step_buttons, all_components, page_progress_update, quotation_cost):
4
  """Set up all step handlers with the provided UI components"""
5
  step_buttons['Step 1 : Scope & Components'].click(
6
+ fn=state.quotation_project.generate_prd_and_components,
7
  inputs=[],
8
  outputs=[
9
  all_components['generate_prd']['generated_prd_text'],
 
17
  )
18
 
19
  step_buttons['Step 2 : Planning & Testing Mandays'].click(
20
+ fn=state.quotation_project.generate_mandays_and_quotation,
21
  inputs=[
22
  all_components['generate_plan_test_components']['generated_plan_test_components_text'],
23
  all_components['generate_dev_components']['generated_dev_components_text']
 
31
  )
32
 
33
  step_buttons['Step 3 : SOW Doc'].click(
34
+ fn=state.quotation_project.generate_sow,
35
  inputs=[
36
  all_components['generate_prd']['generated_prd_text'],
37
  all_components['generate_plan_test_components']['generated_plan_test_components_text'],