Class ChatCompletionCustomTool.Custom.Format
-
- All Implemented Interfaces:
public final class ChatCompletionCustomTool.Custom.FormatThe input format for the custom tool. Default is unconstrained text.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceChatCompletionCustomTool.Custom.Format.VisitorAn interface that defines how to map each variant of Format to a value of type T.
public final classChatCompletionCustomTool.Custom.Format.GrammarA grammar defined by the user.
-
Method Summary
Modifier and Type Method Description final Optional<JsonValue>text()Unconstrained free-form text. final Optional<ChatCompletionCustomTool.Custom.Format.Grammar>grammar()A grammar defined by the user. final BooleanisText()final BooleanisGrammar()final JsonValueasText()Unconstrained free-form text. final ChatCompletionCustomTool.Custom.Format.GrammarasGrammar()A grammar defined by the user. final Optional<JsonValue>_json()final <T extends Any> Taccept(ChatCompletionCustomTool.Custom.Format.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final ChatCompletionCustomTool.Custom.Formatvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ChatCompletionCustomTool.Custom.FormatofText()Unconstrained free-form text. final static ChatCompletionCustomTool.Custom.FormatofGrammar(ChatCompletionCustomTool.Custom.Format.Grammar grammar)A grammar defined by the user. -
-
Method Detail
-
grammar
final Optional<ChatCompletionCustomTool.Custom.Format.Grammar> grammar()
A grammar defined by the user.
-
asGrammar
final ChatCompletionCustomTool.Custom.Format.Grammar asGrammar()
A grammar defined by the user.
-
accept
final <T extends Any> T accept(ChatCompletionCustomTool.Custom.Format.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 = format.accept(new Format.Visitor<Optional<String>>() { @Override public Optional<String> visitText(JsonValue text) { return Optional.of(text.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ChatCompletionCustomTool.Custom.Format 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.
-
ofText
final static ChatCompletionCustomTool.Custom.Format ofText()
Unconstrained free-form text.
-
ofGrammar
final static ChatCompletionCustomTool.Custom.Format ofGrammar(ChatCompletionCustomTool.Custom.Format.Grammar grammar)
A grammar defined by the user.
-
-
-
-