Class RequestChatCompletion.Builder
- All Implemented Interfaces:
WithJson<RequestChatCompletion.Builder>,ObjectBuilder<RequestChatCompletion>
- Enclosing class:
- RequestChatCompletion
RequestChatCompletion.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds aRequestChatCompletion.maxCompletionTokens(Long value) The upper bound limit for the number of tokens that can be generated for a completion request.Required - A list of objects representing the conversation.Required - A list of objects representing the conversation.Required - A list of objects representing the conversation.The ID of the model to use.The reasoning configuration for the completion request.The reasoning configuration for the completion request.protected RequestChatCompletion.Builderself()A sequence of strings to control when the model should stop generating additional tokens.A sequence of strings to control when the model should stop generating additional tokens.temperature(Float value) The sampling temperature to use.toolChoice(CompletionToolType value) Controls which tool is called by the model.Controls which tool is called by the model.tools(CompletionTool value, CompletionTool... values) A list of tools that the model can call.A list of tools that the model can call.tools(List<CompletionTool> list) A list of tools that the model can call.Nucleus sampling, an alternative to sampling with temperature.Methods inherited from class co.elastic.clients.util.WithJsonObjectBuilderBase
withJsonMethods inherited from class co.elastic.clients.util.ObjectBuilderBase
_checkSingleUse, _listAdd, _listAddAll, _mapPut, _mapPutAll
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
messages
Required - A list of objects representing the conversation. Requests should generally only add new messages from the user (roleuser). The other message roles (assistant,system, ortool) 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:
messagesAdds all elements of
listtomessages. -
messages
Required - A list of objects representing the conversation. Requests should generally only add new messages from the user (roleuser). The other message roles (assistant,system, ortool) 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:
messagesAdds one or more values to
messages. -
messages
public final RequestChatCompletion.Builder messages(Function<Message.Builder, ObjectBuilder<Message>> fn) Required - A list of objects representing the conversation. Requests should generally only add new messages from the user (roleuser). The other message roles (assistant,system, ortool) 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:
messagesAdds a value to
messagesusing a builder lambda. -
model
The ID of the model to use. By default, the model ID is set to the value included when creating the inference endpoint.API name:
model -
maxCompletionTokens
The upper bound limit for the number of tokens that can be generated for a completion request.API name:
max_completion_tokens -
reasoning
The reasoning configuration for the completion request. This controls the model's reasoning process in one of two ways:- By specifying the model’s reasoning effort level with the
effortfield. - By enabling reasoning with default settings by setting
enabledfield totrue.
It also includes optional settings to control:
- The level of detail in the summary returned in the response with the
summaryfield. - Whether reasoning details are included in the response at all with the
excludefield.
Example (effort):
{ "reasoning": { "effort": "high", "summary": "concise", "exclude": false } }Example (enabled):
{ "reasoning": { "enabled": true, "summary": "concise", "exclude": false } }Currently supported only for
elasticprovider.API name:
reasoning - By specifying the model’s reasoning effort level with the
-
reasoning
public final RequestChatCompletion.Builder reasoning(Function<Reasoning.Builder, ObjectBuilder<Reasoning>> fn) The reasoning configuration for the completion request. This controls the model's reasoning process in one of two ways:- By specifying the model’s reasoning effort level with the
effortfield. - By enabling reasoning with default settings by setting
enabledfield totrue.
It also includes optional settings to control:
- The level of detail in the summary returned in the response with the
summaryfield. - Whether reasoning details are included in the response at all with the
excludefield.
Example (effort):
{ "reasoning": { "effort": "high", "summary": "concise", "exclude": false } }Example (enabled):
{ "reasoning": { "enabled": true, "summary": "concise", "exclude": false } }Currently supported only for
elasticprovider.API name:
reasoning - By specifying the model’s reasoning effort level with the
-
stop
A sequence of strings to control when the model should stop generating additional tokens.API name:
stopAdds all elements of
listtostop. -
stop
A sequence of strings to control when the model should stop generating additional tokens.API name:
stopAdds one or more values to
stop. -
temperature
The sampling temperature to use.API name:
temperature -
toolChoice
Controls which tool is called by the model. String representation: One ofauto,none, orrequrired.autoallows the model to choose between calling tools and generating a message.nonecauses the model to not call any tools.requiredforces 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
public final RequestChatCompletion.Builder toolChoice(Function<CompletionToolType.Builder, ObjectBuilder<CompletionToolType>> fn) Controls which tool is called by the model. String representation: One ofauto,none, orrequrired.autoallows the model to choose between calling tools and generating a message.nonecauses the model to not call any tools.requiredforces 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:
toolsAdds all elements of
listtotools. -
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:
toolsAdds one or more values to
tools. -
tools
public final RequestChatCompletion.Builder tools(Function<CompletionTool.Builder, ObjectBuilder<CompletionTool>> fn) 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:
toolsAdds a value to
toolsusing a builder lambda. -
topP
Nucleus sampling, an alternative to sampling with temperature.API name:
top_p -
self
- Specified by:
selfin classWithJsonObjectBuilderBase<RequestChatCompletion.Builder>
-
build
Builds aRequestChatCompletion.- Specified by:
buildin interfaceObjectBuilder<RequestChatCompletion>- Throws:
NullPointerException- if some of the required fields are null.
-