Class BetaNamespaceTool.Tool
-
- All Implemented Interfaces:
public final class BetaNamespaceTool.ToolA function or custom tool that belongs to a namespace.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaNamespaceTool.Tool.VisitorAn interface that defines how to map each variant of Tool to a value of type T.
public final classBetaNamespaceTool.Tool.Function
-
Method Summary
Modifier and Type Method Description final Optional<BetaNamespaceTool.Tool.Function>function()final Optional<BetaCustomTool>custom()A custom tool that processes input using a specified format. final BooleanisFunction()final BooleanisCustom()final BetaNamespaceTool.Tool.FunctionasFunction()final BetaCustomToolasCustom()A custom tool that processes input using a specified format. final Optional<JsonValue>_json()final <T extends Any> Taccept(BetaNamespaceTool.Tool.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final BetaNamespaceTool.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 BetaNamespaceTool.ToolofFunction(BetaNamespaceTool.Tool.Function function)final static BetaNamespaceTool.ToolofCustom(BetaCustomTool custom)A custom tool that processes input using a specified format. -
-
Method Detail
-
function
final Optional<BetaNamespaceTool.Tool.Function> function()
-
custom
final Optional<BetaCustomTool> custom()
A custom tool that processes input using a specified format. Learn more about custom tools
-
isFunction
final Boolean isFunction()
-
asFunction
final BetaNamespaceTool.Tool.Function asFunction()
-
asCustom
final BetaCustomTool asCustom()
A custom tool that processes input using a specified format. Learn more about custom tools
-
accept
final <T extends Any> T accept(BetaNamespaceTool.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 BetaNamespaceTool.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 BetaNamespaceTool.Tool ofFunction(BetaNamespaceTool.Tool.Function function)
-
ofCustom
final static BetaNamespaceTool.Tool ofCustom(BetaCustomTool custom)
A custom tool that processes input using a specified format. Learn more about custom tools
-
-
-
-