Class ChatCompletionToolChoiceOption
-
- All Implemented Interfaces:
public final class ChatCompletionToolChoiceOptionControls which (if any) tool is called by the model.
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools. Specifying a particular tool via{"type": "function", "function": {"name": "my_function"}}forces the model to call that tool.noneis the default when no tools are present.autois the default if tools are present.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceChatCompletionToolChoiceOption.VisitorAn interface that defines how to map each variant of ChatCompletionToolChoiceOption to a value of type T.
public final classChatCompletionToolChoiceOption.Autononemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.
-
Method Summary
Modifier and Type Method Description final Optional<ChatCompletionToolChoiceOption.Auto>auto()nonemeans the model will not call any tool and instead generates a message.final Optional<ChatCompletionAllowedToolChoice>allowedToolChoice()Constrains the tools available to the model to a pre-defined set. final Optional<ChatCompletionNamedToolChoice>namedToolChoice()Specifies a tool the model should use. final Optional<ChatCompletionNamedToolChoiceCustom>namedToolChoiceCustom()Specifies a tool the model should use. final BooleanisAuto()final BooleanisAllowedToolChoice()final BooleanisNamedToolChoice()final BooleanisNamedToolChoiceCustom()final ChatCompletionToolChoiceOption.AutoasAuto()nonemeans the model will not call any tool and instead generates a message.final ChatCompletionAllowedToolChoiceasAllowedToolChoice()Constrains the tools available to the model to a pre-defined set. final ChatCompletionNamedToolChoiceasNamedToolChoice()Specifies a tool the model should use. final ChatCompletionNamedToolChoiceCustomasNamedToolChoiceCustom()Specifies a tool the model should use. final Optional<JsonValue>_json()final <T extends Any> Taccept(ChatCompletionToolChoiceOption.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final ChatCompletionToolChoiceOptionvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ChatCompletionToolChoiceOptionofAuto(ChatCompletionToolChoiceOption.Auto auto)nonemeans the model will not call any tool and instead generates a message.final static ChatCompletionToolChoiceOptionofAllowedToolChoice(ChatCompletionAllowedToolChoice allowedToolChoice)Constrains the tools available to the model to a pre-defined set. final static ChatCompletionToolChoiceOptionofNamedToolChoice(ChatCompletionNamedToolChoice namedToolChoice)Specifies a tool the model should use. final static ChatCompletionToolChoiceOptionofNamedToolChoiceCustom(ChatCompletionNamedToolChoiceCustom namedToolChoiceCustom)Specifies a tool the model should use. -
-
Method Detail
-
auto
final Optional<ChatCompletionToolChoiceOption.Auto> auto()
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.
-
allowedToolChoice
final Optional<ChatCompletionAllowedToolChoice> allowedToolChoice()
Constrains the tools available to the model to a pre-defined set.
-
namedToolChoice
final Optional<ChatCompletionNamedToolChoice> namedToolChoice()
Specifies a tool the model should use. Use to force the model to call a specific function.
-
namedToolChoiceCustom
final Optional<ChatCompletionNamedToolChoiceCustom> namedToolChoiceCustom()
Specifies a tool the model should use. Use to force the model to call a specific custom tool.
-
isAllowedToolChoice
final Boolean isAllowedToolChoice()
-
isNamedToolChoice
final Boolean isNamedToolChoice()
-
isNamedToolChoiceCustom
final Boolean isNamedToolChoiceCustom()
-
asAuto
final ChatCompletionToolChoiceOption.Auto asAuto()
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.
-
asAllowedToolChoice
final ChatCompletionAllowedToolChoice asAllowedToolChoice()
Constrains the tools available to the model to a pre-defined set.
-
asNamedToolChoice
final ChatCompletionNamedToolChoice asNamedToolChoice()
Specifies a tool the model should use. Use to force the model to call a specific function.
-
asNamedToolChoiceCustom
final ChatCompletionNamedToolChoiceCustom asNamedToolChoiceCustom()
Specifies a tool the model should use. Use to force the model to call a specific custom tool.
-
accept
final <T extends Any> T accept(ChatCompletionToolChoiceOption.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 = chatCompletionToolChoiceOption.accept(new ChatCompletionToolChoiceOption.Visitor<Optional<String>>() { @Override public Optional<String> visitAuto(Auto auto) { return Optional.of(auto.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ChatCompletionToolChoiceOption 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.
-
ofAuto
final static ChatCompletionToolChoiceOption ofAuto(ChatCompletionToolChoiceOption.Auto auto)
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.
-
ofAllowedToolChoice
final static ChatCompletionToolChoiceOption ofAllowedToolChoice(ChatCompletionAllowedToolChoice allowedToolChoice)
Constrains the tools available to the model to a pre-defined set.
-
ofNamedToolChoice
final static ChatCompletionToolChoiceOption ofNamedToolChoice(ChatCompletionNamedToolChoice namedToolChoice)
Specifies a tool the model should use. Use to force the model to call a specific function.
-
ofNamedToolChoiceCustom
final static ChatCompletionToolChoiceOption ofNamedToolChoiceCustom(ChatCompletionNamedToolChoiceCustom namedToolChoiceCustom)
Specifies a tool the model should use. Use to force the model to call a specific custom tool.
-
-
-
-