Class NamespaceTool.Tool
-
- All Implemented Interfaces:
public final class NamespaceTool.ToolA function or custom tool that belongs to a namespace.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceNamespaceTool.Tool.VisitorAn interface that defines how to map each variant of Tool to a value of type T.
public final classNamespaceTool.Tool.Function
-
Method Summary
Modifier and Type Method Description final Optional<NamespaceTool.Tool.Function>function()final Optional<CustomTool>custom()A custom tool that processes input using a specified format. final BooleanisFunction()final BooleanisCustom()final NamespaceTool.Tool.FunctionasFunction()final CustomToolasCustom()A custom tool that processes input using a specified format. final Optional<JsonValue>_json()final <T extends Any> Taccept(NamespaceTool.Tool.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final NamespaceTool.Toolvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static NamespaceTool.ToolofFunction(NamespaceTool.Tool.Function function)final static NamespaceTool.ToolofCustom(CustomTool custom)A custom tool that processes input using a specified format. -
-
Method Detail
-
function
final Optional<NamespaceTool.Tool.Function> function()
-
custom
final Optional<CustomTool> custom()
A custom tool that processes input using a specified format. Learn more about custom tools
-
isFunction
final Boolean isFunction()
-
asFunction
final NamespaceTool.Tool.Function asFunction()
-
asCustom
final CustomTool asCustom()
A custom tool that processes input using a specified format. Learn more about custom tools
-
accept
final <T extends Any> T accept(NamespaceTool.Tool.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.openai.core.JsonValue; import java.util.Optional; Optional<String> result = tool.accept(new Tool.Visitor<Optional<String>>() { @Override public Optional<String> visitFunction(Function function) { return Optional.of(function.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final NamespaceTool.Tool validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofFunction
final static NamespaceTool.Tool ofFunction(NamespaceTool.Tool.Function function)
-
ofCustom
final static NamespaceTool.Tool ofCustom(CustomTool custom)
A custom tool that processes input using a specified format. Learn more about custom tools
-
-
-
-