Package com.sap.ai.sdk.foundationmodels.openai

# 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:
  - OpenAI Function

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `OpenAiTool.Builder1<InputT>`
  Creates a new OpenAiTool instance with the specified function and input class.
  `static interface`
  `OpenAiTool.Builder2`
  Creates a new OpenAiTool instance with the specified name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  `static <InputT> OpenAiTool.Builder1<InputT>`
  `forFunction(Function<InputT,?> function)`
  Instantiates a OpenAiTool builder instance on behalf of an executable function.
  `int`
  `hashCode()`
  `String`
  `toString()`
  `OpenAiTool`
  `withDescription(String description)`
  An optional description of the function.
  `OpenAiTool`
  `withFunctionExecutor(Function<String,Object> functionExecutor)`
  The function to execute a string argument to tool result object.
  `OpenAiTool`
  `withName(String name)`
  The name of the function.
  `OpenAiTool`
  `withSchema(com.fasterxml.jackson.databind.node.ObjectNode schema)`
  schema to be used for the function call.
  `OpenAiTool`
  `withStrict(Boolean strict)`
  An optional flag indicating whether the function parameters should be treated strictly.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## 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).