|
My Project
|
Functions | |
| tuple[dict, dict] | _extract_plan (APlannerState state) |
| _plan_value (APlannerState state, str key, default=None) | |
| invoke_db_helper (APlannerState state) | |
| invoke_web_helper (APlannerState state) | |
| route_from_planning (APlannerState state) | |
| APlannerState | answer_node (APlannerState 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"] | |
| graph_builder = StateGraph(APlannerState) | |
| a_planner_node | |
| defer | |
| a_chat_graph = graph_builder.compile() | |
Copyright 2026 Luca Silver Advisor-facing chat agent that routes advisor queries through planning and helper graphs. Functions: - `invoke_db_helper`: Invokes the database helper graph and merges results back to planner state. - `invoke_web_helper`: Invokes the web search helper graph and merges results back to planner state. - `route_from_planning`: Routes the planner's decision to appropriate helper graphs or answer node. Enforces a maximum number of loops before forcing an answer. - `answer_node`: Appends the final planner response to the conversation message history. Graph Structure: - START -> planning - planning -> [invoke_db_helper | invoke_web_helper | answer_node] (conditional) (cam be parallel) - invoke_db_helper -> planning (feedback loop) (deferred) - invoke_web_helper -> planning (feedback loop) (deferred) - answer_node -> END Exports: - `a_chat_graph`: Compiled LangGraph advisor chat agent. Loop limits are defined in config.json.
|
protected |
Safely extracts planner output and nested content dict from state. Some model/tooling paths may produce plan payloads where "content" is a string or missing entirely. This helper normalizes both objects so routing code can perform key lookups without type errors.
|
protected |
Reads a planner field from either top-level plan or nested content.
| APlannerState answer_node | ( | APlannerState | state | ) |
Appends the final planner answer to the conversation state.
Args:
state (APlannerState): Current planner state containing the final answer in
plan["answer"].
Returns:
APlannerState: Updated state with the final AI answer appended to messages.
| invoke_db_helper | ( | APlannerState | state | ) |
Invokes the advisor database helper graph and merges its result back into state.
The advisor planner may request database information about a student or course.
This node forwards that request to the database helper graph, then appends the
returned query/result pair to the accumulated db_info list.
Args:
state (APlannerState): Current planner state containing the selected database
request in plan["info_needed_db"].
Returns:
dict: Partial state update with the updated "db_info" list.
| invoke_web_helper | ( | APlannerState | state | ) |
Invokes the web helper graph and merges its result back into state.
The advisor planner may request web information to support an answer. This node
forwards that request to the web helper graph, then appends the returned
query/result pair to the accumulated web_info list.
Args:
state (APlannerState): Current planner state containing the selected web
request in plan["info_needed_web"].
Returns:
dict: Partial state update with the updated "web_info" list.
| route_from_planning | ( | APlannerState | state | ) |
Chooses which helper graphs to run after planning.
The planner can request database lookups or web lookups, or provide a final
answer directly. This router converts the plan into one or more graph sends.
When both database and web information are requested, they are dispatched in
parallel. If no tools are needed, control routes directly to the answer node.
Args:
state (APlannerState): Current planner state containing the loop counter and
the structured plan produced by the planning node.
Returns:
list[Send]: One or more graph sends describing the next execution branch.
| lg_agent.a_chat_graph.a_chat_graph = graph_builder.compile() |
| lg_agent.a_chat_graph.a_planner_node |
| lg_agent.a_chat_graph.CONFIG = json.load(f) |
| lg_agent.a_chat_graph.CONFIG_PATH = os.path.join(PARENT_DIR, "config.json") |
| lg_agent.a_chat_graph.defer |
| lg_agent.a_chat_graph.graph_builder = StateGraph(APlannerState) |
| lg_agent.a_chat_graph.LOOP_CONFIG = CONFIG["loop_limits"] |
| lg_agent.a_chat_graph.PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) |