Class RequestChatCompletion.Builder
java.lang.Object
co.elastic.clients.util.ObjectBuilderBase
co.elastic.clients.util.WithJsonObjectBuilderBase<RequestChatCompletion.Builder>
co.elastic.clients.elasticsearch.inference.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>
Builder for
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.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.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 -
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.
-