Package com.hw.langchain.tools.base
Class BaseTool
java.lang.Object
com.hw.langchain.tools.base.BaseTool
- Direct Known Subclasses:
InvalidTool
,Tool
Interface LangChain tools must implement.
- Author:
- HamaWhite
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionargs()
abstract Object
Use the tool.boolean
Whether the tool only accepts a single input.Run the tool.toArgsAndKwargs
(Object toolInput)
-
Field Details
-
name
The unique name of the tool that clearly communicates its purpose. -
description
Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. -
returnDirect
public final boolean returnDirectWhether to return the tool's output directly. Setting this to true means that after the tool is called, the AgentExecutor will stop looping.
-
-
Constructor Details
-
BaseTool
-
BaseTool
-
-
Method Details
-
isSingleInput
public boolean isSingleInput()Whether the tool only accepts a single input. -
args
-
innerRun
Use the tool.- Parameters:
args
- Tool arguments as a String.kwargs
- Keyword arguments as a Map<String, Object>.- Returns:
- Result of using the tool as an Object.
-
toArgsAndKwargs
-
run
Run the tool.- Parameters:
toolInput
- Input for the tool, can be a String or a Map<String, Object>.kwargs
- Keyword arguments for the tool as a Map<String, Object>.- Returns:
- Result of running the tool as an Object.
-