Class OpenAiTool

java.lang.Object
com.sap.ai.sdk.foundationmodels.openai.OpenAiTool

public final class OpenAiTool extends Object
Represents an OpenAI tool that can be used to define a function call in an OpenAI Chat Completion request. This tool generates a JSON schema based on the provided class representing the function's request structure.
Since:
1.8.0
See Also:
  • Method Details

    • forFunction

      @Nonnull public static <InputT> OpenAiTool.Builder1<InputT> forFunction(@Nonnull Function<InputT,?> function)
      Instantiates a OpenAiTool builder instance on behalf of an executable function.
      Type Parameters:
      InputT - the type of the function input-argument class.
      Parameters:
      function - the function to be executed.
      Returns:
      an OpenAiTool builder instance.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withName

      public OpenAiTool withName(@Nonnull String name)
      The name of the function.
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withFunctionExecutor

      public OpenAiTool withFunctionExecutor(@Nonnull Function<String,Object> functionExecutor)
      The function to execute a string argument to tool result object.
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withSchema

      public OpenAiTool withSchema(@Nonnull com.fasterxml.jackson.databind.node.ObjectNode schema)
      schema to be used for the function call.
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withDescription

      public OpenAiTool withDescription(@Nullable String description)
      An optional description of the function.
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withStrict

      public OpenAiTool withStrict(@Nullable Boolean strict)
      An optional flag indicating whether the function parameters should be treated strictly.
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).