Chain Tool
The Chain Tool node is a component that allows the use of a LangChain chain as a tool for an agent. It provides a way to integrate complex chain-based operations into agent workflows.
Node Details
-
Name: chainTool
-
Type: ChainTool
-
Version: 1.0
-
Category: Tools
-
Description: Use a chain as allowed tool for agent
Parameters
-
Chain Name
-
Type: string
-
Description: A unique identifier for the chain tool
-
Example: “state-of-union-qa”
-
-
Chain Description
-
Type: string
-
Description: A detailed description of what the chain does and when it should be used
-
Example: “State of the Union QA - useful for when you need to ask questions about the most recent state of the union address.”
-
-
Return Direct
-
Type: boolean
-
Optional: Yes
-
Description: Determines whether the tool should return its result directly or wrap it in a response
-
-
Base Chain
-
Type: BaseChain
-
Description: The LangChain chain to be used as the core functionality of this tool
-
Input/Output
Input
The node takes in the following inputs during initialization:
-
Chain Name (string)
-
Chain Description (string)
-
Return Direct (boolean, optional)
-
Base Chain (BaseChain object)
Output
The node outputs a ChainTool object that can be used in agent configurations.
Functionality
The ChainTool node creates a tool that wraps a LangChain chain, allowing it to be used as part of an agent’s toolkit. This enables the agent to leverage complex chain-based operations when needed.
Key aspects of its functionality include:
-
Naming and describing the tool for clear identification by the agent
-
Integrating a BaseChain object as the core functionality
-
Optional direct return of results, bypassing standard response formatting
Use Cases
This node is particularly useful in scenarios where you want to:
-
Incorporate specialized question-answering chains into a more general agent
-
Allow an agent to access and utilize complex, multi-step operations encapsulated in a chain
-
Provide agents with tools that can perform in-depth analysis or processing on specific topics or datasets
Example
A common use case might be creating a tool that uses a QA chain to answer questions about a specific document or topic, such as the State of the Union address mentioned in the placeholder. This tool could then be used alongside other tools in an agent designed to answer general questions about government and politics.