aiq.agent.react_agent.agent#

Attributes#

Classes#

ReActGraphState

State schema for the ReAct Agent Graph

ReActAgentGraph

Configurable LangGraph ReAct Agent. A ReAct Agent performs reasoning inbetween tool calls, and utilizes the tool

Module Contents#

logger#
TOOL_NOT_FOUND_ERROR_MESSAGE = 'There is no tool named {tool_name}. Tool must be one of {tools}.'#
INPUT_SCHEMA_MESSAGE = '. Arguments must be provided as a valid JSON object following this format: {schema}'#
class ReActGraphState(/, **data: Any)#

Bases: pydantic.BaseModel

State schema for the ReAct 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.

self is explicitly positional-only to allow self as a field name.

messages: list[langchain_core.messages.base.BaseMessage] = None#
agent_scratchpad: list[langchain_core.agents.AgentAction] = None#
tool_responses: list[langchain_core.messages.base.BaseMessage] = None#
class ReActAgentGraph(
llm: langchain_core.language_models.BaseChatModel,
prompt: langchain_core.prompts.chat.ChatPromptTemplate,
tools: list[langchain_core.tools.BaseTool],
use_tool_schema: bool = True,
callbacks: list[langchain_core.callbacks.base.AsyncCallbackHandler] = None,
detailed_logs: bool = False,
retry_parsing_errors: bool = True,
max_retries: int = 1,
)#

Bases: aiq.agent.base.BaseAgent

Configurable LangGraph ReAct Agent. A ReAct Agent performs reasoning inbetween tool calls, and utilizes the tool names and descriptions to select the optimal tool. Supports retrying on output parsing errors. Argument “detailed_logs” toggles logging of inputs, outputs, and intermediate steps.

retry_parsing_errors = True#
max_tries = 2#
agent#
tools_dict#
_get_tool(tool_name)#
async agent_node(state: ReActGraphState)#
async conditional_edge(state: ReActGraphState)#
async tool_node(state: ReActGraphState)#
async build_graph()#
static validate_system_prompt(system_prompt: str) bool#