Spaces:
Sleeping
Sleeping
| from app.state.state import OnboardingState | |
| from app.nodes.graphnodes import * | |
| from langgraph.prebuilt import ToolNode ,tools_condition | |
| from langgraph.graph import StateGraph,END,START | |
| from langgraph.types import RetryPolicy | |
| # node_retry = RetryPolicy( | |
| # max_attempts=3, | |
| # initial_interval=1.5, | |
| # retry_on=[ConnectionError] | |
| # ) | |
| builder = StateGraph(OnboardingState) | |
| # Define Nodes | |
| builder.add_node("input_node", input_node) | |
| builder.add_node("resume_data_extraction", extractResumeDataNode) | |
| builder.add_node("skill_gap_analysis", skill_gap_node) | |
| # The ReAct Agent Node | |
| builder.add_node("roadmap_planning_agent", roadmap_planning_node) | |
| # The Tool Execution Node (Required for the loop) | |
| builder.add_node("tools", ToolNode(roadmap_planner_agent_tools)) | |
| # 5. Define Edges and Workflow | |
| builder.add_edge(START, "input_node") | |
| builder.add_edge("input_node", "resume_data_extraction") | |
| # Join Parallel Extractions | |
| builder.add_edge("resume_data_extraction", "skill_gap_analysis") | |
| # Start the Planning Phase | |
| builder.add_edge("skill_gap_analysis", "roadmap_planning_agent") | |
| # Agentic ReAct Loop | |
| builder.add_conditional_edges( | |
| "roadmap_planning_agent", | |
| tools_condition, | |
| { | |
| "tools": "tools", | |
| END: END | |
| } | |
| ) | |
| # Loop back to agent after tool execution | |
| builder.add_edge("tools", "roadmap_planning_agent") | |
| # 6. Compile | |
| graph = builder.compile(debug=True) | |
| # try: | |
| # # This creates a PNG and saves it to your project folder | |
| # graph_png = graph.get_graph().draw_mermaid_png() | |
| # with open("graph.png", "wb") as f: | |
| # f.write(graph_png) | |
| # print("--- Graph image saved as 'graph.png' ---") | |
| # except Exception as e: | |
| # # This happens if you don't have the 'pypydot' or 'graphviz' dependencies | |
| # print(f"Could not generate graph image: {e}") |