dataflow.api.routes.tools_routes_enhanced¶
Enhanced Tools Discovery API Routes using Haive Core’s unified discovery. system.
This module provides FastAPI routes for discovering, managing, and invoking tools using the unified discovery system from haive-core. It supports both individual tools and toolkits with comprehensive schema extraction.
- Key Features:
Unified tool discovery using haive-core’s discovery system
Support for both individual tools and toolkits
Schema extraction and validation
Tool invocation capabilities
Category-based organization
Performance caching
Examples
from fastapi import FastAPI from haive.dataflow.api.routes.tools_routes_enhanced import router
app = FastAPI() app.include_router(router, prefix=”/api/v1”)
# Endpoints available: # GET /api/v1/tools - List all tools # GET /api/v1/tools/search - Search tools # GET /api/v1/tools/{tool_name}/schema - Get tool schema # POST /api/v1/tools/invoke - Invoke a tool
Note
This implementation uses the fixed circular import pattern from haive-core to properly integrate with the discovery system.
Classes¶
Information about a discovered tool or toolkit. |
|
Tool input/output schema information. |
|
Response for tools list endpoints. |
Functions¶
|
Convert a ComponentInfo to ToolInfo. |
|
Discover all tools using the unified discovery system. |
|
Extract schema information from a tool component. |
Get all available tool categories and their tools. |
|
|
Get the input/output schema for a specific tool. |
Get statistics about discovered tools. |
|
|
Infer tool category from component information. |
|
List all available tools with optional filtering. |
|
Search tools by name, description, or module path. |
Module Contents¶
- class dataflow.api.routes.tools_routes_enhanced.ToolInfo(/, **data)¶
Bases:
pydantic.BaseModel
Information about a discovered tool or toolkit.
- Parameters:
data (Any)
- name¶
Tool identifier name.
- description¶
Human-readable description.
- module¶
Full module path to the tool.
- type¶
Type of tool (‘tool’ for individual, ‘toolkit’ for collection).
- category¶
Category for grouping (e.g., ‘search’, ‘database’).
- has_schema¶
Whether the tool has a defined input schema.
- metadata¶
Additional metadata from discovery.
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.
- class dataflow.api.routes.tools_routes_enhanced.ToolSchema(/, **data)¶
Bases:
pydantic.BaseModel
Tool input/output schema information.
- Parameters:
data (Any)
- name¶
Tool name.
- description¶
Tool description.
- input_schema¶
JSON Schema for tool input parameters.
- output_schema¶
JSON Schema for tool output (if available).
- examples¶
Usage examples (if available).
- metadata¶
Additional schema metadata.
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.
- class dataflow.api.routes.tools_routes_enhanced.ToolsListResponse(/, **data)¶
Bases:
pydantic.BaseModel
Response for tools list endpoints.
- Parameters:
data (Any)
- tools¶
List of discovered tools with metadata.
- count¶
Total number of tools and toolkits.
- tool_count¶
Number of individual tools.
- toolkit_count¶
Number of toolkits.
- discovery_method¶
Method used for discovery.
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.
- dataflow.api.routes.tools_routes_enhanced.component_to_tool_info(component)¶
Convert a ComponentInfo to ToolInfo.
- Parameters:
component (haive.dataflow.api.routes.utils.haive_discovery.ComponentInfo) – ComponentInfo object from discovery.
- Returns:
Structured tool information for API response.
- Return type:
- dataflow.api.routes.tools_routes_enhanced.discover_all_tools(force_refresh=False)¶
Discover all tools using the unified discovery system.
- Parameters:
force_refresh (bool) – If True, bypasses cache and rediscovers all tools.
- Returns:
List of discovered tool components including both individual tools and toolkits.
- Return type:
List[ComponentInfo]
Note
Uses haive-core’s discover_tools_with_schemas for comprehensive discovery with schema extraction.
- dataflow.api.routes.tools_routes_enhanced.extract_tool_schema(component)¶
Extract schema information from a tool component.
- Parameters:
component (haive.dataflow.api.routes.utils.haive_discovery.ComponentInfo) – ComponentInfo object representing a tool.
- Returns:
Extracted schema or None if not available.
- Return type:
Optional[Dict[str, Any]]
Note
Attempts multiple strategies to extract schema: 1. From metadata ‘schema’ field 2. From LangChain tool args_schema 3. From custom get_input_schema method 4. From Pydantic model if available
- async dataflow.api.routes.tools_routes_enhanced.get_tool_categories()¶
Get all available tool categories and their tools.
- Returns:
Dictionary mapping category names to sorted lists of tool names in each category.
- Return type:
Examples
GET /api/v1/tools/categories
Response: {
“search”: [“GoogleSearchTool”, “BingSearchTool”], “database”: [“SQLDatabaseToolkit”, “MongoDBToolkit”], “development”: [“GithubToolkit”, “GitLabToolkit”]
}
- async dataflow.api.routes.tools_routes_enhanced.get_tool_schema_endpoint(tool_name)¶
Get the input/output schema for a specific tool.
- Parameters:
tool_name (str) – Name of the tool to get schema for. Case-sensitive exact matching is used.
- Returns:
- Schema information including:
Input parameter schema (JSON Schema format)
Output schema if available
Usage examples if available
- Return type:
- Raises:
HTTPException – 404 if tool is not found.
Examples
GET /api/v1/tools/GoogleSearchTool/schema
- async dataflow.api.routes.tools_routes_enhanced.get_tool_stats()¶
Get statistics about discovered tools.
- Returns:
- Statistics including:
total_tools: Total number of tools and toolkits
individual_tools: Number of individual tools
toolkits: Number of toolkits
categories: Count by category
with_schema: Number of tools with schemas
discovery_method: Method used
last_updated: Cache timestamp
- Return type:
Dict[str, Any]
Examples
GET /api/v1/tools/stats
Response: {
“total_tools”: 50, “individual_tools”: 35, “toolkits”: 15, “categories”: {
“search”: 8, “database”: 10, “development”: 12
}, “with_schema”: 45
}
- dataflow.api.routes.tools_routes_enhanced.infer_tool_category(component)¶
Infer tool category from component information.
- Parameters:
component (haive.dataflow.api.routes.utils.haive_discovery.ComponentInfo) – ComponentInfo object representing a tool.
- Returns:
Inferred category name.
- Return type:
Note
Categories are inferred from: 1. Metadata ‘category’ field 2. Module path keywords 3. Tool name patterns
- async dataflow.api.routes.tools_routes_enhanced.list_tools(tool_type=Query(None, description='Filter by type (tool, toolkit)'), category=Query(None, description='Filter by category'), force_refresh=Query(False, description='Force refresh discovery cache'))¶
List all available tools with optional filtering.
- Parameters:
- Returns:
- Response containing:
List of discovered tools with metadata
Count statistics
Discovery method information
- Return type:
Examples
GET /api/v1/tools?tool_type=toolkit&category=search
- async dataflow.api.routes.tools_routes_enhanced.search_tools(query=Query(..., description='Search query'), tool_type=Query(None, description='Filter by type'), category=Query(None, description='Filter by category'))¶
Search tools by name, description, or module path.
- Parameters:
- Returns:
Filtered list of tools matching the search criteria.
- Return type:
Examples
GET /api/v1/tools/search?query=google&tool_type=toolkit