nat.agent.tool_calling_agent.agent#
Attributes#
Classes#
State schema for the Tool Calling Agent Graph |
|
Configurable LangGraph Tool Calling Agent. A Tool Calling Agent requires an LLM which supports tool calling. |
Functions#
|
Create a Tool Calling Agent prompt from the config. |
Module Contents#
- logger#
- class ToolCallAgentGraphState(/, **data: Any)#
Bases:
pydantic.BaseModelState schema for the Tool Calling Agent Graph
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.
- class ToolCallAgentGraph(
- llm: langchain_core.language_models.BaseChatModel,
- tools: list[langchain_core.tools.BaseTool],
- prompt: str | None = None,
- callbacks: list[langchain_core.callbacks.base.AsyncCallbackHandler] = None,
- detailed_logs: bool = False,
- log_response_max_chars: int = 1000,
- handle_tool_errors: bool = True,
- return_direct: list[langchain_core.tools.BaseTool] | None = None,
Bases:
nat.agent.dual_node.DualNodeAgentConfigurable LangGraph Tool Calling Agent. A Tool Calling Agent requires an LLM which supports tool calling. A tool Calling Agent utilizes the tool input parameters to select the optimal tool. Supports handling tool errors. Argument “detailed_logs” toggles logging of inputs, outputs, and intermediate steps.
- agent#
- tool_caller#
- return_direct = []#
- async agent_node(state: ToolCallAgentGraphState)#
- async conditional_edge(state: ToolCallAgentGraphState)#
- async tool_node(state: ToolCallAgentGraphState)#
- async tool_conditional_edge(
- state: ToolCallAgentGraphState,
Determines whether to continue to the agent or end graph execution after a tool call.
- Args:
state: The current state of the Tool Calling Agent graph containing messages and tool responses.
- Returns:
AgentDecision: TOOL to continue to agent for processing, or END to terminate graph execution. Returns END if the tool is in return_direct list, otherwise returns TOOL to continue processing.
- async build_graph() langgraph.graph.state.CompiledStateGraph#