agents.react_class.react_agent2.dynamic_agentΒΆ
Dynamic React Agent - an extension of React agent with tool selection capabilities.
ClassesΒΆ
A React agent with dynamic tool selection. |
|
Configuration for a React agent with dynamic tool selection. |
|
Extended schema for dynamic tool selection. |
FunctionsΒΆ
|
Create a dynamic react agent with minimal configuration. |
Module ContentsΒΆ
- class agents.react_class.react_agent2.dynamic_agent.DynamicReactAgent(config)ΒΆ
Bases:
haive.agents.react_class.react_agent2.agent2.ReactAgent
A React agent with dynamic tool selection.
This agent extends the React pattern with dynamic tool selection, making it efficient when dealing with a large number of tools.
Initialize the dynamic react agent.
- Parameters:
config (DynamicReactAgentConfig)
- register_tools(tools)ΒΆ
Register tools with the agent and create tool embeddings.
- Parameters:
tools (list[langchain_core.tools.BaseTool]) β List of tools to register
- Return type:
None
- run(input_data, **kwargs)ΒΆ
Run the agent with the given input.
- setup_workflow()ΒΆ
Set up the workflow with dynamic tool selection.
- Return type:
None
- property vector_store: AnyΒΆ
Get the vector store property.
- Return type:
Any
- class agents.react_class.react_agent2.dynamic_agent.DynamicReactAgentConfigΒΆ
Bases:
haive.agents.react_class.react_agent2.config2.ReactAgentConfig
Configuration for a React agent with dynamic tool selection.
This agent can handle a large number of tools by dynamically selecting which tools to make available to the LLM based on the context.
- classmethod from_tools(tools, system_prompt=None, model='gpt-4o', temperature=0.7, name=None, max_tools_per_turn=5, max_iterations=10, response_format=None, use_memory=True, visualize=True, repeat_selection=True, **kwargs)ΒΆ
Create a DynamicReactAgentConfig from a list of tools.
- Parameters:
tools (list[langchain_core.tools.BaseTool]) β List of tools to use
system_prompt (str | None) β Optional system prompt
model (str) β Model name
temperature (float) β Temperature for generation
name (str | None) β Optional agent name
max_tools_per_turn (int) β Maximum number of tools to select per turn
max_iterations (int) β Maximum iterations for React agent
response_format (type[pydantic.BaseModel] | dict[str, Any] | None) β Optional structured output model
use_memory (bool) β Whether to use memory
visualize (bool) β Whether to visualize the graph
repeat_selection (bool) β Whether to repeat tool selection after each tool invocation
**kwargs β Additional kwargs for the config
- Returns:
DynamicReactAgentConfig instance
- Return type:
- class agents.react_class.react_agent2.dynamic_agent.DynamicReactAgentState(/, **data)ΒΆ
Bases:
haive.agents.react_class.react_agent2.state2.ReactAgentState
Extended schema for dynamic tool selection.
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.
- Parameters:
data (Any)
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- agents.react_class.react_agent2.dynamic_agent.create_dynamic_react_agent(tools, system_prompt=None, model='gpt-4o', temperature=0.7, name=None, max_tools_per_turn=5, max_iterations=10, response_format=None, use_memory=True, visualize=True, repeat_selection=True, vector_store_config=None, tool_documents=None, **kwargs)ΒΆ
Create a dynamic react agent with minimal configuration.
- Parameters:
tools (list[langchain_core.tools.BaseTool]) β List of tools the agent can use
system_prompt (str | None) β Optional system prompt
model (str) β Model name to use
temperature (float) β Temperature for generation
name (str | None) β Optional agent name
max_tools_per_turn (int) β Maximum number of tools to select per turn
max_iterations (int) β Maximum iterations for React agent
response_format (type[pydantic.BaseModel] | dict[str, Any] | None) β Optional structured output model
use_memory (bool) β Whether to use memory
visualize (bool) β Whether to visualize the graph
repeat_selection (bool) β Whether to repeat tool selection after each tool invocation
vector_store_config (haive.core.models.vectorstore.base.VectorStoreConfig | None) β Optional vector store configuration
tool_documents (list[langchain_core.documents.Document] | None) β Optional pre-created tool documents
**kwargs β Additional configuration parameters
- Returns:
DynamicReactAgent instance
- Return type: