assemblyai 1.0.0.pre.beta.7 → 1.0.0.pre.beta.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assemblyai/files/client.rb +4 -2
  3. data/lib/assemblyai/files/types/uploaded_file.rb +20 -11
  4. data/lib/assemblyai/lemur/client.rb +260 -150
  5. data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +28 -14
  6. data/lib/assemblyai/lemur/types/lemur_base_params.rb +83 -55
  7. data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +11 -5
  8. data/lib/assemblyai/lemur/types/lemur_base_response.rb +20 -11
  9. data/lib/assemblyai/lemur/types/lemur_question.rb +57 -32
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -15
  12. data/lib/assemblyai/lemur/types/lemur_question_context.rb +13 -6
  13. data/lib/assemblyai/lemur/types/lemur_summary_response.rb +28 -14
  14. data/lib/assemblyai/lemur/types/lemur_task_response.rb +28 -14
  15. data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +32 -17
  16. data/lib/assemblyai/realtime/client.rb +30 -14
  17. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
  18. data/lib/assemblyai/realtime/types/final_transcript.rb +73 -42
  19. data/lib/assemblyai/realtime/types/force_end_utterance.rb +20 -11
  20. data/lib/assemblyai/realtime/types/message_type.rb +1 -0
  21. data/lib/assemblyai/realtime/types/partial_transcript.rb +63 -35
  22. data/lib/assemblyai/realtime/types/realtime_base_message.rb +22 -13
  23. data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +57 -31
  24. data/lib/assemblyai/realtime/types/realtime_error.rb +20 -11
  25. data/lib/assemblyai/realtime/types/realtime_message.rb +44 -18
  26. data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +20 -11
  27. data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
  28. data/lib/assemblyai/realtime/types/session_begins.rb +32 -15
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +21 -12
  31. data/lib/assemblyai/realtime/types/terminate_session.rb +20 -11
  32. data/lib/assemblyai/realtime/types/word.rb +36 -18
  33. data/lib/assemblyai/streaming/types/receive_message.rb +113 -0
  34. data/lib/assemblyai/{realtime → streaming}/types/send_message.rb +26 -14
  35. data/lib/assemblyai/streaming/types/streaming.rb +11 -0
  36. data/lib/assemblyai/transcripts/client.rb +50 -18
  37. data/lib/assemblyai/transcripts/list_by_url_client.rb +6 -4
  38. data/lib/assemblyai/transcripts/polling_client.rb +12 -2
  39. data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +40 -19
  40. data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +38 -14
  41. data/lib/assemblyai/transcripts/types/chapter.rb +40 -20
  42. data/lib/assemblyai/transcripts/types/content_safety_label.rb +32 -16
  43. data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +51 -29
  44. data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +51 -29
  45. data/lib/assemblyai/transcripts/types/entity.rb +41 -21
  46. data/lib/assemblyai/transcripts/types/entity_type.rb +15 -0
  47. data/lib/assemblyai/transcripts/types/page_details.rb +62 -36
  48. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  49. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  50. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  51. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  52. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +63 -36
  53. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  54. data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
  55. data/lib/assemblyai/transcripts/types/substitution_policy.rb +3 -1
  56. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  57. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -20
  58. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  59. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  60. data/lib/assemblyai/transcripts/types/transcript.rb +513 -295
  61. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  62. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +87 -4
  63. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -17
  64. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +60 -35
  65. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +338 -196
  66. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -34
  67. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  68. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -34
  69. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  70. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -32
  71. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  72. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  73. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  74. data/lib/assemblyai/types/error.rb +32 -16
  75. data/lib/requests.rb +80 -34
  76. data/lib/types_export.rb +4 -3
  77. metadata +6 -5
  78. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  79. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
@@ -1,45 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Lemur
7
8
  class LemurActionItemsResponse
8
- attr_reader :response, :request_id, :additional_properties
9
+ # @return [String] The response generated by LeMUR
10
+ attr_reader :response
11
+ # @return [String] The ID of the LeMUR request
12
+ attr_reader :request_id
13
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
14
+ attr_reader :additional_properties
15
+ # @return [Object]
16
+ attr_reader :_field_set
17
+ protected :_field_set
18
+
19
+ OMIT = Object.new
9
20
 
10
21
  # @param response [String] The response generated by LeMUR
11
22
  # @param request_id [String] The ID of the LeMUR request
12
23
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
- # @return [Lemur::LemurActionItemsResponse]
24
+ # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
14
25
  def initialize(response:, request_id:, additional_properties: nil)
15
- # @type [String] The response generated by LeMUR
16
26
  @response = response
17
- # @type [String] The ID of the LeMUR request
18
27
  @request_id = request_id
19
- # @type [OpenStruct] Additional properties unmapped to the current class definition
20
28
  @additional_properties = additional_properties
29
+ @_field_set = { "response": response, "request_id": request_id }
21
30
  end
22
31
 
23
32
  # Deserialize a JSON object to an instance of LemurActionItemsResponse
24
33
  #
25
- # @param json_object [JSON]
26
- # @return [Lemur::LemurActionItemsResponse]
34
+ # @param json_object [String]
35
+ # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
27
36
  def self.from_json(json_object:)
28
37
  struct = JSON.parse(json_object, object_class: OpenStruct)
29
- JSON.parse(json_object)
30
- response = struct.response
31
- request_id = struct.request_id
32
- new(response: response, request_id: request_id, additional_properties: struct)
38
+ response = struct["response"]
39
+ request_id = struct["request_id"]
40
+ new(
41
+ response: response,
42
+ request_id: request_id,
43
+ additional_properties: struct
44
+ )
33
45
  end
34
46
 
35
47
  # Serialize an instance of LemurActionItemsResponse to a JSON object
36
48
  #
37
- # @return [JSON]
49
+ # @return [String]
38
50
  def to_json(*_args)
39
- { "response": @response, "request_id": @request_id }.to_json
51
+ @_field_set&.to_json
40
52
  end
41
53
 
42
- # 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.
54
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
55
+ # hash and check each fields type against the current object's property
56
+ # definitions.
43
57
  #
44
58
  # @param obj [Object]
45
59
  # @return [Void]
@@ -2,95 +2,123 @@
2
2
 
3
3
  require_relative "lemur_base_params_context"
4
4
  require_relative "lemur_model"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Lemur
9
10
  class LemurBaseParams
10
- attr_reader :transcript_ids, :input_text, :context, :final_model, :max_output_size, :temperature,
11
- :additional_properties
11
+ # @return [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
12
+ # hours, whichever is lower.
13
+ # Use either transcript_ids or input_text as input into LeMUR.
14
+ attr_reader :transcript_ids
15
+ # @return [String] Custom formatted transcript data. Maximum size is the context limit of the
16
+ # selected model, which defaults to 100000.
17
+ # Use either transcript_ids or input_text as input into LeMUR.
18
+ attr_reader :input_text
19
+ # @return [AssemblyAI::Lemur::LemurBaseParamsContext] Context to provide the model. This can be a string or a free-form JSON value.
20
+ attr_reader :context
21
+ # @return [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
22
+ # Defaults to "default".
23
+ attr_reader :final_model
24
+ # @return [Integer] Max output size in tokens, up to 4000
25
+ attr_reader :max_output_size
26
+ # @return [Float] The temperature to use for the model.
27
+ # Higher values result in answers that are more creative, lower values are more
28
+ # conservative.
29
+ # Can be any value between 0.0 and 1.0 inclusive.
30
+ attr_reader :temperature
31
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
32
+ attr_reader :additional_properties
33
+ # @return [Object]
34
+ attr_reader :_field_set
35
+ protected :_field_set
12
36
 
13
- # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100 hours, whichever is lower.
14
- # Use either transcript_ids or input_text as input into LeMUR.
15
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
16
- # Use either transcript_ids or input_text as input into LeMUR.
17
- # @param context [Lemur::LemurBaseParamsContext] Context to provide the model. This can be a string or a free-form JSON value.
18
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
19
- # Defaults to "default".
37
+ OMIT = Object.new
38
+
39
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
40
+ # hours, whichever is lower.
41
+ # Use either transcript_ids or input_text as input into LeMUR.
42
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
43
+ # selected model, which defaults to 100000.
44
+ # Use either transcript_ids or input_text as input into LeMUR.
45
+ # @param context [AssemblyAI::Lemur::LemurBaseParamsContext] Context to provide the model. This can be a string or a free-form JSON value.
46
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
47
+ # Defaults to "default".
20
48
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
21
49
  # @param temperature [Float] The temperature to use for the model.
22
- # Higher values result in answers that are more creative, lower values are more conservative.
23
- # Can be any value between 0.0 and 1.0 inclusive.
50
+ # Higher values result in answers that are more creative, lower values are more
51
+ # conservative.
52
+ # Can be any value between 0.0 and 1.0 inclusive.
24
53
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25
- # @return [Lemur::LemurBaseParams]
26
- def initialize(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
27
- temperature: nil, additional_properties: nil)
28
- # @type [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100 hours, whichever is lower.
29
- # Use either transcript_ids or input_text as input into LeMUR.
30
- @transcript_ids = transcript_ids
31
- # @type [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
32
- # Use either transcript_ids or input_text as input into LeMUR.
33
- @input_text = input_text
34
- # @type [Lemur::LemurBaseParamsContext] Context to provide the model. This can be a string or a free-form JSON value.
35
- @context = context
36
- # @type [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
37
- # Defaults to "default".
38
- @final_model = final_model
39
- # @type [Integer] Max output size in tokens, up to 4000
40
- @max_output_size = max_output_size
41
- # @type [Float] The temperature to use for the model.
42
- # Higher values result in answers that are more creative, lower values are more conservative.
43
- # Can be any value between 0.0 and 1.0 inclusive.
44
- @temperature = temperature
45
- # @type [OpenStruct] Additional properties unmapped to the current class definition
54
+ # @return [AssemblyAI::Lemur::LemurBaseParams]
55
+ def initialize(transcript_ids: OMIT, input_text: OMIT, context: OMIT, final_model: OMIT, max_output_size: OMIT,
56
+ temperature: OMIT, additional_properties: nil)
57
+ @transcript_ids = transcript_ids if transcript_ids != OMIT
58
+ @input_text = input_text if input_text != OMIT
59
+ @context = context if context != OMIT
60
+ @final_model = final_model if final_model != OMIT
61
+ @max_output_size = max_output_size if max_output_size != OMIT
62
+ @temperature = temperature if temperature != OMIT
46
63
  @additional_properties = additional_properties
64
+ @_field_set = {
65
+ "transcript_ids": transcript_ids,
66
+ "input_text": input_text,
67
+ "context": context,
68
+ "final_model": final_model,
69
+ "max_output_size": max_output_size,
70
+ "temperature": temperature
71
+ }.reject do |_k, v|
72
+ v == OMIT
73
+ end
47
74
  end
48
75
 
49
76
  # Deserialize a JSON object to an instance of LemurBaseParams
50
77
  #
51
- # @param json_object [JSON]
52
- # @return [Lemur::LemurBaseParams]
78
+ # @param json_object [String]
79
+ # @return [AssemblyAI::Lemur::LemurBaseParams]
53
80
  def self.from_json(json_object:)
54
81
  struct = JSON.parse(json_object, object_class: OpenStruct)
55
- parsed_json = JSON.parse(json_object)
56
- transcript_ids = struct.transcript_ids
57
- input_text = struct.input_text
82
+ transcript_ids = struct["transcript_ids"]
83
+ input_text = struct["input_text"]
58
84
  if parsed_json["context"].nil?
59
85
  context = nil
60
86
  else
61
87
  context = parsed_json["context"].to_json
62
- context = Lemur::LemurBaseParamsContext.from_json(json_object: context)
88
+ context = AssemblyAI::Lemur::LemurBaseParamsContext.from_json(json_object: context)
63
89
  end
64
- final_model = struct.final_model
65
- max_output_size = struct.max_output_size
66
- temperature = struct.temperature
67
- new(transcript_ids: transcript_ids, input_text: input_text, context: context, final_model: final_model,
68
- max_output_size: max_output_size, temperature: temperature, additional_properties: struct)
90
+ final_model = struct["final_model"]
91
+ max_output_size = struct["max_output_size"]
92
+ temperature = struct["temperature"]
93
+ new(
94
+ transcript_ids: transcript_ids,
95
+ input_text: input_text,
96
+ context: context,
97
+ final_model: final_model,
98
+ max_output_size: max_output_size,
99
+ temperature: temperature,
100
+ additional_properties: struct
101
+ )
69
102
  end
70
103
 
71
104
  # Serialize an instance of LemurBaseParams to a JSON object
72
105
  #
73
- # @return [JSON]
106
+ # @return [String]
74
107
  def to_json(*_args)
75
- {
76
- "transcript_ids": @transcript_ids,
77
- "input_text": @input_text,
78
- "context": @context,
79
- "final_model": @final_model,
80
- "max_output_size": @max_output_size,
81
- "temperature": @temperature
82
- }.to_json
108
+ @_field_set&.to_json
83
109
  end
84
110
 
85
- # 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.
111
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
112
+ # hash and check each fields type against the current object's property
113
+ # definitions.
86
114
  #
87
115
  # @param obj [Object]
88
116
  # @return [Void]
89
117
  def self.validate_raw(obj:)
90
118
  obj.transcript_ids&.is_a?(Array) != false || raise("Passed value for field obj.transcript_ids is not the expected type, validation failed.")
91
119
  obj.input_text&.is_a?(String) != false || raise("Passed value for field obj.input_text is not the expected type, validation failed.")
92
- obj.context.nil? || Lemur::LemurBaseParamsContext.validate_raw(obj: obj.context)
93
- obj.final_model&.is_a?(Lemur::LemurModel) != false || raise("Passed value for field obj.final_model is not the expected type, validation failed.")
120
+ obj.context.nil? || AssemblyAI::Lemur::LemurBaseParamsContext.validate_raw(obj: obj.context)
121
+ obj.final_model&.is_a?(AssemblyAI::Lemur::LemurModel) != false || raise("Passed value for field obj.final_model is not the expected type, validation failed.")
94
122
  obj.max_output_size&.is_a?(Integer) != false || raise("Passed value for field obj.max_output_size is not the expected type, validation failed.")
95
123
  obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.")
96
124
  end
@@ -8,26 +8,32 @@ module AssemblyAI
8
8
  class LemurBaseParamsContext
9
9
  # Deserialize a JSON object to an instance of LemurBaseParamsContext
10
10
  #
11
- # @param json_object [JSON]
12
- # @return [Lemur::LemurBaseParamsContext]
11
+ # @param json_object [String]
12
+ # @return [AssemblyAI::Lemur::LemurBaseParamsContext]
13
13
  def self.from_json(json_object:)
14
14
  struct = JSON.parse(json_object, object_class: OpenStruct)
15
15
  begin
16
16
  struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
17
- return json_object
17
+ return json_object unless json_object.nil?
18
+
19
+ return nil
18
20
  rescue StandardError
19
21
  # noop
20
22
  end
21
23
  begin
22
24
  struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.")
23
- return json_object
25
+ return json_object unless json_object.nil?
26
+
27
+ return nil
24
28
  rescue StandardError
25
29
  # noop
26
30
  end
27
31
  struct
28
32
  end
29
33
 
30
- # 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.
34
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
35
+ # hash and check each fields type against the current object's property
36
+ # definitions.
31
37
  #
32
38
  # @param obj [Object]
33
39
  # @return [Void]
@@ -1,41 +1,50 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Lemur
7
8
  class LemurBaseResponse
8
- attr_reader :request_id, :additional_properties
9
+ # @return [String] The ID of the LeMUR request
10
+ attr_reader :request_id
11
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
12
+ attr_reader :additional_properties
13
+ # @return [Object]
14
+ attr_reader :_field_set
15
+ protected :_field_set
16
+
17
+ OMIT = Object.new
9
18
 
10
19
  # @param request_id [String] The ID of the LeMUR request
11
20
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
- # @return [Lemur::LemurBaseResponse]
21
+ # @return [AssemblyAI::Lemur::LemurBaseResponse]
13
22
  def initialize(request_id:, additional_properties: nil)
14
- # @type [String] The ID of the LeMUR request
15
23
  @request_id = request_id
16
- # @type [OpenStruct] Additional properties unmapped to the current class definition
17
24
  @additional_properties = additional_properties
25
+ @_field_set = { "request_id": request_id }
18
26
  end
19
27
 
20
28
  # Deserialize a JSON object to an instance of LemurBaseResponse
21
29
  #
22
- # @param json_object [JSON]
23
- # @return [Lemur::LemurBaseResponse]
30
+ # @param json_object [String]
31
+ # @return [AssemblyAI::Lemur::LemurBaseResponse]
24
32
  def self.from_json(json_object:)
25
33
  struct = JSON.parse(json_object, object_class: OpenStruct)
26
- JSON.parse(json_object)
27
- request_id = struct.request_id
34
+ request_id = struct["request_id"]
28
35
  new(request_id: request_id, additional_properties: struct)
29
36
  end
30
37
 
31
38
  # Serialize an instance of LemurBaseResponse to a JSON object
32
39
  #
33
- # @return [JSON]
40
+ # @return [String]
34
41
  def to_json(*_args)
35
- { "request_id": @request_id }.to_json
42
+ @_field_set&.to_json
36
43
  end
37
44
 
38
- # 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.
45
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
46
+ # hash and check each fields type against the current object's property
47
+ # definitions.
39
48
  #
40
49
  # @param obj [Object]
41
50
  # @return [Void]
@@ -1,71 +1,96 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "lemur_question_context"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Lemur
8
9
  class LemurQuestion
9
- attr_reader :question, :context, :answer_format, :answer_options, :additional_properties
10
+ # @return [String] The question you wish to ask. For more complex questions use default model.
11
+ attr_reader :question
12
+ # @return [AssemblyAI::Lemur::LemurQuestionContext] Any context about the transcripts you wish to provide. This can be a string or
13
+ # any object.
14
+ attr_reader :context
15
+ # @return [String] How you want the answer to be returned. This can be any text. Can't be used with
16
+ # answer_options. Examples: "short sentence", "bullet points"
17
+ attr_reader :answer_format
18
+ # @return [Array<String>] What discrete options to return. Useful for precise responses. Can't be used
19
+ # with answer_format. Example: ["Yes", "No"]
20
+ attr_reader :answer_options
21
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
22
+ attr_reader :additional_properties
23
+ # @return [Object]
24
+ attr_reader :_field_set
25
+ protected :_field_set
26
+
27
+ OMIT = Object.new
10
28
 
11
29
  # @param question [String] The question you wish to ask. For more complex questions use default model.
12
- # @param context [Lemur::LemurQuestionContext] Any context about the transcripts you wish to provide. This can be a string or any object.
13
- # @param answer_format [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"
14
- # @param answer_options [Array<String>] What discrete options to return. Useful for precise responses. Can't be used with answer_format. Example: ["Yes", "No"]
30
+ # @param context [AssemblyAI::Lemur::LemurQuestionContext] Any context about the transcripts you wish to provide. This can be a string or
31
+ # any object.
32
+ # @param answer_format [String] How you want the answer to be returned. This can be any text. Can't be used with
33
+ # answer_options. Examples: "short sentence", "bullet points"
34
+ # @param answer_options [Array<String>] What discrete options to return. Useful for precise responses. Can't be used
35
+ # with answer_format. Example: ["Yes", "No"]
15
36
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Lemur::LemurQuestion]
17
- def initialize(question:, context: nil, answer_format: nil, answer_options: nil, additional_properties: nil)
18
- # @type [String] The question you wish to ask. For more complex questions use default model.
37
+ # @return [AssemblyAI::Lemur::LemurQuestion]
38
+ def initialize(question:, context: OMIT, answer_format: OMIT, answer_options: OMIT, additional_properties: nil)
19
39
  @question = question
20
- # @type [Lemur::LemurQuestionContext] Any context about the transcripts you wish to provide. This can be a string or any object.
21
- @context = context
22
- # @type [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"
23
- @answer_format = answer_format
24
- # @type [Array<String>] What discrete options to return. Useful for precise responses. Can't be used with answer_format. Example: ["Yes", "No"]
25
- @answer_options = answer_options
26
- # @type [OpenStruct] Additional properties unmapped to the current class definition
40
+ @context = context if context != OMIT
41
+ @answer_format = answer_format if answer_format != OMIT
42
+ @answer_options = answer_options if answer_options != OMIT
27
43
  @additional_properties = additional_properties
44
+ @_field_set = {
45
+ "question": question,
46
+ "context": context,
47
+ "answer_format": answer_format,
48
+ "answer_options": answer_options
49
+ }.reject do |_k, v|
50
+ v == OMIT
51
+ end
28
52
  end
29
53
 
30
54
  # Deserialize a JSON object to an instance of LemurQuestion
31
55
  #
32
- # @param json_object [JSON]
33
- # @return [Lemur::LemurQuestion]
56
+ # @param json_object [String]
57
+ # @return [AssemblyAI::Lemur::LemurQuestion]
34
58
  def self.from_json(json_object:)
35
59
  struct = JSON.parse(json_object, object_class: OpenStruct)
36
- parsed_json = JSON.parse(json_object)
37
- question = struct.question
60
+ question = struct["question"]
38
61
  if parsed_json["context"].nil?
39
62
  context = nil
40
63
  else
41
64
  context = parsed_json["context"].to_json
42
- context = Lemur::LemurQuestionContext.from_json(json_object: context)
65
+ context = AssemblyAI::Lemur::LemurQuestionContext.from_json(json_object: context)
43
66
  end
44
- answer_format = struct.answer_format
45
- answer_options = struct.answer_options
46
- new(question: question, context: context, answer_format: answer_format, answer_options: answer_options,
47
- additional_properties: struct)
67
+ answer_format = struct["answer_format"]
68
+ answer_options = struct["answer_options"]
69
+ new(
70
+ question: question,
71
+ context: context,
72
+ answer_format: answer_format,
73
+ answer_options: answer_options,
74
+ additional_properties: struct
75
+ )
48
76
  end
49
77
 
50
78
  # Serialize an instance of LemurQuestion to a JSON object
51
79
  #
52
- # @return [JSON]
80
+ # @return [String]
53
81
  def to_json(*_args)
54
- {
55
- "question": @question,
56
- "context": @context,
57
- "answer_format": @answer_format,
58
- "answer_options": @answer_options
59
- }.to_json
82
+ @_field_set&.to_json
60
83
  end
61
84
 
62
- # 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.
85
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
86
+ # hash and check each fields type against the current object's property
87
+ # definitions.
63
88
  #
64
89
  # @param obj [Object]
65
90
  # @return [Void]
66
91
  def self.validate_raw(obj:)
67
92
  obj.question.is_a?(String) != false || raise("Passed value for field obj.question is not the expected type, validation failed.")
68
- obj.context.nil? || Lemur::LemurQuestionContext.validate_raw(obj: obj.context)
93
+ obj.context.nil? || AssemblyAI::Lemur::LemurQuestionContext.validate_raw(obj: obj.context)
69
94
  obj.answer_format&.is_a?(String) != false || raise("Passed value for field obj.answer_format is not the expected type, validation failed.")
70
95
  obj.answer_options&.is_a?(Array) != false || raise("Passed value for field obj.answer_options is not the expected type, validation failed.")
71
96
  end
@@ -1,46 +1,60 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Lemur
7
8
  # An answer generated by LeMUR and its question
8
9
  class LemurQuestionAnswer
9
- attr_reader :question, :answer, :additional_properties
10
+ # @return [String] The question for LeMUR to answer
11
+ attr_reader :question
12
+ # @return [String] The answer generated by LeMUR
13
+ attr_reader :answer
14
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
15
+ attr_reader :additional_properties
16
+ # @return [Object]
17
+ attr_reader :_field_set
18
+ protected :_field_set
19
+
20
+ OMIT = Object.new
10
21
 
11
22
  # @param question [String] The question for LeMUR to answer
12
23
  # @param answer [String] The answer generated by LeMUR
13
24
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
- # @return [Lemur::LemurQuestionAnswer]
25
+ # @return [AssemblyAI::Lemur::LemurQuestionAnswer]
15
26
  def initialize(question:, answer:, additional_properties: nil)
16
- # @type [String] The question for LeMUR to answer
17
27
  @question = question
18
- # @type [String] The answer generated by LeMUR
19
28
  @answer = answer
20
- # @type [OpenStruct] Additional properties unmapped to the current class definition
21
29
  @additional_properties = additional_properties
30
+ @_field_set = { "question": question, "answer": answer }
22
31
  end
23
32
 
24
33
  # Deserialize a JSON object to an instance of LemurQuestionAnswer
25
34
  #
26
- # @param json_object [JSON]
27
- # @return [Lemur::LemurQuestionAnswer]
35
+ # @param json_object [String]
36
+ # @return [AssemblyAI::Lemur::LemurQuestionAnswer]
28
37
  def self.from_json(json_object:)
29
38
  struct = JSON.parse(json_object, object_class: OpenStruct)
30
- JSON.parse(json_object)
31
- question = struct.question
32
- answer = struct.answer
33
- new(question: question, answer: answer, additional_properties: struct)
39
+ question = struct["question"]
40
+ answer = struct["answer"]
41
+ new(
42
+ question: question,
43
+ answer: answer,
44
+ additional_properties: struct
45
+ )
34
46
  end
35
47
 
36
48
  # Serialize an instance of LemurQuestionAnswer to a JSON object
37
49
  #
38
- # @return [JSON]
50
+ # @return [String]
39
51
  def to_json(*_args)
40
- { "question": @question, "answer": @answer }.to_json
52
+ @_field_set&.to_json
41
53
  end
42
54
 
43
- # 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.
55
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
56
+ # hash and check each fields type against the current object's property
57
+ # definitions.
44
58
  #
45
59
  # @param obj [Object]
46
60
  # @return [Void]
@@ -1,49 +1,63 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "lemur_question_answer"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Lemur
8
9
  class LemurQuestionAnswerResponse
9
- attr_reader :response, :request_id, :additional_properties
10
+ # @return [Array<AssemblyAI::Lemur::LemurQuestionAnswer>] The answers generated by LeMUR and their questions
11
+ attr_reader :response
12
+ # @return [String] The ID of the LeMUR request
13
+ attr_reader :request_id
14
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
15
+ attr_reader :additional_properties
16
+ # @return [Object]
17
+ attr_reader :_field_set
18
+ protected :_field_set
10
19
 
11
- # @param response [Array<Lemur::LemurQuestionAnswer>] The answers generated by LeMUR and their questions
20
+ OMIT = Object.new
21
+
22
+ # @param response [Array<AssemblyAI::Lemur::LemurQuestionAnswer>] The answers generated by LeMUR and their questions
12
23
  # @param request_id [String] The ID of the LeMUR request
13
24
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
- # @return [Lemur::LemurQuestionAnswerResponse]
25
+ # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
15
26
  def initialize(response:, request_id:, additional_properties: nil)
16
- # @type [Array<Lemur::LemurQuestionAnswer>] The answers generated by LeMUR and their questions
17
27
  @response = response
18
- # @type [String] The ID of the LeMUR request
19
28
  @request_id = request_id
20
- # @type [OpenStruct] Additional properties unmapped to the current class definition
21
29
  @additional_properties = additional_properties
30
+ @_field_set = { "response": response, "request_id": request_id }
22
31
  end
23
32
 
24
33
  # Deserialize a JSON object to an instance of LemurQuestionAnswerResponse
25
34
  #
26
- # @param json_object [JSON]
27
- # @return [Lemur::LemurQuestionAnswerResponse]
35
+ # @param json_object [String]
36
+ # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
28
37
  def self.from_json(json_object:)
29
38
  struct = JSON.parse(json_object, object_class: OpenStruct)
30
- parsed_json = JSON.parse(json_object)
31
39
  response = parsed_json["response"]&.map do |v|
32
40
  v = v.to_json
33
- Lemur::LemurQuestionAnswer.from_json(json_object: v)
41
+ AssemblyAI::Lemur::LemurQuestionAnswer.from_json(json_object: v)
34
42
  end
35
- request_id = struct.request_id
36
- new(response: response, request_id: request_id, additional_properties: struct)
43
+ request_id = struct["request_id"]
44
+ new(
45
+ response: response,
46
+ request_id: request_id,
47
+ additional_properties: struct
48
+ )
37
49
  end
38
50
 
39
51
  # Serialize an instance of LemurQuestionAnswerResponse to a JSON object
40
52
  #
41
- # @return [JSON]
53
+ # @return [String]
42
54
  def to_json(*_args)
43
- { "response": @response, "request_id": @request_id }.to_json
55
+ @_field_set&.to_json
44
56
  end
45
57
 
46
- # 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.
58
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
59
+ # hash and check each fields type against the current object's property
60
+ # definitions.
47
61
  #
48
62
  # @param obj [Object]
49
63
  # @return [Void]