Class ChatCompletionTool
-
- All Implemented Interfaces:
public final class ChatCompletionToolA function tool that can be used to generate a response.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceChatCompletionTool.VisitorAn interface that defines how to map each variant of ChatCompletionTool to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<ChatCompletionFunctionTool>function()A function tool that can be used to generate a response. final Optional<ChatCompletionCustomTool>custom()A custom tool that processes input using a specified format. final BooleanisFunction()final BooleanisCustom()final ChatCompletionFunctionToolasFunction()A function tool that can be used to generate a response. final ChatCompletionCustomToolasCustom()A custom tool that processes input using a specified format. final Optional<JsonValue>_json()final <T extends Any> Taccept(ChatCompletionTool.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final ChatCompletionToolvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ChatCompletionToolofFunction(ChatCompletionFunctionTool function)A function tool that can be used to generate a response. final static ChatCompletionToolofCustom(ChatCompletionCustomTool custom)A custom tool that processes input using a specified format. -
-
Method Detail
-
function
final Optional<ChatCompletionFunctionTool> function()
A function tool that can be used to generate a response.
-
custom
final Optional<ChatCompletionCustomTool> custom()
A custom tool that processes input using a specified format.
-
isFunction
final Boolean isFunction()
-
asFunction
final ChatCompletionFunctionTool asFunction()
A function tool that can be used to generate a response.
-
asCustom
final ChatCompletionCustomTool asCustom()
A custom tool that processes input using a specified format.
-
accept
final <T extends Any> T accept(ChatCompletionTool.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 = chatCompletionTool.accept(new ChatCompletionTool.Visitor<Optional<String>>() { @Override public Optional<String> visitFunction(ChatCompletionFunctionTool function) { return Optional.of(function.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ChatCompletionTool 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 ChatCompletionTool ofFunction(ChatCompletionFunctionTool function)
A function tool that can be used to generate a response.
-
ofCustom
final static ChatCompletionTool ofCustom(ChatCompletionCustomTool custom)
A custom tool that processes input using a specified format.
-
-
-
-