Class: AssemblyAI::Lemur::LemurQuestion
- Inherits:
-
Object
- Object
- AssemblyAI::Lemur::LemurQuestion
- Defined in:
- lib/assemblyai/lemur/types/lemur_question.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#answer_format ⇒ String
readonly
How you want the answer to be returned.
-
#answer_options ⇒ Array<String>
readonly
What discrete options to return.
-
#context ⇒ AssemblyAI::Lemur::LemurQuestionContext
readonly
Any context about the transcripts you wish to provide.
-
#question ⇒ String
readonly
The question you wish to ask.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ AssemblyAI::Lemur::LemurQuestion
Deserialize a JSON object to an instance of LemurQuestion.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(question:, context: OMIT, answer_format: OMIT, answer_options: OMIT, additional_properties: nil) ⇒ AssemblyAI::Lemur::LemurQuestion constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of LemurQuestion to a JSON object.
Constructor Details
#initialize(question:, context: OMIT, answer_format: OMIT, answer_options: OMIT, additional_properties: nil) ⇒ AssemblyAI::Lemur::LemurQuestion
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 38 def initialize(question:, context: OMIT, answer_format: OMIT, answer_options: OMIT, additional_properties: nil) @question = question @context = context if context != OMIT @answer_format = answer_format if answer_format != OMIT @answer_options = if != OMIT @additional_properties = additional_properties @_field_set = { "question": question, "context": context, "answer_format": answer_format, "answer_options": }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
22 23 24 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 22 def additional_properties @additional_properties end |
#answer_format ⇒ String (readonly)
Returns How you want the answer to be returned. This can be any text. Can’t be used with answer_options. Examples: “short sentence”, “bullet points”.
17 18 19 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 17 def answer_format @answer_format end |
#answer_options ⇒ Array<String> (readonly)
Returns What discrete options to return. Useful for precise responses. Can’t be used with answer_format. Example: [“Yes”, “No”].
20 21 22 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 20 def @answer_options end |
#context ⇒ AssemblyAI::Lemur::LemurQuestionContext (readonly)
Returns Any context about the transcripts you wish to provide. This can be a string or any object.
14 15 16 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 14 def context @context end |
#question ⇒ String (readonly)
Returns The question you wish to ask. For more complex questions use default model.
11 12 13 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 11 def question @question end |
Class Method Details
.from_json(json_object:) ⇒ AssemblyAI::Lemur::LemurQuestion
Deserialize a JSON object to an instance of LemurQuestion
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 58 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) question = struct["question"] if parsed_json["context"].nil? context = nil else context = parsed_json["context"].to_json context = AssemblyAI::Lemur::LemurQuestionContext.from_json(json_object: context) end answer_format = struct["answer_format"] = struct["answer_options"] new( question: question, context: context, answer_format: answer_format, answer_options: , additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
92 93 94 95 96 97 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 92 def self.validate_raw(obj:) obj.question.is_a?(String) != false || raise("Passed value for field obj.question is not the expected type, validation failed.") obj.context.nil? || AssemblyAI::Lemur::LemurQuestionContext.validate_raw(obj: obj.context) obj.answer_format&.is_a?(String) != false || raise("Passed value for field obj.answer_format is not the expected type, validation failed.") obj.&.is_a?(Array) != false || raise("Passed value for field obj.answer_options is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of LemurQuestion to a JSON object
82 83 84 |
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 82 def to_json(*_args) @_field_set&.to_json end |