Class Message.Builder

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

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

    • Builder

      public Builder()
  • Method Details

    • content

      public final Message.Builder content(@Nullable MessageContent value)
      The content of the message.

      String example:

       {
          "content": "Some string"
       }
       
       

      Object example:

       {
         "content": [
             {
              "text": "Some text",
              "type": "text"
             }
          ]
       }
       
       

      API name: content

    • content

      The content of the message.

      String example:

       {
          "content": "Some string"
       }
       
       

      Object example:

       {
         "content": [
             {
              "text": "Some text",
              "type": "text"
             }
          ]
       }
       
       

      API name: content

    • role

      public final Message.Builder role(String value)
      Required - The role of the message author. Valid values are user, assistant, system, and tool.

      API name: role

    • toolCallId

      public final Message.Builder toolCallId(@Nullable String value)
      Only for tool role messages. The tool call that this message is responding to.

      API name: tool_call_id

    • toolCalls

      public final Message.Builder toolCalls(List<ToolCall> list)
      Only for assistant role messages. The tool calls generated by the model. If it's specified, the content field is optional. Example:
       {
         "tool_calls": [
             {
                 "id": "call_KcAjWtAww20AihPHphUh46Gd",
                 "type": "function",
                 "function": {
                     "name": "get_current_weather",
                     "arguments": "{\"location\":\"Boston, MA\"}"
                 }
             }
         ]
       }
       
       

      API name: tool_calls

      Adds all elements of list to toolCalls.

    • toolCalls

      public final Message.Builder toolCalls(ToolCall value, ToolCall... values)
      Only for assistant role messages. The tool calls generated by the model. If it's specified, the content field is optional. Example:
       {
         "tool_calls": [
             {
                 "id": "call_KcAjWtAww20AihPHphUh46Gd",
                 "type": "function",
                 "function": {
                     "name": "get_current_weather",
                     "arguments": "{\"location\":\"Boston, MA\"}"
                 }
             }
         ]
       }
       
       

      API name: tool_calls

      Adds one or more values to toolCalls.

    • toolCalls

      Only for assistant role messages. The tool calls generated by the model. If it's specified, the content field is optional. Example:
       {
         "tool_calls": [
             {
                 "id": "call_KcAjWtAww20AihPHphUh46Gd",
                 "type": "function",
                 "function": {
                     "name": "get_current_weather",
                     "arguments": "{\"location\":\"Boston, MA\"}"
                 }
             }
         ]
       }
       
       

      API name: tool_calls

      Adds a value to toolCalls using a builder lambda.

    • self

      protected Message.Builder self()
      Specified by:
      self in class WithJsonObjectBuilderBase<Message.Builder>
    • build

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