Class RequestChatCompletion.Builder

All Implemented Interfaces:
WithJson<RequestChatCompletion.Builder>, ObjectBuilder<RequestChatCompletion>
Enclosing class:
RequestChatCompletion

public static class RequestChatCompletion.Builder extends WithJsonObjectBuilderBase<RequestChatCompletion.Builder> implements ObjectBuilder<RequestChatCompletion>
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • messages

      public final RequestChatCompletion.Builder messages(List<Message> list)
      Required - A list of objects representing the conversation. Requests should generally only add new messages from the user (role user). The other message roles (assistant, system, or tool) should generally only be copied from the response to a previous completion request, such that the messages array is built up throughout a conversation.

      API name: messages

      Adds all elements of list to messages.

    • messages

      public final RequestChatCompletion.Builder messages(Message value, Message... values)
      Required - A list of objects representing the conversation. Requests should generally only add new messages from the user (role user). The other message roles (assistant, system, or tool) should generally only be copied from the response to a previous completion request, such that the messages array is built up throughout a conversation.

      API name: messages

      Adds one or more values to messages.

    • messages

      Required - A list of objects representing the conversation. Requests should generally only add new messages from the user (role user). The other message roles (assistant, system, or tool) should generally only be copied from the response to a previous completion request, such that the messages array is built up throughout a conversation.

      API name: messages

      Adds a value to messages using a builder lambda.

    • model

      public final RequestChatCompletion.Builder model(@Nullable String value)
      The ID of the model to use.

      API name: model

    • maxCompletionTokens

      public final RequestChatCompletion.Builder maxCompletionTokens(@Nullable Long value)
      The upper bound limit for the number of tokens that can be generated for a completion request.

      API name: max_completion_tokens

    • stop

      public final RequestChatCompletion.Builder stop(List<String> list)
      A sequence of strings to control when the model should stop generating additional tokens.

      API name: stop

      Adds all elements of list to stop.

    • stop

      public final RequestChatCompletion.Builder stop(String value, String... values)
      A sequence of strings to control when the model should stop generating additional tokens.

      API name: stop

      Adds one or more values to stop.

    • temperature

      public final RequestChatCompletion.Builder temperature(@Nullable Float value)
      The sampling temperature to use.

      API name: temperature

    • toolChoice

      public final RequestChatCompletion.Builder toolChoice(@Nullable CompletionToolType value)
      Controls which tool is called by the model. String representation: One of auto, none, or requrired. auto allows the model to choose between calling tools and generating a message. none causes the model to not call any tools. required forces the model to call one or more tools. Example (object representation):
       {
         "tool_choice": {
             "type": "function",
             "function": {
                 "name": "get_current_weather"
             }
         }
       }
       
       

      API name: tool_choice

    • toolChoice

      Controls which tool is called by the model. String representation: One of auto, none, or requrired. auto allows the model to choose between calling tools and generating a message. none causes the model to not call any tools. required forces the model to call one or more tools. Example (object representation):
       {
         "tool_choice": {
             "type": "function",
             "function": {
                 "name": "get_current_weather"
             }
         }
       }
       
       

      API name: tool_choice

    • tools

      A list of tools that the model can call. Example:
       {
         "tools": [
             {
                 "type": "function",
                 "function": {
                     "name": "get_price_of_item",
                     "description": "Get the current price of an item",
                     "parameters": {
                         "type": "object",
                         "properties": {
                             "item": {
                                 "id": "12345"
                             },
                             "unit": {
                                 "type": "currency"
                             }
                         }
                     }
                 }
             }
         ]
       }
       
       

      API name: tools

      Adds all elements of list to tools.

    • tools

      public final RequestChatCompletion.Builder tools(CompletionTool value, CompletionTool... values)
      A list of tools that the model can call. Example:
       {
         "tools": [
             {
                 "type": "function",
                 "function": {
                     "name": "get_price_of_item",
                     "description": "Get the current price of an item",
                     "parameters": {
                         "type": "object",
                         "properties": {
                             "item": {
                                 "id": "12345"
                             },
                             "unit": {
                                 "type": "currency"
                             }
                         }
                     }
                 }
             }
         ]
       }
       
       

      API name: tools

      Adds one or more values to tools.

    • tools

      A list of tools that the model can call. Example:
       {
         "tools": [
             {
                 "type": "function",
                 "function": {
                     "name": "get_price_of_item",
                     "description": "Get the current price of an item",
                     "parameters": {
                         "type": "object",
                         "properties": {
                             "item": {
                                 "id": "12345"
                             },
                             "unit": {
                                 "type": "currency"
                             }
                         }
                     }
                 }
             }
         ]
       }
       
       

      API name: tools

      Adds a value to tools using a builder lambda.

    • topP

      public final RequestChatCompletion.Builder topP(@Nullable Float value)
      Nucleus sampling, an alternative to sampling with temperature.

      API name: top_p

    • self

      Specified by:
      self in class WithJsonObjectBuilderBase<RequestChatCompletion.Builder>
    • build

      public RequestChatCompletion build()
      Specified by:
      build in interface ObjectBuilder<RequestChatCompletion>
      Throws:
      NullPointerException - if some of the required fields are null.