Class CohereChatRequest
- java.lang.Object
-
- com.oracle.bmc.http.client.internal.ExplicitlySetBmcModel
-
- com.oracle.bmc.generativeaiinference.model.BaseChatRequest
-
- com.oracle.bmc.generativeaiinference.model.CohereChatRequest
-
@Generated(value="OracleSDKGenerator", comments="API Version: 20231130") public final class CohereChatRequest extends BaseChatRequest
Details for the chat request for Cohere models.
Note: Objects should always be created or deserialized using theCohereChatRequest.Builder
. This model distinguishes fields that are null because they are unset from fields that are explicitly set to null. This is done in the setter methods of theCohereChatRequest.Builder
, which maintain a set of all explicitly set fields calledCohereChatRequest.Builder.__explicitlySet__
. ThehashCode()
andequals(Object)
methods are implemented to take the explicitly set fields into account. The constructor, on the other hand, does not take the explicitly set fields into account (since the constructor cannot distinguish explicit null from unset null).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CohereChatRequest.Builder
static class
CohereChatRequest.CitationQuality
When FAST is selected, citations are generated at the same time as the text output and the request will be completed sooner.static class
CohereChatRequest.PromptTruncation
Defaults to OFF.-
Nested classes/interfaces inherited from class com.oracle.bmc.generativeaiinference.model.BaseChatRequest
BaseChatRequest.ApiFormat
-
-
Constructor Summary
Constructors Constructor Description CohereChatRequest(String message, List<CohereMessage> chatHistory, List<Object> documents, CohereResponseFormat responseFormat, Boolean isSearchQueriesOnly, String preambleOverride, Boolean isStream, Integer maxTokens, Integer maxInputTokens, Double temperature, Integer topK, Double topP, CohereChatRequest.PromptTruncation promptTruncation, Double frequencyPenalty, Double presencePenalty, Integer seed, Boolean isEcho, List<CohereTool> tools, List<CohereToolResult> toolResults, Boolean isForceSingleStep, List<String> stopSequences, Boolean isRawPrompting, CohereChatRequest.CitationQuality citationQuality)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CohereChatRequest.Builder
builder()
Create a new builder.boolean
equals(Object o)
List<CohereMessage>
getChatHistory()
The list of previous messages between the user and the model.CohereChatRequest.CitationQuality
getCitationQuality()
When FAST is selected, citations are generated at the same time as the text output and the request will be completed sooner.List<Object>
getDocuments()
A list of relevant documents that the model can refer to for generating grounded responses to the user’s requests.Double
getFrequencyPenalty()
To reduce repetitiveness of generated tokens, this number penalizes new tokens based on their frequency in the generated text so far.Boolean
getIsEcho()
Returns the full prompt that was sent to the model when True.Boolean
getIsForceSingleStep()
When enabled, the model will issue (potentially multiple) tool calls in a single step, before it receives the tool responses and directly answers the user’s original message.Boolean
getIsRawPrompting()
When enabled, the user\u2019s message will be sent to the model without any preprocessing.Boolean
getIsSearchQueriesOnly()
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.Boolean
getIsStream()
Whether to stream the partial progress of the model’s response.Integer
getMaxInputTokens()
The maximum number of input tokens to send to the model.Integer
getMaxTokens()
The maximum number of output tokens that the model will generate for the response.String
getMessage()
The text that the user inputs for the model to respond to.String
getPreambleOverride()
If specified, the default Cohere preamble is replaced with the provided preamble.Double
getPresencePenalty()
To reduce repetitiveness of generated tokens, this number penalizes new tokens based on whether they’ve appeared in the generated text so far.CohereChatRequest.PromptTruncation
getPromptTruncation()
Defaults to OFF.CohereResponseFormat
getResponseFormat()
Integer
getSeed()
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.List<String>
getStopSequences()
Stop the model generation when it reaches a stop sequence defined in this parameter.Double
getTemperature()
A number that sets the randomness of the generated output.List<CohereToolResult>
getToolResults()
A list of results from invoking tools recommended by the model in the previous chat turn.List<CohereTool>
getTools()
A list of available tools (functions) that the model may suggest invoking before producing a text response.Integer
getTopK()
A sampling method in which the model chooses the next token randomly from the top k most likely tokens.Double
getTopP()
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.int
hashCode()
CohereChatRequest.Builder
toBuilder()
String
toString()
String
toString(boolean includeByteArrayContents)
Return a string representation of the object.
-
-
-
Constructor Detail
-
CohereChatRequest
@Deprecated public CohereChatRequest(String message, List<CohereMessage> chatHistory, List<Object> documents, CohereResponseFormat responseFormat, Boolean isSearchQueriesOnly, String preambleOverride, Boolean isStream, Integer maxTokens, Integer maxInputTokens, Double temperature, Integer topK, Double topP, CohereChatRequest.PromptTruncation promptTruncation, Double frequencyPenalty, Double presencePenalty, Integer seed, Boolean isEcho, List<CohereTool> tools, List<CohereToolResult> toolResults, Boolean isForceSingleStep, List<String> stopSequences, Boolean isRawPrompting, CohereChatRequest.CitationQuality citationQuality)
Deprecated.
-
-
Method Detail
-
builder
public static CohereChatRequest.Builder builder()
Create a new builder.
-
toBuilder
public CohereChatRequest.Builder toBuilder()
-
getMessage
public String getMessage()
The text that the user inputs for the model to respond to.- Returns:
- the value
-
getChatHistory
public List<CohereMessage> getChatHistory()
The list of previous messages between the user and the model.The chat history gives the model context for responding to the user’s inputs.
- Returns:
- the value
-
getDocuments
public List<Object> getDocuments()
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.
Example: [ { "title": "Tall penguins", "snippet": "Emperor penguins are the tallest." }, { "title": "Penguin habitats", "snippet": "Emperor penguins only live in Antarctica." } ]
- Returns:
- the value
-
getResponseFormat
public CohereResponseFormat getResponseFormat()
-
getIsSearchQueriesOnly
public Boolean getIsSearchQueriesOnly()
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.- Returns:
- the value
-
getPreambleOverride
public String getPreambleOverride()
If specified, the default Cohere preamble is replaced with the provided preamble.A preamble is an initial guideline message that can change the model’s overall chat behavior and conversation style. Default preambles vary for different models.
Example: You are a travel advisor. Answer with a pirate tone.
- Returns:
- the value
-
getIsStream
public Boolean getIsStream()
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.
- Returns:
- the value
-
getMaxTokens
public Integer getMaxTokens()
The maximum number of output tokens that the model will generate for the response.- Returns:
- the value
-
getMaxInputTokens
public Integer getMaxInputTokens()
The maximum number of input tokens to send to the model.If not specified, max_input_tokens is the model’s context length limit minus a small buffer.
- Returns:
- the value
-
getTemperature
public Double getTemperature()
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.
- Returns:
- the value
-
getTopK
public Integer getTopK()
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.
- Returns:
- the value
-
getTopP
public Double getTopP()
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.
- Returns:
- the value
-
getPromptTruncation
public CohereChatRequest.PromptTruncation getPromptTruncation()
Defaults to OFF.Dictates how the prompt will be constructed. With promptTruncation set to AUTO_PRESERVE_ORDER, some elements from chatHistory and documents will be dropped to construct a prompt that fits within the model’s context length limit. During this process the order of the documents and chat history will be preserved. With prompt_truncation set to OFF, no elements will be dropped.
- Returns:
- the value
-
getFrequencyPenalty
public Double getFrequencyPenalty()
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.
- Returns:
- the value
-
getPresencePenalty
public Double getPresencePenalty()
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.
- Returns:
- the value
-
getSeed
public Integer getSeed()
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.
- Returns:
- the value
-
getIsEcho
public Boolean getIsEcho()
Returns the full prompt that was sent to the model when True.- Returns:
- the value
-
getTools
public List<CohereTool> getTools()
A list of available tools (functions) that the model may suggest invoking before producing a text response.- Returns:
- the value
-
getToolResults
public List<CohereToolResult> getToolResults()
A list of results from invoking tools recommended by the model in the previous chat turn.- Returns:
- the value
-
getIsForceSingleStep
public Boolean getIsForceSingleStep()
When enabled, the model will issue (potentially multiple) tool calls in a single step, before it receives the tool responses and directly answers the user’s original message.- Returns:
- the value
-
getStopSequences
public List<String> getStopSequences()
Stop the model generation when it reaches a stop sequence defined in this parameter.- Returns:
- the value
-
getIsRawPrompting
public Boolean getIsRawPrompting()
When enabled, the user\u2019s message will be sent to the model without any preprocessing.- Returns:
- the value
-
getCitationQuality
public CohereChatRequest.CitationQuality getCitationQuality()
When FAST is selected, citations are generated at the same time as the text output and the request will be completed sooner.May result in less accurate citations.
- Returns:
- the value
-
toString
public String toString()
- Overrides:
toString
in classBaseChatRequest
-
toString
public String toString(boolean includeByteArrayContents)
Return a string representation of the object.- Overrides:
toString
in classBaseChatRequest
- Parameters:
includeByteArrayContents
- true to include the full contents of byte arrays- Returns:
- string representation
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classBaseChatRequest
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBaseChatRequest
-
-