Class AssistantTool
-
- All Implemented Interfaces:
public final class AssistantTool
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceAssistantTool.VisitorAn interface that defines how to map each variant of AssistantTool to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<CodeInterpreterTool>codeInterpreter()final Optional<FileSearchTool>fileSearch()final Optional<FunctionTool>function()final BooleanisCodeInterpreter()final BooleanisFileSearch()final BooleanisFunction()final CodeInterpreterToolasCodeInterpreter()final FileSearchToolasFileSearch()final FunctionToolasFunction()final Optional<JsonValue>_json()final <T extends Any> Taccept(AssistantTool.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final AssistantToolvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static AssistantToolofCodeInterpreter(CodeInterpreterTool codeInterpreter)final static AssistantToolofFileSearch(FileSearchTool fileSearch)final static AssistantToolofFunction(FunctionTool function)-
-
Method Detail
-
codeInterpreter
final Optional<CodeInterpreterTool> codeInterpreter()
-
fileSearch
final Optional<FileSearchTool> fileSearch()
-
function
final Optional<FunctionTool> function()
-
isCodeInterpreter
final Boolean isCodeInterpreter()
-
isFileSearch
final Boolean isFileSearch()
-
isFunction
final Boolean isFunction()
-
asCodeInterpreter
final CodeInterpreterTool asCodeInterpreter()
-
asFileSearch
final FileSearchTool asFileSearch()
-
asFunction
final FunctionTool asFunction()
-
accept
final <T extends Any> T accept(AssistantTool.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 = assistantTool.accept(new AssistantTool.Visitor<Optional<String>>() { @Override public Optional<String> visitCodeInterpreter(CodeInterpreterTool codeInterpreter) { return Optional.of(codeInterpreter.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final AssistantTool 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.
-
ofCodeInterpreter
final static AssistantTool ofCodeInterpreter(CodeInterpreterTool codeInterpreter)
-
ofFileSearch
final static AssistantTool ofFileSearch(FileSearchTool fileSearch)
-
ofFunction
final static AssistantTool ofFunction(FunctionTool function)
-
-
-
-