agents.discovery.semantic_discoveryΒΆ
Semantic Discovery Engine with Vector-Based Tool Selection.
This module implements semantic discovery capabilities inspired by LangGraphβs many-tools pattern, using vector embeddings to match tools and components based on query content and semantic similarity.
Key Features: - Vector-based tool discovery and ranking - Semantic capability matching - Query analysis and tool recommendation - Dynamic tool binding and selection - Context-aware component matching
ClassesΒΆ
Matches tools based on required capabilities. |
|
Different modes for semantic discovery. |
|
Analysis of user query for tool selection. |
|
Analyzes queries to extract relevant information for tool selection. |
|
Main semantic discovery engine combining all capabilities. |
|
Strategies for tool selection. |
|
Selects tools using vector similarity search. |
FunctionsΒΆ
|
Create Component Registry. |
Create a semantic discovery engine with default configuration. |
Module ContentsΒΆ
- class agents.discovery.semantic_discovery.CapabilityMatcher(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Matches tools based on required capabilities.
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)
- class agents.discovery.semantic_discovery.DiscoveryModeΒΆ
-
Different modes for semantic discovery.
Initialize self. See help(type(self)) for accurate signature.
- class agents.discovery.semantic_discovery.QueryAnalysisΒΆ
Analysis of user query for tool selection.
- class agents.discovery.semantic_discovery.QueryAnalyzer(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Analyzes queries to extract relevant information for 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)
- class agents.discovery.semantic_discovery.SemanticDiscoveryEngine(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Main semantic discovery engine combining all capabilities.
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)
- async discover_tools(tools=None, haive_root=None)ΒΆ
Discover available tools.
- async get_tools_for_capabilities(required_capabilities, optional_capabilities=None, max_tools=5)ΒΆ
Get tools that match specific capabilities.
- async semantic_tool_selection(query, max_tools=5, strategy=ToolSelectionStrategy.HYBRID, capability_filter=None)ΒΆ
Perform semantic tool selection for a query.
- Parameters:
query (str)
max_tools (int)
strategy (ToolSelectionStrategy)
- Return type:
tuple[list[haive.core.registry.ComponentMetadata], QueryAnalysis]
- setup_registry()ΒΆ
Setup shared component registry.
- Return type:
- class agents.discovery.semantic_discovery.ToolSelectionStrategyΒΆ
-
Strategies for tool selection.
Initialize self. See help(type(self)) for accurate signature.
- class agents.discovery.semantic_discovery.VectorBasedToolSelector(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Selects tools using vector similarity search.
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)
- index_tools(tools)ΒΆ
Index tools in vector store and component registry.
- Parameters:
tools (list[Any])
- Return type:
None
- async select_tools(query, strategy=ToolSelectionStrategy.TOP_K)ΒΆ
Select tools based on query using specified strategy.
- Parameters:
query (str)
strategy (ToolSelectionStrategy)
- Return type:
list[haive.core.registry.ComponentMetadata]
- setup_vector_store()ΒΆ
Setup vector store if not provided.
- Return type:
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- agents.discovery.semantic_discovery.create_component_registry(**kwargs)ΒΆ
Create Component Registry.
- agents.discovery.semantic_discovery.create_semantic_discovery()ΒΆ
Create a semantic discovery engine with default configuration.
- Return type: