WebashalarForML commited on
Commit
da99536
·
verified ·
1 Parent(s): 3aae586

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -656,8 +656,8 @@ def declaration_planner_node(state: GameState):
656
  logger.info("Declaration plan successfully generated.")
657
 
658
  # Save debug
659
- with open("debug_declaration_plan.json", "w", encoding="utf-8") as f:
660
- json.dump(declaration_plan, f, indent=2, ensure_ascii=False)
661
 
662
  return state
663
 
@@ -889,8 +889,8 @@ def declaration_builder_node(state: GameState):
889
  state["project_json"] = project_json
890
  logger.info("Declaration builder node finished updating project JSON.")
891
 
892
- with open("debug_state.json", "w", encoding="utf-8") as f:
893
- json.dump(state, f, indent=2, ensure_ascii=False)
894
 
895
  print("Updated project JSON after declarations:", json.dumps(project_json, indent=2))
896
  return state
@@ -1166,8 +1166,8 @@ def overall_planner_node(state: GameState):
1166
  state["action_plan"] = overall_plan
1167
  logger.info("Overall plan generated by OverallPlannerNode.")
1168
 
1169
- with open("debug_state.json", "w", encoding="utf-8") as f:
1170
- json.dump(state, f, indent=2, ensure_ascii=False)
1171
 
1172
  return state
1173
 
@@ -1428,8 +1428,8 @@ def plan_verification_node(state: GameState):
1428
  state["plan_validation_feedback"] = "Max iterations reached, stopping further improvements."
1429
  state["iteration_count"] = 0 # Reset iteration count as improvement loop is stopping
1430
  print(f"[updated action_plan after verification] on ({current_iteration}): {json.dumps(state.get('action_plan', {}), indent=2)}")
1431
- with open("debug_state.json", "w", encoding="utf-8") as f:
1432
- json.dump(state, f, indent=2, ensure_ascii=False)
1433
  return state
1434
  # --- End of Optimized Logic ---
1435
 
@@ -1575,8 +1575,8 @@ def plan_verification_node(state: GameState):
1575
  logger.info(f"Verification completed. Needs Improvement: {state['needs_improvement']}. Feedback: {state['plan_validation_feedback'][:100]}...")
1576
  print(f"[updated action_plan after verification] on ({current_iteration}): {json.dumps(state.get('action_plan', {}), indent=2)}")
1577
 
1578
- with open("debug_state.json", "w", encoding="utf-8") as f:
1579
- json.dump(state, f, indent=2, ensure_ascii=False)
1580
 
1581
  return state
1582
  except Exception as e:
@@ -1864,8 +1864,8 @@ def refined_planner_node(state: GameState):
1864
  print("[Refined Action Plan]:", json.dumps(state["action_plan"], indent=2))
1865
  #print("[current state after refinement]:", json.dumps(state, indent=2))
1866
 
1867
- with open("debug_state.json", "w", encoding="utf-8") as f:
1868
- json.dump(state, f, indent=2, ensure_ascii=False)
1869
 
1870
  return state
1871
  except Exception as e:
@@ -2389,8 +2389,8 @@ def overall_block_builder_node(state: dict):
2389
  combined_blocks[op] = merged
2390
 
2391
  print(f"[Combined blocks for this script for event {event_opcode}]: {json.dumps(combined_blocks, indent=2)}")
2392
- with open("debug_combine_blocks.json", "w", encoding="utf-8") as f:
2393
- json.dump(combined_blocks, f, indent=2, ensure_ascii=False)
2394
 
2395
  # --- LLM Block Generation Prompt (Self-Contained and Explicit) ---
2396
  # All necessary instructions and context are directly included in the prompt.
@@ -2738,8 +2738,8 @@ def overall_block_builder_node(state: dict):
2738
  state["project_json"] = project_json
2739
  logger.info("Updated project JSON with action nodes.")
2740
 
2741
- with open("debug_state.json", "w", encoding="utf-8") as f:
2742
- json.dump(state, f, indent=2, ensure_ascii=False)
2743
 
2744
  print("Updated project JSON with action nodes:", json.dumps(project_json, indent=2))
2745
  return state
@@ -3265,8 +3265,8 @@ def block_verification_node(state: dict) -> dict:
3265
  print(f"[BLOCK VERIFICATION NODE: (improvement_plan)]:{state.get('improvement_plan')}")
3266
  print(f"[BLOCK VERIFICATION NODE: (review_block_feedback)]:{state.get('review_block_feedback')}")
3267
 
3268
- with open("debug_state.json", "w", encoding="utf-8") as f:
3269
- json.dump(state, f, indent=2, ensure_ascii=False)
3270
 
3271
  return state
3272
 
@@ -3638,8 +3638,8 @@ def improvement_block_builder_node(state: GameState):
3638
  logger.info("Updated project JSON with improvement nodes.")
3639
  print("Updated project JSON with improvement nodes:", json.dumps(project_json, indent=2)) # Print for direct visibility
3640
 
3641
- with open("debug_state.json", "w", encoding="utf-8") as f:
3642
- json.dump(state, f, indent=2, ensure_ascii=False)
3643
 
3644
  return state
3645
 
@@ -4002,8 +4002,8 @@ def get_asset(project_id, filename):
4002
  # In a real application, app_graph would be properly initialized.
4003
  try:
4004
  png_bytes = app_graph.get_graph().draw_mermaid_png()
4005
- with open("langgraph_workflow.png", "wb") as f:
4006
- f.write(png_bytes)
4007
  except Exception as e:
4008
  logger.warning(f"Could not draw or save LangGraph workflow diagram: {e}. This might be expected if app_graph is a mock.")
4009
 
 
656
  logger.info("Declaration plan successfully generated.")
657
 
658
  # Save debug
659
+ #with open("debug_declaration_plan.json", "w", encoding="utf-8") as f:
660
+ # json.dump(declaration_plan, f, indent=2, ensure_ascii=False)
661
 
662
  return state
663
 
 
889
  state["project_json"] = project_json
890
  logger.info("Declaration builder node finished updating project JSON.")
891
 
892
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
893
+ # json.dump(state, f, indent=2, ensure_ascii=False)
894
 
895
  print("Updated project JSON after declarations:", json.dumps(project_json, indent=2))
896
  return state
 
1166
  state["action_plan"] = overall_plan
1167
  logger.info("Overall plan generated by OverallPlannerNode.")
1168
 
1169
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
1170
+ # json.dump(state, f, indent=2, ensure_ascii=False)
1171
 
1172
  return state
1173
 
 
1428
  state["plan_validation_feedback"] = "Max iterations reached, stopping further improvements."
1429
  state["iteration_count"] = 0 # Reset iteration count as improvement loop is stopping
1430
  print(f"[updated action_plan after verification] on ({current_iteration}): {json.dumps(state.get('action_plan', {}), indent=2)}")
1431
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
1432
+ # json.dump(state, f, indent=2, ensure_ascii=False)
1433
  return state
1434
  # --- End of Optimized Logic ---
1435
 
 
1575
  logger.info(f"Verification completed. Needs Improvement: {state['needs_improvement']}. Feedback: {state['plan_validation_feedback'][:100]}...")
1576
  print(f"[updated action_plan after verification] on ({current_iteration}): {json.dumps(state.get('action_plan', {}), indent=2)}")
1577
 
1578
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
1579
+ # json.dump(state, f, indent=2, ensure_ascii=False)
1580
 
1581
  return state
1582
  except Exception as e:
 
1864
  print("[Refined Action Plan]:", json.dumps(state["action_plan"], indent=2))
1865
  #print("[current state after refinement]:", json.dumps(state, indent=2))
1866
 
1867
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
1868
+ # json.dump(state, f, indent=2, ensure_ascii=False)
1869
 
1870
  return state
1871
  except Exception as e:
 
2389
  combined_blocks[op] = merged
2390
 
2391
  print(f"[Combined blocks for this script for event {event_opcode}]: {json.dumps(combined_blocks, indent=2)}")
2392
+ #with open("debug_combine_blocks.json", "w", encoding="utf-8") as f:
2393
+ # json.dump(combined_blocks, f, indent=2, ensure_ascii=False)
2394
 
2395
  # --- LLM Block Generation Prompt (Self-Contained and Explicit) ---
2396
  # All necessary instructions and context are directly included in the prompt.
 
2738
  state["project_json"] = project_json
2739
  logger.info("Updated project JSON with action nodes.")
2740
 
2741
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
2742
+ # json.dump(state, f, indent=2, ensure_ascii=False)
2743
 
2744
  print("Updated project JSON with action nodes:", json.dumps(project_json, indent=2))
2745
  return state
 
3265
  print(f"[BLOCK VERIFICATION NODE: (improvement_plan)]:{state.get('improvement_plan')}")
3266
  print(f"[BLOCK VERIFICATION NODE: (review_block_feedback)]:{state.get('review_block_feedback')}")
3267
 
3268
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
3269
+ # json.dump(state, f, indent=2, ensure_ascii=False)
3270
 
3271
  return state
3272
 
 
3638
  logger.info("Updated project JSON with improvement nodes.")
3639
  print("Updated project JSON with improvement nodes:", json.dumps(project_json, indent=2)) # Print for direct visibility
3640
 
3641
+ #with open("debug_state.json", "w", encoding="utf-8") as f:
3642
+ # json.dump(state, f, indent=2, ensure_ascii=False)
3643
 
3644
  return state
3645
 
 
4002
  # In a real application, app_graph would be properly initialized.
4003
  try:
4004
  png_bytes = app_graph.get_graph().draw_mermaid_png()
4005
+ #with open("langgraph_workflow.png", "wb") as f:
4006
+ # f.write(png_bytes)
4007
  except Exception as e:
4008
  logger.warning(f"Could not draw or save LangGraph workflow diagram: {e}. This might be expected if app_graph is a mock.")
4009