Class: AssemblyAI::Lemur::LemurQuestion

Inherits:
Object
  • Object
show all
Defined in:
lib/assemblyai/lemur/types/lemur_question.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(question:, context: OMIT, answer_format: OMIT, answer_options: OMIT, additional_properties: nil) ⇒ AssemblyAI::Lemur::LemurQuestion

Parameters:

  • question (String)

    The question you wish to ask. For more complex questions use default model.

  • context (AssemblyAI::Lemur::LemurQuestionContext) (defaults to: OMIT)

    Any context about the transcripts you wish to provide. This can be a string or any object.

  • answer_format (String) (defaults to: OMIT)

    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”

  • answer_options (Array<String>) (defaults to: OMIT)

    What discrete options to return. Useful for precise responses. Can’t be used with answer_format. Example: [“Yes”, “No”]

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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 = answer_options if answer_options != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "question": question,
    "context": context,
    "answer_format": answer_format,
    "answer_options": answer_options
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_formatString (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”.

Returns:

  • (String)

    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_optionsArray<String> (readonly)

Returns What discrete options to return. Useful for precise responses. Can’t be used with answer_format. Example: [“Yes”, “No”].

Returns:

  • (Array<String>)

    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
  @answer_options
end

#contextAssemblyAI::Lemur::LemurQuestionContext (readonly)

Returns Any context about the transcripts you wish to provide. This can be a string or any object.

Returns:



14
15
16
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 14

def context
  @context
end

#questionString (readonly)

Returns The question you wish to ask. For more complex questions use default model.

Returns:

  • (String)

    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

Parameters:

  • json_object (String)

Returns:



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"]
  answer_options = struct["answer_options"]
  new(
    question: question,
    context: context,
    answer_format: answer_format,
    answer_options: 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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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.answer_options&.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

Returns:

  • (String)


82
83
84
# File 'lib/assemblyai/lemur/types/lemur_question.rb', line 82

def to_json(*_args)
  @_field_set&.to_json
end