AgentExecutorIterator#
- class langchain.agents.agent_iterator.AgentExecutorIterator(
- agent_executor: AgentExecutor,
- inputs: Any,
- callbacks: Callbacks = None,
- *,
- tags: list[str] | None = None,
- metadata: dict[str, Any] | None = None,
- run_name: str | None = None,
- run_id: UUID | None = None,
- include_run_info: bool = False,
- yield_actions: bool = False,
Iterator for AgentExecutor.
Initialize the AgentExecutorIterator with the given AgentExecutor, inputs, and optional callbacks.
- Parameters:
agent_executor (AgentExecutor) – The AgentExecutor to iterate over.
inputs (Any) – The inputs to the AgentExecutor.
callbacks (Callbacks, optional) – The callbacks to use during iteration. Defaults to None.
tags (Optional[list[str]], optional) – The tags to use during iteration. Defaults to None.
metadata (Optional[Dict[str, Any]], optional) – The metadata to use during iteration. Defaults to None.
run_name (Optional[str], optional) – The name of the run. Defaults to None.
run_id (Optional[UUID], optional) – The ID of the run. Defaults to None.
include_run_info (bool, optional) – Whether to include run info in the output. Defaults to False.
yield_actions (bool, optional) – Whether to yield actions as they are generated. Defaults to False.
Attributes
agent_executor
The AgentExecutor to iterate over.
color_mapping
A mapping of tool names to colors.
inputs
The inputs to the AgentExecutor.
name_to_tool_map
A mapping of tool names to tools.
Methods
__init__
(agent_executor, inputs[, ...])Initialize the AgentExecutorIterator with the given AgentExecutor, inputs, and optional callbacks.
make_final_outputs
(outputs, run_manager)Make final outputs for the iterator.
reset
()Reset the iterator to its initial state, clearing intermediate steps, iterations, and time elapsed.
Increment the number of iterations and update the time elapsed.
- __init__(
- agent_executor: AgentExecutor,
- inputs: Any,
- callbacks: Callbacks = None,
- *,
- tags: list[str] | None = None,
- metadata: dict[str, Any] | None = None,
- run_name: str | None = None,
- run_id: UUID | None = None,
- include_run_info: bool = False,
- yield_actions: bool = False,
Initialize the AgentExecutorIterator with the given AgentExecutor, inputs, and optional callbacks.
- Parameters:
agent_executor (AgentExecutor) – The AgentExecutor to iterate over.
inputs (Any) – The inputs to the AgentExecutor.
callbacks (Callbacks, optional) – The callbacks to use during iteration. Defaults to None.
tags (Optional[list[str]], optional) – The tags to use during iteration. Defaults to None.
metadata (Optional[Dict[str, Any]], optional) – The metadata to use during iteration. Defaults to None.
run_name (Optional[str], optional) – The name of the run. Defaults to None.
run_id (Optional[UUID], optional) – The ID of the run. Defaults to None.
include_run_info (bool, optional) – Whether to include run info in the output. Defaults to False.
yield_actions (bool, optional) – Whether to yield actions as they are generated. Defaults to False.
- make_final_outputs(
- outputs: dict[str, Any],
- run_manager: CallbackManagerForChainRun | AsyncCallbackManagerForChainRun,
Make final outputs for the iterator.
- Parameters:
outputs (dict[str, Any]) – The outputs from the agent executor.
run_manager (CallbackManagerForChainRun | AsyncCallbackManagerForChainRun) – The run manager to use for callbacks.
- Return type: