haive.core.engine.tool.engine¶
Rebuilt ToolEngine with universal typing and advanced features.
Classes¶
Enhanced tool engine with universal typing and property analysis. |
Module Contents¶
- class haive.core.engine.tool.engine.ToolEngine[source]¶
Bases:
haive.core.engine.base.InvokableEngine
[dict
[str
,Any
],dict
[str
,Any
]]Enhanced tool engine with universal typing and property analysis.
This engine manages tools with comprehensive property analysis, capability-based routing, and state interaction tracking.
- classmethod augment_tool(tool, *, name=None, description=None, make_interruptible=False, interrupt_message='Tool execution interrupted', reads_state=False, writes_state=False, state_keys=None, structured_output_model=None)[source]¶
Augment an existing tool with additional capabilities.
This method adds capabilities to a tool without creating nested wrappers. All capabilities are added directly to the tool instance.
- Parameters:
tool (langchain_core.tools.StructuredTool | langchain_core.tools.base.BaseTool | collections.abc.Callable[Ellipsis, Any])
name (str | None)
description (str | None)
make_interruptible (bool)
interrupt_message (str)
reads_state (bool)
writes_state (bool)
structured_output_model (type[pydantic.BaseModel] | None)
- Return type:
langchain_core.tools.StructuredTool
- classmethod create_human_interrupt_tool(name='human_interrupt', description='Request human intervention or approval', *, allow_ignore=True, allow_respond=True, allow_edit=False, allow_accept=True, interrupt_message='Human input requested')[source]¶
Create a tool that triggers human interrupt workflow.
This creates a tool that can pause graph execution and request human intervention, following langgraph’s interrupt patterns.
- Parameters:
name (str) – Tool name
description (str) – Tool description
allow_ignore (bool) – Whether human can skip/ignore
allow_respond (bool) – Whether human can provide text response
allow_edit (bool) – Whether human can edit the request
allow_accept (bool) – Whether human can accept as-is
interrupt_message (str) – Default interrupt message
- Returns:
A StructuredTool that triggers human interrupts
- Return type:
langchain_core.tools.StructuredTool
- classmethod create_interruptible_tool(func, name=None, description=None, *, interrupt_message='Tool execution interrupted')[source]¶
Create or wrap a tool with interruption capability.
- Parameters:
func (collections.abc.Callable[Ellipsis, Any] | langchain_core.tools.StructuredTool | langchain_core.tools.base.BaseTool)
name (str | None)
description (str | None)
interrupt_message (str)
- Return type:
langchain_core.tools.StructuredTool
- classmethod create_retriever_tool(retriever, name, description, *, document_prompt=None, document_separator='\n\n', response_format='content')[source]¶
Create a tool to do retrieval of documents.
- classmethod create_retriever_tool_from_config(retriever_config, name, description, *, document_prompt=None, document_separator='\n\n', response_format='content')[source]¶
Create a retriever tool from a Haive retriever configuration.
This is a convenience method that creates a retriever from the config and then converts it to a tool with proper metadata.
- Parameters:
retriever_config (Any) – The BaseRetrieverConfig to use
name (str) – Tool name
description (str) – Tool description
document_prompt (langchain_core.prompts.BasePromptTemplate | None) – Optional prompt to format documents
document_separator (str) – Separator between documents
response_format (Literal['content', 'content_and_artifact']) – Format for tool response
- Returns:
A StructuredTool configured for retrieval
- Return type:
langchain_core.tools.StructuredTool
- create_runnable(runnable_config=None)[source]¶
Create enhanced ToolNode with property awareness.
- Parameters:
runnable_config (langchain_core.runnables.RunnableConfig | None)
- Return type:
Any
- classmethod create_state_tool(func, name=None, description=None, *, reads_state=False, writes_state=False, state_keys=None)[source]¶
Create or wrap a tool with state interaction metadata.
- classmethod create_store_tools_suite(store_manager, namespace=None, include_tools=None)[source]¶
Create a suite of store/memory management tools.
This creates tools for memory operations like store, search, retrieve, update, and delete. These tools integrate with the StoreManager for persistent memory management.
- Parameters:
- Returns:
List of store tools with proper metadata
- Return type:
list[langchain_core.tools.StructuredTool]
- classmethod create_structured_output_tool(func, name, description, output_model, *, infer_schema=True)[source]¶
Create a tool that produces structured output.
- Parameters:
func (collections.abc.Callable[Ellipsis, Any])
name (str)
description (str)
output_model (type[pydantic.BaseModel])
infer_schema (bool)
- Return type:
langchain_core.tools.StructuredTool
- classmethod from_aug_llm_config(config, *, extract_tools=True, include_structured_output=True, name=None)[source]¶
Create ToolEngine from AugLLMConfig.
- Parameters:
config (AugLLMConfig) – AugLLMConfig instance to convert
extract_tools (bool) – Whether to extract tools from config
include_structured_output (bool) – Whether to convert structured_output_model to tool
name (str | None) – Optional name for the engine
- Returns:
ToolEngine with tools extracted from AugLLMConfig
- Return type:
- classmethod from_document_engine(engine, *, create_loader_tools=True, create_splitter_tools=True, create_processor_tools=False, name=None)[source]¶
Create ToolEngine from DocumentEngine.
- Parameters:
engine (DocumentEngine) – DocumentEngine instance to convert
create_loader_tools (bool) – Whether to create document loading tools
create_splitter_tools (bool) – Whether to create document splitting tools
create_processor_tools (bool) – Whether to create document processing tools
name (str | None) – Optional name for the engine
- Returns:
ToolEngine with document processing tools
- Return type:
- classmethod from_multiple_engines(engines, *, engine_conversion_config=None, name=None)[source]¶
Create ToolEngine from multiple engines.
- Parameters:
- Returns:
ToolEngine with tools from all engines
- Return type:
- classmethod from_retriever_config(config, *, tool_name=None, tool_description=None, name=None)[source]¶
Create ToolEngine from BaseRetrieverConfig.
- Parameters:
config (BaseRetrieverConfig) – BaseRetrieverConfig instance to convert
tool_name (str | None) – Name for the retriever tool
tool_description (str | None) – Description for the retriever tool
name (str | None) – Optional name for the engine
- Returns:
ToolEngine with retriever converted to tool
- Return type:
- classmethod from_vectorstore_config(config, *, search_tool_name=None, similarity_search_tool=True, max_marginal_relevance_tool=False, name=None)[source]¶
Create ToolEngine from VectorStoreConfig.
- Parameters:
config (haive.core.engine.vectorstore.VectorStoreConfig) – VectorStoreConfig instance to convert
search_tool_name (str | None) – Base name for search tools
similarity_search_tool (bool) – Whether to create similarity search tool
max_marginal_relevance_tool (bool) – Whether to create MMR search tool
name (str | None) – Optional name for the engine
- Returns:
ToolEngine with vectorstore search tools
- Return type:
- classmethod get_capability_enum()[source]¶
Get ToolCapability enum for other components.
- Return type:
- get_tool_properties(tool_name)[source]¶
Get properties for specific tool.
- Parameters:
tool_name (str)
- Return type:
- classmethod get_tool_type()[source]¶
Get the universal ToolLike type for other components.
- Return type:
- get_tools_by_capability(*capabilities)[source]¶
Get tool names with specified capabilities.
- Parameters:
capabilities (haive.core.engine.tool.types.ToolCapability)
- Return type:
- get_tools_by_category(category)[source]¶
Get tool names in category.
- Parameters:
category (haive.core.engine.tool.types.ToolCategory)
- Return type:
- model_post_init(__context)[source]¶
Initialize and analyze tools after creation.
- Parameters:
__context (Any)
- Return type:
None