Class CohereChatRequestV2.Builder
- java.lang.Object
-
- com.oracle.bmc.generativeaiinference.model.CohereChatRequestV2.Builder
-
- Enclosing class:
- CohereChatRequestV2
public static class CohereChatRequestV2.Builder extends Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CohereChatRequestV2build()CohereChatRequestV2.BuildercitationOptions(CitationOptionsV2 citationOptions)CohereChatRequestV2.Buildercopy(CohereChatRequestV2 model)CohereChatRequestV2.Builderdocuments(List<Object> documents)A list of relevant documents that the model can refer to for generating grounded responses to the user’s requests.CohereChatRequestV2.BuilderfrequencyPenalty(Double frequencyPenalty)To reduce repetitiveness of generated tokens, this number penalizes new tokens based on their frequency in the generated text so far.CohereChatRequestV2.BuilderisLogProbsEnabled(Boolean isLogProbsEnabled)The log probabilities of the generated tokens will be included in the response.CohereChatRequestV2.BuilderisRawPrompting(Boolean isRawPrompting)When enabled, the user\u2019s message will be sent to the model without any preprocessing.CohereChatRequestV2.BuilderisSearchQueriesOnly(Boolean isSearchQueriesOnly)When set to true, the response contains only a list of generated search queries without the search results and the model will not respond to the user’s message.CohereChatRequestV2.BuilderisStream(Boolean isStream)Whether to stream the partial progress of the model’s response.CohereChatRequestV2.BuilderisStrictToolsEnabled(Boolean isStrictToolsEnabled)When set to true, tool calls in the Assistant message will be forced to follow the tool definition strictly.CohereChatRequestV2.BuildermaxTokens(Integer maxTokens)The maximum number of output tokens that the model will generate for the response.CohereChatRequestV2.Buildermessages(List<CohereMessageV2> messages)A list of chat messages in chronological order, representing a conversation between the user and the model.CohereChatRequestV2.BuilderpresencePenalty(Double presencePenalty)To reduce repetitiveness of generated tokens, this number penalizes new tokens based on whether they’ve appeared in the generated text so far.CohereChatRequestV2.Builderpriority(Integer priority)The priority of the request (lower means earlier handling; default 0 highest priority).CohereChatRequestV2.BuilderresponseFormat(CohereResponseFormat responseFormat)CohereChatRequestV2.BuildersafetyMode(CohereChatRequestV2.SafetyMode safetyMode)Safety mode: Adds a safety instruction for the model to use when generating responses.CohereChatRequestV2.Builderseed(Integer seed)If specified, the backend will make a best effort to sample tokens deterministically, so that repeated requests with the same seed and parameters yield the same result.CohereChatRequestV2.BuilderstopSequences(List<String> stopSequences)Stop the model generation when it reaches a stop sequence defined in this parameter.CohereChatRequestV2.BuilderstreamOptions(StreamOptions streamOptions)CohereChatRequestV2.Buildertemperature(Double temperature)A number that sets the randomness of the generated output.CohereChatRequestV2.Builderthinking(CohereThinkingV2 thinking)CohereChatRequestV2.Buildertools(List<CohereToolV2> tools)A list of available tools (functions) that the model may suggest invoking before producing a text response.CohereChatRequestV2.BuildertoolsChoice(CohereChatRequestV2.ToolsChoice toolsChoice)Used to control whether or not the model will be forced to use a tool when answering.CohereChatRequestV2.BuildertopK(Integer topK)A sampling method in which the model chooses the next token randomly from the top k most likely tokens.CohereChatRequestV2.BuildertopP(Double topP)If set to a probability 0.0 < p < 1.0, it ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step.
-
-
-
Method Detail
-
messages
public CohereChatRequestV2.Builder messages(List<CohereMessageV2> messages)
A list of chat messages in chronological order, representing a conversation between the user and the model.- Parameters:
messages- the value to set- Returns:
- this builder
-
documents
public CohereChatRequestV2.Builder documents(List<Object> documents)
A list of relevant documents that the model can refer to for generating grounded responses to the user’s requests.Some example keys that you can add to the dictionary are “text”, “author”, and “date”. Keep the total word count of the strings in the dictionary to 300 words or less.
- Parameters:
documents- the value to set- Returns:
- this builder
-
citationOptions
public CohereChatRequestV2.Builder citationOptions(CitationOptionsV2 citationOptions)
-
toolsChoice
public CohereChatRequestV2.Builder toolsChoice(CohereChatRequestV2.ToolsChoice toolsChoice)
Used to control whether or not the model will be forced to use a tool when answering.When REQUIRED is specified, the model will be forced to use at least one of the user-defined tools, and the tools parameter must be passed in the request. When NONE is specified, the model will be forced not to use one of the specified tools, and give a direct response. If tool_choice isn\u2019t specified, then the model is free to choose whether to use the specified tools or not. Note:This parameter is only compatible with models Command-r7b and newer.
- Parameters:
toolsChoice- the value to set- Returns:
- this builder
-
tools
public CohereChatRequestV2.Builder tools(List<CohereToolV2> tools)
A list of available tools (functions) that the model may suggest invoking before producing a text response.- Parameters:
tools- the value to set- Returns:
- this builder
-
isStrictToolsEnabled
public CohereChatRequestV2.Builder isStrictToolsEnabled(Boolean isStrictToolsEnabled)
When set to true, tool calls in the Assistant message will be forced to follow the tool definition strictly.Note:The first few requests with a new set of tools will take longer to process.
- Parameters:
isStrictToolsEnabled- the value to set- Returns:
- this builder
-
isLogProbsEnabled
public CohereChatRequestV2.Builder isLogProbsEnabled(Boolean isLogProbsEnabled)
The log probabilities of the generated tokens will be included in the response.- Parameters:
isLogProbsEnabled- the value to set- Returns:
- this builder
-
thinking
public CohereChatRequestV2.Builder thinking(CohereThinkingV2 thinking)
-
responseFormat
public CohereChatRequestV2.Builder responseFormat(CohereResponseFormat responseFormat)
-
isSearchQueriesOnly
public CohereChatRequestV2.Builder isSearchQueriesOnly(Boolean isSearchQueriesOnly)
When set to true, the response contains only a list of generated search queries without the search results and the model will not respond to the user’s message.- Parameters:
isSearchQueriesOnly- the value to set- Returns:
- this builder
-
streamOptions
public CohereChatRequestV2.Builder streamOptions(StreamOptions streamOptions)
-
isStream
public CohereChatRequestV2.Builder isStream(Boolean isStream)
Whether to stream the partial progress of the model’s response.When set to true, as tokens become available, they are sent as data-only server-sent events.
- Parameters:
isStream- the value to set- Returns:
- this builder
-
maxTokens
public CohereChatRequestV2.Builder maxTokens(Integer maxTokens)
The maximum number of output tokens that the model will generate for the response.The token count of your prompt plus maxTokens must not exceed the model’s context length. For on-demand inferencing, the response length is capped at 4,000 tokens for each run.
- Parameters:
maxTokens- the value to set- Returns:
- this builder
-
temperature
public CohereChatRequestV2.Builder temperature(Double temperature)
A number that sets the randomness of the generated output.A lower temperature means less random generations. Use lower numbers for tasks such as question answering or summarizing. High temperatures can generate hallucinations or factually incorrect information. Start with temperatures lower than 1.0 and increase the temperature for more creative outputs, as you regenerate the prompts to refine the outputs.
- Parameters:
temperature- the value to set- Returns:
- this builder
-
topK
public CohereChatRequestV2.Builder topK(Integer topK)
A sampling method in which the model chooses the next token randomly from the top k most likely tokens.A higher value for k generates more random output, which makes the output text sound more natural. The default value for k is 0 which disables this method and considers all tokens. To set a number for the likely tokens, choose an integer between 1 and 500.
If also using top p, then the model considers only the top tokens whose probabilities add up to p percent and ignores the rest of the k tokens. For example, if k is 20 but only the probabilities of the top 10 add up to the value of p, then only the top 10 tokens are chosen.
- Parameters:
topK- the value to set- Returns:
- this builder
-
topP
public CohereChatRequestV2.Builder topP(Double topP)
If set to a probability 0.0 < p < 1.0, it ensures that only the most likely tokens, with total probability mass of p, are considered for generation at each step.To eliminate tokens with low likelihood, assign p a minimum percentage for the next token's likelihood. For example, when p is set to 0.75, the model eliminates the bottom 25 percent for the next token. Set to 1.0 to consider all tokens and set to 0 to disable. If both k and p are enabled, p acts after k.
- Parameters:
topP- the value to set- Returns:
- this builder
-
frequencyPenalty
public CohereChatRequestV2.Builder frequencyPenalty(Double frequencyPenalty)
To reduce repetitiveness of generated tokens, this number penalizes new tokens based on their frequency in the generated text so far.Greater numbers encourage the model to use new tokens, while lower numbers encourage the model to repeat the tokens. Set to 0 to disable.
- Parameters:
frequencyPenalty- the value to set- Returns:
- this builder
-
presencePenalty
public CohereChatRequestV2.Builder presencePenalty(Double presencePenalty)
To reduce repetitiveness of generated tokens, this number penalizes new tokens based on whether they’ve appeared in the generated text so far.Greater numbers encourage the model to use new tokens, while lower numbers encourage the model to repeat the tokens.
Similar to frequency penalty, a penalty is applied to previously present tokens, except that this penalty is applied equally to all tokens that have already appeared, regardless of how many times they've appeared. Set to 0 to disable.
- Parameters:
presencePenalty- the value to set- Returns:
- this builder
-
seed
public CohereChatRequestV2.Builder seed(Integer seed)
If specified, the backend will make a best effort to sample tokens deterministically, so that repeated requests with the same seed and parameters yield the same result.However, determinism cannot be fully guaranteed.
- Parameters:
seed- the value to set- Returns:
- this builder
-
stopSequences
public CohereChatRequestV2.Builder stopSequences(List<String> stopSequences)
Stop the model generation when it reaches a stop sequence defined in this parameter.- Parameters:
stopSequences- the value to set- Returns:
- this builder
-
priority
public CohereChatRequestV2.Builder priority(Integer priority)
The priority of the request (lower means earlier handling; default 0 highest priority).Higher priority requests are handled first, and dropped last when the system is under load.
- Parameters:
priority- the value to set- Returns:
- this builder
-
isRawPrompting
public CohereChatRequestV2.Builder isRawPrompting(Boolean isRawPrompting)
When enabled, the user\u2019s message will be sent to the model without any preprocessing.- Parameters:
isRawPrompting- the value to set- Returns:
- this builder
-
safetyMode
public CohereChatRequestV2.Builder safetyMode(CohereChatRequestV2.SafetyMode safetyMode)
Safety mode: Adds a safety instruction for the model to use when generating responses.Contextual: (Default) Puts fewer constraints on the output. It maintains core protections by aiming to reject harmful or illegal suggestions, but it allows profanity and some toxic content, sexually explicit and violent content, and content that contains medical, financial, or legal information. Contextual mode is suited for entertainment, creative, or academic use. Strict: Aims to avoid sensitive topics, such as violent or sexual acts and profanity. This mode aims to provide a safer experience by prohibiting responses or recommendations that it finds inappropriate. Strict mode is suited for corporate use, such as for corporate communications and customer service. Off: No safety mode is applied. Note: This parameter is only compatible with models cohere.command-r-08-2024, cohere.command-r-plus-08-2024 and Cohere models released after these models. See release dates.
- Parameters:
safetyMode- the value to set- Returns:
- this builder
-
build
public CohereChatRequestV2 build()
-
copy
public CohereChatRequestV2.Builder copy(CohereChatRequestV2 model)
-
-