CohereChatRequest

class oci.generative_ai_inference.models.CohereChatRequest(**kwargs)

Bases: oci.generative_ai_inference.models.base_chat_request.BaseChatRequest

Details for the chat request for Cohere models.

Attributes

API_FORMAT_COHERE str(object=’’) -> str
API_FORMAT_GENERIC str(object=’’) -> str
api_format [Required] Gets the api_format of this BaseChatRequest.
chat_history Gets the chat_history of this CohereChatRequest.
documents Gets the documents of this CohereChatRequest.
frequency_penalty Gets the frequency_penalty of this CohereChatRequest.
is_search_queries_only Gets the is_search_queries_only of this CohereChatRequest.
is_stream Gets the is_stream of this CohereChatRequest.
max_tokens Gets the max_tokens of this CohereChatRequest.
message [Required] Gets the message of this CohereChatRequest.
preamble_override Gets the preamble_override of this CohereChatRequest.
presence_penalty Gets the presence_penalty of this CohereChatRequest.
temperature Gets the temperature of this CohereChatRequest.
top_k Gets the top_k of this CohereChatRequest.
top_p Gets the top_p of this CohereChatRequest.

Methods

__init__(**kwargs) Initializes a new CohereChatRequest object with values from keyword arguments.
get_subtype(object_dictionary) Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.
API_FORMAT_COHERE = 'COHERE'
API_FORMAT_GENERIC = 'GENERIC'
__init__(**kwargs)

Initializes a new CohereChatRequest object with values from keyword arguments. The default value of the api_format attribute of this class is COHERE and it should not be changed. The following keyword arguments are supported (corresponding to the getters/setters of this class):

Parameters:
  • api_format (str) – The value to assign to the api_format property of this CohereChatRequest. Allowed values for this property are: “COHERE”, “GENERIC”
  • message (str) – The value to assign to the message property of this CohereChatRequest.
  • chat_history (list[oci.generative_ai_inference.models.CohereMessage]) – The value to assign to the chat_history property of this CohereChatRequest.
  • documents (list[object]) – The value to assign to the documents property of this CohereChatRequest.
  • is_search_queries_only (bool) – The value to assign to the is_search_queries_only property of this CohereChatRequest.
  • preamble_override (str) – The value to assign to the preamble_override property of this CohereChatRequest.
  • is_stream (bool) – The value to assign to the is_stream property of this CohereChatRequest.
  • max_tokens (int) – The value to assign to the max_tokens property of this CohereChatRequest.
  • temperature (float) – The value to assign to the temperature property of this CohereChatRequest.
  • top_k (int) – The value to assign to the top_k property of this CohereChatRequest.
  • top_p (float) – The value to assign to the top_p property of this CohereChatRequest.
  • frequency_penalty (float) – The value to assign to the frequency_penalty property of this CohereChatRequest.
  • presence_penalty (float) – The value to assign to the presence_penalty property of this CohereChatRequest.
api_format

[Required] Gets the api_format of this BaseChatRequest. The api format for the model’s request

Allowed values for this property are: “COHERE”, “GENERIC”

Returns:The api_format of this BaseChatRequest.
Return type:str
chat_history

Gets the chat_history of this CohereChatRequest. A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user’s message.

Returns:The chat_history of this CohereChatRequest.
Return type:list[oci.generative_ai_inference.models.CohereMessage]
documents

Gets the documents of this CohereChatRequest. list of relevant documents that the model can cite to generate a more accurate reply. Some suggested keys are “text”, “author”, and “date”. For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words.

Returns:The documents of this CohereChatRequest.
Return type:list[object]
frequency_penalty

Gets the frequency_penalty of this CohereChatRequest. 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 frequency_penalty of this CohereChatRequest.
Return type:float
static get_subtype(object_dictionary)

Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.

is_search_queries_only

Gets the is_search_queries_only of this CohereChatRequest. When true, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user’s message will be generated.

Returns:The is_search_queries_only of this CohereChatRequest.
Return type:bool
is_stream

Gets the is_stream of this CohereChatRequest. Whether to stream back partial progress. If set, tokens are sent as data-only server-sent events as they become available.

Returns:The is_stream of this CohereChatRequest.
Return type:bool
max_tokens

Gets the max_tokens of this CohereChatRequest. The maximum number of tokens to predict for each response. Includes input plus output tokens.

Returns:The max_tokens of this CohereChatRequest.
Return type:int
message

[Required] Gets the message of this CohereChatRequest. Text input for the model to respond to.

Returns:The message of this CohereChatRequest.
Return type:str
preamble_override

Gets the preamble_override of this CohereChatRequest. When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model’s overall behavior and conversation style. Default preambles vary for different models.

Returns:The preamble_override of this CohereChatRequest.
Return type:str
presence_penalty

Gets the presence_penalty of this CohereChatRequest. 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 presence_penalty of this CohereChatRequest.
Return type:float
temperature

Gets the temperature of this CohereChatRequest. A number that sets the randomness of the generated output. A lower temperature means a less random generations. Use lower numbers for tasks with a correct answer 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 temperature of this CohereChatRequest.
Return type:float
top_k

Gets the top_k of this CohereChatRequest. An integer that sets up the model to use only the top k most likely tokens in the generated output. A higher k introduces more randomness into the output making the output text sound more natural. Default value 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 the probabilities of the top 10 add up to .75, then only the top 10 tokens are chosen.

Returns:The top_k of this CohereChatRequest.
Return type:int
top_p

Gets the top_p of this CohereChatRequest. 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 top_p of this CohereChatRequest.
Return type:float