Class: OCI::GenerativeAiInference::Models::CohereChatRequest

Inherits:
BaseChatRequest
  • Object
show all
Defined in:
lib/oci/generative_ai_inference/models/cohere_chat_request.rb

Overview

Details for the chat request for Cohere models.

Constant Summary collapse

PROMPT_TRUNCATION_ENUM =
[
  PROMPT_TRUNCATION_OFF = 'OFF'.freeze,
  PROMPT_TRUNCATION_AUTO_PRESERVE_ORDER = 'AUTO_PRESERVE_ORDER'.freeze
].freeze
CITATION_QUALITY_ENUM =
[
  CITATION_QUALITY_ACCURATE = 'ACCURATE'.freeze,
  CITATION_QUALITY_FAST = 'FAST'.freeze
].freeze
SAFETY_MODE_ENUM =
[
  SAFETY_MODE_CONTEXTUAL = 'CONTEXTUAL'.freeze,
  SAFETY_MODE_STRICT = 'STRICT'.freeze,
  SAFETY_MODE_OFF = 'OFF'.freeze
].freeze

Constants inherited from BaseChatRequest

BaseChatRequest::API_FORMAT_ENUM

Instance Attribute Summary collapse

Attributes inherited from BaseChatRequest

#api_format

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseChatRequest

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ CohereChatRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 258

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  attributes['apiFormat'] = 'COHERE'

  super(attributes)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.message = attributes[:'message'] if attributes[:'message']

  self.chat_history = attributes[:'chatHistory'] if attributes[:'chatHistory']

  raise 'You cannot provide both :chatHistory and :chat_history' if attributes.key?(:'chatHistory') && attributes.key?(:'chat_history')

  self.chat_history = attributes[:'chat_history'] if attributes[:'chat_history']

  self.documents = attributes[:'documents'] if attributes[:'documents']

  self.response_format = attributes[:'responseFormat'] if attributes[:'responseFormat']

  raise 'You cannot provide both :responseFormat and :response_format' if attributes.key?(:'responseFormat') && attributes.key?(:'response_format')

  self.response_format = attributes[:'response_format'] if attributes[:'response_format']

  self.is_search_queries_only = attributes[:'isSearchQueriesOnly'] unless attributes[:'isSearchQueriesOnly'].nil?
  self.is_search_queries_only = false if is_search_queries_only.nil? && !attributes.key?(:'isSearchQueriesOnly') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isSearchQueriesOnly and :is_search_queries_only' if attributes.key?(:'isSearchQueriesOnly') && attributes.key?(:'is_search_queries_only')

  self.is_search_queries_only = attributes[:'is_search_queries_only'] unless attributes[:'is_search_queries_only'].nil?
  self.is_search_queries_only = false if is_search_queries_only.nil? && !attributes.key?(:'isSearchQueriesOnly') && !attributes.key?(:'is_search_queries_only') # rubocop:disable Style/StringLiterals

  self.preamble_override = attributes[:'preambleOverride'] if attributes[:'preambleOverride']

  raise 'You cannot provide both :preambleOverride and :preamble_override' if attributes.key?(:'preambleOverride') && attributes.key?(:'preamble_override')

  self.preamble_override = attributes[:'preamble_override'] if attributes[:'preamble_override']

  self.is_stream = attributes[:'isStream'] unless attributes[:'isStream'].nil?
  self.is_stream = false if is_stream.nil? && !attributes.key?(:'isStream') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isStream and :is_stream' if attributes.key?(:'isStream') && attributes.key?(:'is_stream')

  self.is_stream = attributes[:'is_stream'] unless attributes[:'is_stream'].nil?
  self.is_stream = false if is_stream.nil? && !attributes.key?(:'isStream') && !attributes.key?(:'is_stream') # rubocop:disable Style/StringLiterals

  self.stream_options = attributes[:'streamOptions'] if attributes[:'streamOptions']

  raise 'You cannot provide both :streamOptions and :stream_options' if attributes.key?(:'streamOptions') && attributes.key?(:'stream_options')

  self.stream_options = attributes[:'stream_options'] if attributes[:'stream_options']

  self.max_tokens = attributes[:'maxTokens'] if attributes[:'maxTokens']

  raise 'You cannot provide both :maxTokens and :max_tokens' if attributes.key?(:'maxTokens') && attributes.key?(:'max_tokens')

  self.max_tokens = attributes[:'max_tokens'] if attributes[:'max_tokens']

  self.max_input_tokens = attributes[:'maxInputTokens'] if attributes[:'maxInputTokens']

  raise 'You cannot provide both :maxInputTokens and :max_input_tokens' if attributes.key?(:'maxInputTokens') && attributes.key?(:'max_input_tokens')

  self.max_input_tokens = attributes[:'max_input_tokens'] if attributes[:'max_input_tokens']

  self.temperature = attributes[:'temperature'] if attributes[:'temperature']
  self.temperature = 0.3 if temperature.nil? && !attributes.key?(:'temperature') # rubocop:disable Style/StringLiterals

  self.top_k = attributes[:'topK'] if attributes[:'topK']

  raise 'You cannot provide both :topK and :top_k' if attributes.key?(:'topK') && attributes.key?(:'top_k')

  self.top_k = attributes[:'top_k'] if attributes[:'top_k']

  self.top_p = attributes[:'topP'] if attributes[:'topP']
  self.top_p = 0.75 if top_p.nil? && !attributes.key?(:'topP') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :topP and :top_p' if attributes.key?(:'topP') && attributes.key?(:'top_p')

  self.top_p = attributes[:'top_p'] if attributes[:'top_p']
  self.top_p = 0.75 if top_p.nil? && !attributes.key?(:'topP') && !attributes.key?(:'top_p') # rubocop:disable Style/StringLiterals

  self.prompt_truncation = attributes[:'promptTruncation'] if attributes[:'promptTruncation']
  self.prompt_truncation = "OFF" if prompt_truncation.nil? && !attributes.key?(:'promptTruncation') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :promptTruncation and :prompt_truncation' if attributes.key?(:'promptTruncation') && attributes.key?(:'prompt_truncation')

  self.prompt_truncation = attributes[:'prompt_truncation'] if attributes[:'prompt_truncation']
  self.prompt_truncation = "OFF" if prompt_truncation.nil? && !attributes.key?(:'promptTruncation') && !attributes.key?(:'prompt_truncation') # rubocop:disable Style/StringLiterals

  self.frequency_penalty = attributes[:'frequencyPenalty'] if attributes[:'frequencyPenalty']
  self.frequency_penalty = 0.0 if frequency_penalty.nil? && !attributes.key?(:'frequencyPenalty') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :frequencyPenalty and :frequency_penalty' if attributes.key?(:'frequencyPenalty') && attributes.key?(:'frequency_penalty')

  self.frequency_penalty = attributes[:'frequency_penalty'] if attributes[:'frequency_penalty']
  self.frequency_penalty = 0.0 if frequency_penalty.nil? && !attributes.key?(:'frequencyPenalty') && !attributes.key?(:'frequency_penalty') # rubocop:disable Style/StringLiterals

  self.presence_penalty = attributes[:'presencePenalty'] if attributes[:'presencePenalty']
  self.presence_penalty = 0.0 if presence_penalty.nil? && !attributes.key?(:'presencePenalty') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :presencePenalty and :presence_penalty' if attributes.key?(:'presencePenalty') && attributes.key?(:'presence_penalty')

  self.presence_penalty = attributes[:'presence_penalty'] if attributes[:'presence_penalty']
  self.presence_penalty = 0.0 if presence_penalty.nil? && !attributes.key?(:'presencePenalty') && !attributes.key?(:'presence_penalty') # rubocop:disable Style/StringLiterals

  self.seed = attributes[:'seed'] if attributes[:'seed']

  self.is_echo = attributes[:'isEcho'] unless attributes[:'isEcho'].nil?
  self.is_echo = false if is_echo.nil? && !attributes.key?(:'isEcho') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isEcho and :is_echo' if attributes.key?(:'isEcho') && attributes.key?(:'is_echo')

  self.is_echo = attributes[:'is_echo'] unless attributes[:'is_echo'].nil?
  self.is_echo = false if is_echo.nil? && !attributes.key?(:'isEcho') && !attributes.key?(:'is_echo') # rubocop:disable Style/StringLiterals

  self.tools = attributes[:'tools'] if attributes[:'tools']

  self.tool_results = attributes[:'toolResults'] if attributes[:'toolResults']

  raise 'You cannot provide both :toolResults and :tool_results' if attributes.key?(:'toolResults') && attributes.key?(:'tool_results')

  self.tool_results = attributes[:'tool_results'] if attributes[:'tool_results']

  self.is_force_single_step = attributes[:'isForceSingleStep'] unless attributes[:'isForceSingleStep'].nil?
  self.is_force_single_step = false if is_force_single_step.nil? && !attributes.key?(:'isForceSingleStep') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isForceSingleStep and :is_force_single_step' if attributes.key?(:'isForceSingleStep') && attributes.key?(:'is_force_single_step')

  self.is_force_single_step = attributes[:'is_force_single_step'] unless attributes[:'is_force_single_step'].nil?
  self.is_force_single_step = false if is_force_single_step.nil? && !attributes.key?(:'isForceSingleStep') && !attributes.key?(:'is_force_single_step') # rubocop:disable Style/StringLiterals

  self.stop_sequences = attributes[:'stopSequences'] if attributes[:'stopSequences']

  raise 'You cannot provide both :stopSequences and :stop_sequences' if attributes.key?(:'stopSequences') && attributes.key?(:'stop_sequences')

  self.stop_sequences = attributes[:'stop_sequences'] if attributes[:'stop_sequences']

  self.is_raw_prompting = attributes[:'isRawPrompting'] unless attributes[:'isRawPrompting'].nil?
  self.is_raw_prompting = false if is_raw_prompting.nil? && !attributes.key?(:'isRawPrompting') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :isRawPrompting and :is_raw_prompting' if attributes.key?(:'isRawPrompting') && attributes.key?(:'is_raw_prompting')

  self.is_raw_prompting = attributes[:'is_raw_prompting'] unless attributes[:'is_raw_prompting'].nil?
  self.is_raw_prompting = false if is_raw_prompting.nil? && !attributes.key?(:'isRawPrompting') && !attributes.key?(:'is_raw_prompting') # rubocop:disable Style/StringLiterals

  self.citation_quality = attributes[:'citationQuality'] if attributes[:'citationQuality']
  self.citation_quality = "ACCURATE" if citation_quality.nil? && !attributes.key?(:'citationQuality') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :citationQuality and :citation_quality' if attributes.key?(:'citationQuality') && attributes.key?(:'citation_quality')

  self.citation_quality = attributes[:'citation_quality'] if attributes[:'citation_quality']
  self.citation_quality = "ACCURATE" if citation_quality.nil? && !attributes.key?(:'citationQuality') && !attributes.key?(:'citation_quality') # rubocop:disable Style/StringLiterals

  self.safety_mode = attributes[:'safetyMode'] if attributes[:'safetyMode']
  self.safety_mode = "CONTEXTUAL" if safety_mode.nil? && !attributes.key?(:'safetyMode') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :safetyMode and :safety_mode' if attributes.key?(:'safetyMode') && attributes.key?(:'safety_mode')

  self.safety_mode = attributes[:'safety_mode'] if attributes[:'safety_mode']
  self.safety_mode = "CONTEXTUAL" if safety_mode.nil? && !attributes.key?(:'safetyMode') && !attributes.key?(:'safety_mode') # rubocop:disable Style/StringLiterals
end

Instance Attribute Details

#chat_historyArray<OCI::GenerativeAiInference::Models::CohereMessage>

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.



34
35
36
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 34

def chat_history
  @chat_history
end

#citation_qualityString

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:

  • (String)


148
149
150
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 148

def citation_quality
  @citation_quality
end

#documentsArray<Object>

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:

  • (Array<Object>)


46
47
48
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 46

def documents
  @documents
end

#frequency_penaltyFloat

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:

  • (Float)


106
107
108
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 106

def frequency_penalty
  @frequency_penalty
end

#is_echoBOOLEAN

Returns the full prompt that was sent to the model when True.

Returns:

  • (BOOLEAN)


122
123
124
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 122

def is_echo
  @is_echo
end

#is_force_single_stepBOOLEAN

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:

  • (BOOLEAN)


135
136
137
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 135

def is_force_single_step
  @is_force_single_step
end

#is_raw_promptingBOOLEAN

When enabled, the useru2019s message will be sent to the model without any preprocessing.

Returns:

  • (BOOLEAN)


143
144
145
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 143

def is_raw_prompting
  @is_raw_prompting
end

#is_search_queries_onlyBOOLEAN

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:

  • (BOOLEAN)


54
55
56
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 54

def is_search_queries_only
  @is_search_queries_only
end

#is_streamBOOLEAN

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:

  • (BOOLEAN)


65
66
67
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 65

def is_stream
  @is_stream
end

#max_input_tokensInteger

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:

  • (Integer)


76
77
78
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 76

def max_input_tokens
  @max_input_tokens
end

#max_tokensInteger

The maximum number of output tokens that the model will generate for the response.

Returns:

  • (Integer)


72
73
74
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 72

def max_tokens
  @max_tokens
end

#messageString

[Required] The text that the user inputs for the model to respond to.

Returns:

  • (String)


30
31
32
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 30

def message
  @message
end

#preamble_overrideString

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:

  • (String)


61
62
63
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 61

def preamble_override
  @preamble_override
end

#presence_penaltyFloat

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:

  • (Float)


113
114
115
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 113

def presence_penalty
  @presence_penalty
end

#prompt_truncationString

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:

  • (String)


101
102
103
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 101

def prompt_truncation
  @prompt_truncation
end

#response_formatOCI::GenerativeAiInference::Models::CohereResponseFormat



49
50
51
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 49

def response_format
  @response_format
end

#safety_modeString

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.

Returns:

  • (String)


157
158
159
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 157

def safety_mode
  @safety_mode
end

#seedInteger

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:

  • (Integer)


118
119
120
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 118

def seed
  @seed
end

#stop_sequencesArray<String>

Stop the model generation when it reaches a stop sequence defined in this parameter.

Returns:

  • (Array<String>)


139
140
141
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 139

def stop_sequences
  @stop_sequences
end

#stream_optionsOCI::GenerativeAiInference::Models::StreamOptions



68
69
70
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 68

def stream_options
  @stream_options
end

#temperatureFloat

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:

  • (Float)


82
83
84
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 82

def temperature
  @temperature
end

#tool_resultsArray<OCI::GenerativeAiInference::Models::CohereToolResult>

A list of results from invoking tools recommended by the model in the previous chat turn.



130
131
132
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 130

def tool_results
  @tool_results
end

#toolsArray<OCI::GenerativeAiInference::Models::CohereTool>

A list of available tools (functions) that the model may suggest invoking before producing a text response.



126
127
128
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 126

def tools
  @tools
end

#top_kInteger

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:

  • (Integer)


89
90
91
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 89

def top_k
  @top_k
end

#top_pFloat

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:

  • (Float)


96
97
98
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 96

def top_p
  @top_p
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 160

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'api_format': :'apiFormat',
    'message': :'message',
    'chat_history': :'chatHistory',
    'documents': :'documents',
    'response_format': :'responseFormat',
    'is_search_queries_only': :'isSearchQueriesOnly',
    'preamble_override': :'preambleOverride',
    'is_stream': :'isStream',
    'stream_options': :'streamOptions',
    'max_tokens': :'maxTokens',
    'max_input_tokens': :'maxInputTokens',
    'temperature': :'temperature',
    'top_k': :'topK',
    'top_p': :'topP',
    'prompt_truncation': :'promptTruncation',
    'frequency_penalty': :'frequencyPenalty',
    'presence_penalty': :'presencePenalty',
    'seed': :'seed',
    'is_echo': :'isEcho',
    'tools': :'tools',
    'tool_results': :'toolResults',
    'is_force_single_step': :'isForceSingleStep',
    'stop_sequences': :'stopSequences',
    'is_raw_prompting': :'isRawPrompting',
    'citation_quality': :'citationQuality',
    'safety_mode': :'safetyMode'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 194

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'api_format': :'String',
    'message': :'String',
    'chat_history': :'Array<OCI::GenerativeAiInference::Models::CohereMessage>',
    'documents': :'Array<Object>',
    'response_format': :'OCI::GenerativeAiInference::Models::CohereResponseFormat',
    'is_search_queries_only': :'BOOLEAN',
    'preamble_override': :'String',
    'is_stream': :'BOOLEAN',
    'stream_options': :'OCI::GenerativeAiInference::Models::StreamOptions',
    'max_tokens': :'Integer',
    'max_input_tokens': :'Integer',
    'temperature': :'Float',
    'top_k': :'Integer',
    'top_p': :'Float',
    'prompt_truncation': :'String',
    'frequency_penalty': :'Float',
    'presence_penalty': :'Float',
    'seed': :'Integer',
    'is_echo': :'BOOLEAN',
    'tools': :'Array<OCI::GenerativeAiInference::Models::CohereTool>',
    'tool_results': :'Array<OCI::GenerativeAiInference::Models::CohereToolResult>',
    'is_force_single_step': :'BOOLEAN',
    'stop_sequences': :'Array<String>',
    'is_raw_prompting': :'BOOLEAN',
    'citation_quality': :'String',
    'safety_mode': :'String'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 453

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    api_format == other.api_format &&
    message == other.message &&
    chat_history == other.chat_history &&
    documents == other.documents &&
    response_format == other.response_format &&
    is_search_queries_only == other.is_search_queries_only &&
    preamble_override == other.preamble_override &&
    is_stream == other.is_stream &&
    stream_options == other.stream_options &&
    max_tokens == other.max_tokens &&
    max_input_tokens == other.max_input_tokens &&
    temperature == other.temperature &&
    top_k == other.top_k &&
    top_p == other.top_p &&
    prompt_truncation == other.prompt_truncation &&
    frequency_penalty == other.frequency_penalty &&
    presence_penalty == other.presence_penalty &&
    seed == other.seed &&
    is_echo == other.is_echo &&
    tools == other.tools &&
    tool_results == other.tool_results &&
    is_force_single_step == other.is_force_single_step &&
    stop_sequences == other.stop_sequences &&
    is_raw_prompting == other.is_raw_prompting &&
    citation_quality == other.citation_quality &&
    safety_mode == other.safety_mode
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 508

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


488
489
490
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 488

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



497
498
499
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 497

def hash
  [api_format, message, chat_history, documents, response_format, is_search_queries_only, preamble_override, is_stream, stream_options, max_tokens, max_input_tokens, temperature, top_k, top_p, prompt_truncation, frequency_penalty, presence_penalty, seed, is_echo, tools, tool_results, is_force_single_step, stop_sequences, is_raw_prompting, citation_quality, safety_mode].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



541
542
543
544
545
546
547
548
549
550
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 541

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



535
536
537
# File 'lib/oci/generative_ai_inference/models/cohere_chat_request.rb', line 535

def to_s
  to_hash.to_s
end