|
My Project
|
Functions | |
| InsertionHelperOutput | format_insertion_output (InsertionHelperState state) |
| tool_route (InsertionHelperState state) | |
Variables | |
| PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| CONFIG_PATH = os.path.join(PARENT_DIR, "config.json") | |
| CONFIG = json.load(f) | |
| LOOP_CONFIG = CONFIG["loop_limits"] | |
| tool_node = ToolNode(insertion_tools) | |
| graph_builder = StateGraph(InsertionHelperState, output_schema=InsertionHelperOutput) | |
| insertion_graph = graph_builder.compile() | |
Copyright 2026 Luca Silver Insertion helper subgraph that processes student profile updates (interests and tracked sections). Functions: - `format_insertion_output`: Normalizes insertion helper response into standardized helper output schema. - `tool_route`: Conditionally routes insertion helper loop based on tool calls and loop count. Graph Structure: - START -> insertion_node - insertion_node -> [tool_node | format_insertion_output] (conditional routing based on tool_route) - tool_node -> insertion_node (feedback loop) - format_insertion_output -> END Exports: - `insertion_graph`: Compiled LangGraph insertion helper subgraph. Loop limits are defined in config.json.
| InsertionHelperOutput format_insertion_output | ( | InsertionHelperState | state | ) |
Normalizes the insertion helper response into the helper output schema.
If the last message is a tool message (meaning the insertion helper passed its
loop limit without providing a final answer), the full message history is serialized so
the planner can inspect the tool trail. Otherwise, the final AI message content
is returned directly as the insertion result.
Args:
state (InsertionHelperState): Helper state containing the insertion request
context and the message history produced by the insertion loop.
Returns:
InsertionHelperOutput: Output object containing the formatted insertion result.
| tool_route | ( | InsertionHelperState | state | ) |
Routes the insertion helper loop based on tool usage and loop count.
The insertion helper is allowed a limited number of iterations. If the latest
AI message includes tool calls, the graph routes to the tool node. Otherwise it
formats the output. If the loop limit is reached, the function enforces a final
response path and includes a fallback message when necessary.
Args:
state (InsertionHelperState): Current helper state including messages,
loop counter, and requested insertion content.
Returns:
str: The next node name to execute.
| lg_agent.insertion_helper_graph.CONFIG = json.load(f) |
| lg_agent.insertion_helper_graph.CONFIG_PATH = os.path.join(PARENT_DIR, "config.json") |
| lg_agent.insertion_helper_graph.graph_builder = StateGraph(InsertionHelperState, output_schema=InsertionHelperOutput) |
| lg_agent.insertion_helper_graph.insertion_graph = graph_builder.compile() |
| lg_agent.insertion_helper_graph.LOOP_CONFIG = CONFIG["loop_limits"] |
| lg_agent.insertion_helper_graph.PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) |
| lg_agent.insertion_helper_graph.tool_node = ToolNode(insertion_tools) |