agents.react_class.react_v2.utilsΒΆ

Utility functions for creating and customizing ReactAgents.

FunctionsΒΆ

create_agent_with_custom_engine(engine, tools[, name, ...])

Create a ReactAgent with a custom engine configuration.

create_react_agent(tools[, model, system_prompt, ...])

Create a ReactAgent with the specified tools and configuration.

create_structured_react_agent(output_model, tools[, ...])

Create a ReactAgent that produces structured output according to the specified model.

organize_tools_by_category(tools[, categories])

Organize tools into categories for parallel processing.

Module ContentsΒΆ

agents.react_class.react_v2.utils.create_agent_with_custom_engine(engine, tools, name=None, max_iterations=10, parallel_tool_execution=False, max_retries=3, retry_delay=0.5, **kwargs)ΒΆ

Create a ReactAgent with a custom engine configuration.

Parameters:
  • engine (haive.core.engine.aug_llm.AugLLMConfig) – Custom AugLLMConfig

  • tools (haive.agents.react.config.ToolsInput) – Tools available to the agent (list or node mapping)

  • name (str | None) – Optional agent name

  • max_iterations (int) – Maximum number of iterations

  • parallel_tool_execution (bool) – Whether to execute tools in parallel

  • max_retries (int) – Maximum number of retries for tool failures

  • retry_delay (float) – Delay between retry attempts in seconds

  • **kwargs – Additional configuration options

Returns:

Configured ReactAgent instance

Return type:

haive.agents.react.agent.ReactAgent

agents.react_class.react_v2.utils.create_react_agent(tools, model='gpt-4o', system_prompt=None, name=None, max_iterations=10, temperature=0.7, parallel_tool_execution=False, max_retries=3, retry_delay=0.5, **kwargs)ΒΆ

Create a ReactAgent with the specified tools and configuration.

Parameters:
  • tools (haive.agents.react.config.ToolsInput) – Tools available to the agent (list or node mapping)

  • model (str) – The model name to use

  • system_prompt (str | None) – Optional system prompt

  • name (str | None) – Optional agent name

  • max_iterations (int) – Maximum number of iterations

  • temperature (float) – Temperature for LLM generation

  • parallel_tool_execution (bool) – Whether to execute tools in parallel

  • max_retries (int) – Maximum number of retries for tool failures

  • retry_delay (float) – Delay between retry attempts in seconds

  • **kwargs – Additional configuration options

Returns:

Configured ReactAgent instance

Return type:

haive.agents.react.agent.ReactAgent

agents.react_class.react_v2.utils.create_structured_react_agent(output_model, tools, model='gpt-4o', system_prompt=None, name=None, max_iterations=10, temperature=0.7, parallel_tool_execution=False, max_retries=3, retry_delay=0.5, **kwargs)ΒΆ

Create a ReactAgent that produces structured output according to the specified model.

Parameters:
  • output_model (type[pydantic.BaseModel]) – Pydantic model for structured output

  • tools (haive.agents.react.config.ToolsInput) – Tools available to the agent (list or node mapping)

  • model (str) – The model name to use

  • system_prompt (str | None) – Optional system prompt

  • name (str | None) – Optional agent name

  • max_iterations (int) – Maximum number of iterations

  • temperature (float) – Temperature for LLM generation

  • parallel_tool_execution (bool) – Whether to execute tools in parallel

  • max_retries (int) – Maximum number of retries for tool failures

  • retry_delay (float) – Delay between retry attempts in seconds

  • **kwargs – Additional configuration options

Returns:

Configured ReactAgent instance with structured output support

Return type:

haive.agents.react.agent.ReactAgent

agents.react_class.react_v2.utils.organize_tools_by_category(tools, categories=None)ΒΆ

Organize tools into categories for parallel processing.

Parameters:
  • tools (list[langchain_core.tools.BaseTool | langchain_core.tools.StructuredTool | langchain_core.tools.Tool | collections.abc.Callable]) – List of tools to organize

  • categories (dict[str, list[str]] | None) – Optional mapping of category names to tool names

Returns:

Dictionary mapping category names to tool lists

Return type:

dict[str, list[langchain_core.tools.BaseTool | langchain_core.tools.StructuredTool | langchain_core.tools.Tool | collections.abc.Callable]]