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)[source]#

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)

reset()

Reset the iterator to its initial state, clearing intermediate steps, iterations, and time elapsed.

update_iterations()

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)[source]#

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) β†’ AddableDict[source]#
Parameters:
Return type:

AddableDict

reset() β†’ None[source]#

Reset the iterator to its initial state, clearing intermediate steps, iterations, and time elapsed.

Return type:

None

update_iterations() β†’ None[source]#

Increment the number of iterations and update the time elapsed.

Return type:

None