haive.agents.discovery.selection_strategies¶
Tool selection strategies for dynamic tool selection.
This module implements various strategies for selecting tools based on different criteria and approaches, providing flexibility in how tools are chosen for different contexts and use cases.
Classes¶
Adaptive selection that learns from usage patterns. |
|
Base class for tool selection strategies. |
|
Capability-based tool selection. |
|
Context-aware tool selection considering conversation history. |
|
Ensemble strategy combining multiple selection approaches. |
|
Selection strategy that learns from user feedback and tool performance. |
|
Semantic similarity-based tool selection. |
Functions¶
|
Create a selection strategy by name. |
Module Contents¶
- class haive.agents.discovery.selection_strategies.AdaptiveSelectionStrategy(learning_rate=0.1)¶
Bases:
BaseSelectionStrategyAdaptive selection that learns from usage patterns.
Init .
- Parameters:
learning_rate (float) – [TODO: Add description]
- async select_tools(query, available_tools, context, max_tools=5)¶
Select tools using adaptive learning.
- Parameters:
query (str)
available_tools (list[haive.agents.discovery.semantic_discovery.ComponentMetadata])
context (haive.agents.discovery.dynamic_tool_selector.ContextAwareState)
max_tools (int)
- Return type:
haive.agents.discovery.dynamic_tool_selector.ToolSelectionResult
- class haive.agents.discovery.selection_strategies.BaseSelectionStrategy¶
Bases:
abc.ABCBase class for tool selection strategies.
- abstractmethod select_tools(query, available_tools, context, max_tools=5)¶
- Async:
- Parameters:
query (str)
available_tools (list[haive.agents.discovery.semantic_discovery.ComponentMetadata])
context (haive.agents.discovery.dynamic_tool_selector.ContextAwareState)
max_tools (int)
- Return type:
haive.agents.discovery.dynamic_tool_selector.ToolSelectionResult
Select tools based on strategy.
- class haive.agents.discovery.selection_strategies.CapabilityBasedStrategy(capability_weights=None)¶
Bases:
BaseSelectionStrategyCapability-based tool selection.
Init .
- async select_tools(query, available_tools, context, max_tools=5)¶
Select tools based on capability matching.
- Parameters:
query (str)
available_tools (list[haive.agents.discovery.semantic_discovery.ComponentMetadata])
context (haive.agents.discovery.dynamic_tool_selector.ContextAwareState)
max_tools (int)
- Return type:
haive.agents.discovery.dynamic_tool_selector.ToolSelectionResult
- class haive.agents.discovery.selection_strategies.ContextualSelectionStrategy(context_weight=0.3)¶
Bases:
BaseSelectionStrategyContext-aware tool selection considering conversation history.
Init .
- Parameters:
context_weight (float) – [TODO: Add description]
- async select_tools(query, available_tools, context, max_tools=5)¶
Select tools considering full context.
- Parameters:
query (str)
available_tools (list[haive.agents.discovery.semantic_discovery.ComponentMetadata])
context (haive.agents.discovery.dynamic_tool_selector.ContextAwareState)
max_tools (int)
- Return type:
haive.agents.discovery.dynamic_tool_selector.ToolSelectionResult
- class haive.agents.discovery.selection_strategies.EnsembleSelectionStrategy(strategies=None)¶
Bases:
BaseSelectionStrategyEnsemble strategy combining multiple selection approaches.
Init .
- Parameters:
strategies (list[BaseSelectionStrategy] | None) – [TODO: Add description]
- async select_tools(query, available_tools, context, max_tools=5)¶
Select tools using ensemble of strategies.
- Parameters:
query (str)
available_tools (list[haive.agents.discovery.semantic_discovery.ComponentMetadata])
context (haive.agents.discovery.dynamic_tool_selector.ContextAwareState)
max_tools (int)
- Return type:
haive.agents.discovery.dynamic_tool_selector.ToolSelectionResult
- class haive.agents.discovery.selection_strategies.LearningSelectionStrategy¶
Bases:
BaseSelectionStrategySelection strategy that learns from user feedback and tool performance.
Init .
- Returns:
Add return description]
- Return type:
[TODO
- add_feedback(tool_name, rating, context, feedback_data)¶
Add user feedback for learning.
- async select_tools(query, available_tools, context, max_tools=5)¶
Select tools using learned patterns and feedback.
- Parameters:
query (str)
available_tools (list[haive.agents.discovery.semantic_discovery.ComponentMetadata])
context (haive.agents.discovery.dynamic_tool_selector.ContextAwareState)
max_tools (int)
- Return type:
haive.agents.discovery.dynamic_tool_selector.ToolSelectionResult
- class haive.agents.discovery.selection_strategies.SemanticSelectionStrategy(similarity_threshold=0.7)¶
Bases:
BaseSelectionStrategySemantic similarity-based tool selection.
Init .
- Parameters:
similarity_threshold (float) – [TODO: Add description]
- async select_tools(query, available_tools, context, max_tools=5)¶
Select tools based on semantic similarity to query.
- Parameters:
query (str)
available_tools (list[haive.agents.discovery.semantic_discovery.ComponentMetadata])
context (haive.agents.discovery.dynamic_tool_selector.ContextAwareState)
max_tools (int)
- Return type:
haive.agents.discovery.dynamic_tool_selector.ToolSelectionResult