assemblyai 1.0.0.pre.beta.7 → 1.0.0.pre.beta.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) 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 +256 -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 -54
  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 -31
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -14
  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 +72 -41
  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 +62 -34
  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 +31 -14
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +20 -11
  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/page_details.rb +59 -33
  47. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  48. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  49. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  50. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  51. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +62 -35
  52. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  53. data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
  54. data/lib/assemblyai/transcripts/types/substitution_policy.rb +3 -1
  55. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  56. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -19
  57. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  58. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  59. data/lib/assemblyai/transcripts/types/transcript.rb +512 -293
  60. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  61. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +3 -2
  62. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -17
  63. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +60 -34
  64. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +334 -191
  65. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -33
  66. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  67. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -33
  68. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  69. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -31
  70. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  71. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  72. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  73. data/lib/assemblyai/types/error.rb +32 -16
  74. data/lib/requests.rb +80 -34
  75. data/lib/types_export.rb +4 -3
  76. metadata +6 -5
  77. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  78. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
@@ -13,35 +13,45 @@ require "async"
13
13
 
14
14
  module AssemblyAI
15
15
  class LemurClient
16
+ # @return [AssemblyAI::RequestClient]
16
17
  attr_reader :request_client
17
18
 
18
- # @param request_client [RequestClient]
19
- # @return [LemurClient]
19
+ # @param request_client [AssemblyAI::RequestClient]
20
+ # @return [AssemblyAI::LemurClient]
20
21
  def initialize(request_client:)
21
- # @type [RequestClient]
22
22
  @request_client = request_client
23
23
  end
24
24
 
25
25
  # Use the LeMUR task endpoint to input your own LLM prompt.
26
26
  #
27
- # @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.
28
- # Use either transcript_ids or input_text as input into LeMUR.
29
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
30
- # Use either transcript_ids or input_text as input into LeMUR.
27
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
28
+ # hours, whichever is lower.
29
+ # Use either transcript_ids or input_text as input into LeMUR.
30
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
31
+ # selected model, which defaults to 100000.
32
+ # Use either transcript_ids or input_text as input into LeMUR.
31
33
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
32
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
33
- # Defaults to "default".
34
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
35
+ # Defaults to "default".
34
36
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
35
37
  # @param temperature [Float] The temperature to use for the model.
36
- # Higher values result in answers that are more creative, lower values are more conservative.
37
- # Can be any value between 0.0 and 1.0 inclusive.
38
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
39
- # @param prompt [String] Your text to prompt the model to produce a desired output, including any context you want to pass into the model.
40
- # @param request_options [RequestOptions]
41
- # @return [Lemur::LemurTaskResponse]
38
+ # Higher values result in answers that are more creative, lower values are more
39
+ # conservative.
40
+ # Can be any value between 0.0 and 1.0 inclusive.
41
+ # @param prompt [String] Your text to prompt the model to produce a desired output, including any context
42
+ # you want to pass into the model.
43
+ # @param request_options [AssemblyAI::RequestOptions]
44
+ # @return [AssemblyAI::Lemur::LemurTaskResponse]
45
+ # @example
46
+ # api = AssemblyAI::Client.new(
47
+ # environment: Environment::DEFAULT,
48
+ # base_url: "https://api.example.com",
49
+ # api_key: "YOUR_API_KEY"
50
+ # )
51
+ # api.task(prompt: "List all the locations affected by wildfires.")
42
52
  def task(prompt:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
43
- temperature: nil, additional_properties: nil, request_options: nil)
44
- response = @request_client.conn.post("/lemur/v3/generate/task") do |req|
53
+ temperature: nil, request_options: nil)
54
+ response = @request_client.conn.post do |req|
45
55
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
46
56
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
47
57
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -53,33 +63,45 @@ module AssemblyAI
53
63
  final_model: final_model,
54
64
  max_output_size: max_output_size,
55
65
  temperature: temperature,
56
- additional_properties: additional_properties,
57
66
  prompt: prompt
58
67
  }.compact
68
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/task"
59
69
  end
60
- Lemur::LemurTaskResponse.from_json(json_object: response.body)
70
+ AssemblyAI::Lemur::LemurTaskResponse.from_json(json_object: response.body)
61
71
  end
62
72
 
63
- # Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
73
+ # Custom Summary allows you to distill a piece of audio into a few impactful
74
+ # sentences. You can give the model context to obtain more targeted results while
75
+ # outputting the results in a variety of formats described in human language.
64
76
  #
65
- # @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.
66
- # Use either transcript_ids or input_text as input into LeMUR.
67
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
68
- # Use either transcript_ids or input_text as input into LeMUR.
77
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
78
+ # hours, whichever is lower.
79
+ # Use either transcript_ids or input_text as input into LeMUR.
80
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
81
+ # selected model, which defaults to 100000.
82
+ # Use either transcript_ids or input_text as input into LeMUR.
69
83
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
70
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
71
- # Defaults to "default".
84
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
85
+ # Defaults to "default".
72
86
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
73
87
  # @param temperature [Float] The temperature to use for the model.
74
- # Higher values result in answers that are more creative, lower values are more conservative.
75
- # Can be any value between 0.0 and 1.0 inclusive.
76
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
77
- # @param answer_format [String] How you want the summary to be returned. This can be any text. Examples: "TLDR", "bullet points"
78
- # @param request_options [RequestOptions]
79
- # @return [Lemur::LemurSummaryResponse]
88
+ # Higher values result in answers that are more creative, lower values are more
89
+ # conservative.
90
+ # Can be any value between 0.0 and 1.0 inclusive.
91
+ # @param answer_format [String] How you want the summary to be returned. This can be any text. Examples: "TLDR",
92
+ # "bullet points"
93
+ # @param request_options [AssemblyAI::RequestOptions]
94
+ # @return [AssemblyAI::Lemur::LemurSummaryResponse]
95
+ # @example
96
+ # api = AssemblyAI::Client.new(
97
+ # environment: Environment::DEFAULT,
98
+ # base_url: "https://api.example.com",
99
+ # api_key: "YOUR_API_KEY"
100
+ # )
101
+ # api.summary
80
102
  def summary(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
81
- temperature: nil, additional_properties: nil, answer_format: nil, request_options: nil)
82
- response = @request_client.conn.post("/lemur/v3/generate/summary") do |req|
103
+ temperature: nil, answer_format: nil, request_options: nil)
104
+ response = @request_client.conn.post do |req|
83
105
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
84
106
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
85
107
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -91,37 +113,49 @@ module AssemblyAI
91
113
  final_model: final_model,
92
114
  max_output_size: max_output_size,
93
115
  temperature: temperature,
94
- additional_properties: additional_properties,
95
116
  answer_format: answer_format
96
117
  }.compact
118
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/summary"
97
119
  end
98
- Lemur::LemurSummaryResponse.from_json(json_object: response.body)
120
+ AssemblyAI::Lemur::LemurSummaryResponse.from_json(json_object: response.body)
99
121
  end
100
122
 
101
- # Question & Answer allows you to ask free-form questions about a single transcript or a group of transcripts. The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
123
+ # Question & Answer allows you to ask free-form questions about a single
124
+ # transcript or a group of transcripts. The questions can be any whose answers you
125
+ # find useful, such as judging whether a caller is likely to become a customer or
126
+ # whether all items on a meeting's agenda were covered.
102
127
  #
103
- # @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.
104
- # Use either transcript_ids or input_text as input into LeMUR.
105
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
106
- # Use either transcript_ids or input_text as input into LeMUR.
128
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
129
+ # hours, whichever is lower.
130
+ # Use either transcript_ids or input_text as input into LeMUR.
131
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
132
+ # selected model, which defaults to 100000.
133
+ # Use either transcript_ids or input_text as input into LeMUR.
107
134
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
108
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
109
- # Defaults to "default".
135
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
136
+ # Defaults to "default".
110
137
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
111
138
  # @param temperature [Float] The temperature to use for the model.
112
- # Higher values result in answers that are more creative, lower values are more conservative.
113
- # Can be any value between 0.0 and 1.0 inclusive.
114
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
115
- # @param questions [Array<Hash>] A list of questions to askRequest of type Array<Lemur::LemurQuestion>, as a Hash
139
+ # Higher values result in answers that are more creative, lower values are more
140
+ # conservative.
141
+ # Can be any value between 0.0 and 1.0 inclusive.
142
+ # @param questions [Array<Hash>] A list of questions to askRequest of type Array<AssemblyAI::Lemur::LemurQuestion>, as a Hash
116
143
  # * :question (String)
117
144
  # * :context (Hash)
118
145
  # * :answer_format (String)
119
146
  # * :answer_options (Array<String>)
120
- # @param request_options [RequestOptions]
121
- # @return [Lemur::LemurQuestionAnswerResponse]
147
+ # @param request_options [AssemblyAI::RequestOptions]
148
+ # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
149
+ # @example
150
+ # api = AssemblyAI::Client.new(
151
+ # environment: Environment::DEFAULT,
152
+ # base_url: "https://api.example.com",
153
+ # api_key: "YOUR_API_KEY"
154
+ # )
155
+ # api.question_answer(questions: [{ question: "Where are there wildfires?", answer_format: "List of countries in ISO 3166-1 alpha-2 format", answer_options: ["US", "CA"] }, { question: "Is global warming affecting wildfires?", answer_options: ["yes", "no"] }])
122
156
  def question_answer(questions:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
123
- temperature: nil, additional_properties: nil, request_options: nil)
124
- response = @request_client.conn.post("/lemur/v3/generate/question-answer") do |req|
157
+ temperature: nil, request_options: nil)
158
+ response = @request_client.conn.post do |req|
125
159
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
126
160
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
127
161
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -133,34 +167,43 @@ module AssemblyAI
133
167
  final_model: final_model,
134
168
  max_output_size: max_output_size,
135
169
  temperature: temperature,
136
- additional_properties: additional_properties,
137
170
  questions: questions
138
171
  }.compact
172
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/question-answer"
139
173
  end
140
- Lemur::LemurQuestionAnswerResponse.from_json(json_object: response.body)
174
+ AssemblyAI::Lemur::LemurQuestionAnswerResponse.from_json(json_object: response.body)
141
175
  end
142
176
 
143
177
  # Use LeMUR to generate a list of action items from a transcript
144
178
  #
145
- # @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.
146
- # Use either transcript_ids or input_text as input into LeMUR.
147
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
148
- # Use either transcript_ids or input_text as input into LeMUR.
179
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
180
+ # hours, whichever is lower.
181
+ # Use either transcript_ids or input_text as input into LeMUR.
182
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
183
+ # selected model, which defaults to 100000.
184
+ # Use either transcript_ids or input_text as input into LeMUR.
149
185
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
150
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
151
- # Defaults to "default".
186
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
187
+ # Defaults to "default".
152
188
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
153
189
  # @param temperature [Float] The temperature to use for the model.
154
- # Higher values result in answers that are more creative, lower values are more conservative.
155
- # Can be any value between 0.0 and 1.0 inclusive.
156
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
190
+ # Higher values result in answers that are more creative, lower values are more
191
+ # conservative.
192
+ # Can be any value between 0.0 and 1.0 inclusive.
157
193
  # @param answer_format [String] How you want the action items to be returned. This can be any text.
158
- # Defaults to "Bullet Points".
159
- # @param request_options [RequestOptions]
160
- # @return [Lemur::LemurActionItemsResponse]
194
+ # Defaults to "Bullet Points".
195
+ # @param request_options [AssemblyAI::RequestOptions]
196
+ # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
197
+ # @example
198
+ # api = AssemblyAI::Client.new(
199
+ # environment: Environment::DEFAULT,
200
+ # base_url: "https://api.example.com",
201
+ # api_key: "YOUR_API_KEY"
202
+ # )
203
+ # api.action_items(answer_format: "Bullet Points")
161
204
  def action_items(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
162
- temperature: nil, additional_properties: nil, answer_format: nil, request_options: nil)
163
- response = @request_client.conn.post("/lemur/v3/generate/action-items") do |req|
205
+ temperature: nil, answer_format: nil, request_options: nil)
206
+ response = @request_client.conn.post do |req|
164
207
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
165
208
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
166
209
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -172,60 +215,80 @@ module AssemblyAI
172
215
  final_model: final_model,
173
216
  max_output_size: max_output_size,
174
217
  temperature: temperature,
175
- additional_properties: additional_properties,
176
218
  answer_format: answer_format
177
219
  }.compact
220
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/action-items"
178
221
  end
179
- Lemur::LemurActionItemsResponse.from_json(json_object: response.body)
222
+ AssemblyAI::Lemur::LemurActionItemsResponse.from_json(json_object: response.body)
180
223
  end
181
224
 
182
225
  # Delete the data for a previously submitted LeMUR request.
183
- # The LLM response data, as well as any context provided in the original request will be removed.
226
+ # The LLM response data, as well as any context provided in the original request
227
+ # will be removed.
184
228
  #
185
- # @param request_id [String] The ID of the LeMUR request whose data you want to delete. This would be found in the response of the original request.
186
- # @param request_options [RequestOptions]
187
- # @return [Lemur::PurgeLemurRequestDataResponse]
229
+ # @param request_id [String] The ID of the LeMUR request whose data you want to delete. This would be found
230
+ # in the response of the original request.
231
+ # @param request_options [AssemblyAI::RequestOptions]
232
+ # @return [AssemblyAI::Lemur::PurgeLemurRequestDataResponse]
233
+ # @example
234
+ # api = AssemblyAI::Client.new(
235
+ # environment: Environment::DEFAULT,
236
+ # base_url: "https://api.example.com",
237
+ # api_key: "YOUR_API_KEY"
238
+ # )
239
+ # api.purge_request_data(request_id: "request_id")
188
240
  def purge_request_data(request_id:, request_options: nil)
189
- response = @request_client.conn.delete("/lemur/v3/#{request_id}") do |req|
241
+ response = @request_client.conn.delete do |req|
190
242
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
191
243
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
192
244
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
245
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/#{request_id}"
193
246
  end
194
- Lemur::PurgeLemurRequestDataResponse.from_json(json_object: response.body)
247
+ AssemblyAI::Lemur::PurgeLemurRequestDataResponse.from_json(json_object: response.body)
195
248
  end
196
249
  end
197
250
 
198
251
  class AsyncLemurClient
252
+ # @return [AssemblyAI::AsyncRequestClient]
199
253
  attr_reader :request_client
200
254
 
201
- # @param request_client [AsyncRequestClient]
202
- # @return [AsyncLemurClient]
255
+ # @param request_client [AssemblyAI::AsyncRequestClient]
256
+ # @return [AssemblyAI::AsyncLemurClient]
203
257
  def initialize(request_client:)
204
- # @type [AsyncRequestClient]
205
258
  @request_client = request_client
206
259
  end
207
260
 
208
261
  # Use the LeMUR task endpoint to input your own LLM prompt.
209
262
  #
210
- # @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.
211
- # Use either transcript_ids or input_text as input into LeMUR.
212
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
213
- # Use either transcript_ids or input_text as input into LeMUR.
263
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
264
+ # hours, whichever is lower.
265
+ # Use either transcript_ids or input_text as input into LeMUR.
266
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
267
+ # selected model, which defaults to 100000.
268
+ # Use either transcript_ids or input_text as input into LeMUR.
214
269
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
215
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
216
- # Defaults to "default".
270
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
271
+ # Defaults to "default".
217
272
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
218
273
  # @param temperature [Float] The temperature to use for the model.
219
- # Higher values result in answers that are more creative, lower values are more conservative.
220
- # Can be any value between 0.0 and 1.0 inclusive.
221
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
222
- # @param prompt [String] Your text to prompt the model to produce a desired output, including any context you want to pass into the model.
223
- # @param request_options [RequestOptions]
224
- # @return [Lemur::LemurTaskResponse]
274
+ # Higher values result in answers that are more creative, lower values are more
275
+ # conservative.
276
+ # Can be any value between 0.0 and 1.0 inclusive.
277
+ # @param prompt [String] Your text to prompt the model to produce a desired output, including any context
278
+ # you want to pass into the model.
279
+ # @param request_options [AssemblyAI::RequestOptions]
280
+ # @return [AssemblyAI::Lemur::LemurTaskResponse]
281
+ # @example
282
+ # api = AssemblyAI::Client.new(
283
+ # environment: Environment::DEFAULT,
284
+ # base_url: "https://api.example.com",
285
+ # api_key: "YOUR_API_KEY"
286
+ # )
287
+ # api.task(prompt: "List all the locations affected by wildfires.")
225
288
  def task(prompt:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
226
- temperature: nil, additional_properties: nil, request_options: nil)
289
+ temperature: nil, request_options: nil)
227
290
  Async do
228
- response = @request_client.conn.post("/lemur/v3/generate/task") do |req|
291
+ response = @request_client.conn.post do |req|
229
292
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
230
293
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
231
294
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -237,35 +300,47 @@ module AssemblyAI
237
300
  final_model: final_model,
238
301
  max_output_size: max_output_size,
239
302
  temperature: temperature,
240
- additional_properties: additional_properties,
241
303
  prompt: prompt
242
304
  }.compact
305
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/task"
243
306
  end
244
- Lemur::LemurTaskResponse.from_json(json_object: response.body)
307
+ AssemblyAI::Lemur::LemurTaskResponse.from_json(json_object: response.body)
245
308
  end
246
309
  end
247
310
 
248
- # Custom Summary allows you to distill a piece of audio into a few impactful sentences. You can give the model context to obtain more targeted results while outputting the results in a variety of formats described in human language.
311
+ # Custom Summary allows you to distill a piece of audio into a few impactful
312
+ # sentences. You can give the model context to obtain more targeted results while
313
+ # outputting the results in a variety of formats described in human language.
249
314
  #
250
- # @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.
251
- # Use either transcript_ids or input_text as input into LeMUR.
252
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
253
- # Use either transcript_ids or input_text as input into LeMUR.
315
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
316
+ # hours, whichever is lower.
317
+ # Use either transcript_ids or input_text as input into LeMUR.
318
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
319
+ # selected model, which defaults to 100000.
320
+ # Use either transcript_ids or input_text as input into LeMUR.
254
321
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
255
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
256
- # Defaults to "default".
322
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
323
+ # Defaults to "default".
257
324
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
258
325
  # @param temperature [Float] The temperature to use for the model.
259
- # Higher values result in answers that are more creative, lower values are more conservative.
260
- # Can be any value between 0.0 and 1.0 inclusive.
261
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
262
- # @param answer_format [String] How you want the summary to be returned. This can be any text. Examples: "TLDR", "bullet points"
263
- # @param request_options [RequestOptions]
264
- # @return [Lemur::LemurSummaryResponse]
326
+ # Higher values result in answers that are more creative, lower values are more
327
+ # conservative.
328
+ # Can be any value between 0.0 and 1.0 inclusive.
329
+ # @param answer_format [String] How you want the summary to be returned. This can be any text. Examples: "TLDR",
330
+ # "bullet points"
331
+ # @param request_options [AssemblyAI::RequestOptions]
332
+ # @return [AssemblyAI::Lemur::LemurSummaryResponse]
333
+ # @example
334
+ # api = AssemblyAI::Client.new(
335
+ # environment: Environment::DEFAULT,
336
+ # base_url: "https://api.example.com",
337
+ # api_key: "YOUR_API_KEY"
338
+ # )
339
+ # api.summary
265
340
  def summary(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
266
- temperature: nil, additional_properties: nil, answer_format: nil, request_options: nil)
341
+ temperature: nil, answer_format: nil, request_options: nil)
267
342
  Async do
268
- response = @request_client.conn.post("/lemur/v3/generate/summary") do |req|
343
+ response = @request_client.conn.post do |req|
269
344
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
270
345
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
271
346
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -277,39 +352,51 @@ module AssemblyAI
277
352
  final_model: final_model,
278
353
  max_output_size: max_output_size,
279
354
  temperature: temperature,
280
- additional_properties: additional_properties,
281
355
  answer_format: answer_format
282
356
  }.compact
357
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/summary"
283
358
  end
284
- Lemur::LemurSummaryResponse.from_json(json_object: response.body)
359
+ AssemblyAI::Lemur::LemurSummaryResponse.from_json(json_object: response.body)
285
360
  end
286
361
  end
287
362
 
288
- # Question & Answer allows you to ask free-form questions about a single transcript or a group of transcripts. The questions can be any whose answers you find useful, such as judging whether a caller is likely to become a customer or whether all items on a meeting's agenda were covered.
363
+ # Question & Answer allows you to ask free-form questions about a single
364
+ # transcript or a group of transcripts. The questions can be any whose answers you
365
+ # find useful, such as judging whether a caller is likely to become a customer or
366
+ # whether all items on a meeting's agenda were covered.
289
367
  #
290
- # @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.
291
- # Use either transcript_ids or input_text as input into LeMUR.
292
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
293
- # Use either transcript_ids or input_text as input into LeMUR.
368
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
369
+ # hours, whichever is lower.
370
+ # Use either transcript_ids or input_text as input into LeMUR.
371
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
372
+ # selected model, which defaults to 100000.
373
+ # Use either transcript_ids or input_text as input into LeMUR.
294
374
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
295
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
296
- # Defaults to "default".
375
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
376
+ # Defaults to "default".
297
377
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
298
378
  # @param temperature [Float] The temperature to use for the model.
299
- # Higher values result in answers that are more creative, lower values are more conservative.
300
- # Can be any value between 0.0 and 1.0 inclusive.
301
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
302
- # @param questions [Array<Hash>] A list of questions to askRequest of type Array<Lemur::LemurQuestion>, as a Hash
379
+ # Higher values result in answers that are more creative, lower values are more
380
+ # conservative.
381
+ # Can be any value between 0.0 and 1.0 inclusive.
382
+ # @param questions [Array<Hash>] A list of questions to askRequest of type Array<AssemblyAI::Lemur::LemurQuestion>, as a Hash
303
383
  # * :question (String)
304
384
  # * :context (Hash)
305
385
  # * :answer_format (String)
306
386
  # * :answer_options (Array<String>)
307
- # @param request_options [RequestOptions]
308
- # @return [Lemur::LemurQuestionAnswerResponse]
387
+ # @param request_options [AssemblyAI::RequestOptions]
388
+ # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
389
+ # @example
390
+ # api = AssemblyAI::Client.new(
391
+ # environment: Environment::DEFAULT,
392
+ # base_url: "https://api.example.com",
393
+ # api_key: "YOUR_API_KEY"
394
+ # )
395
+ # api.question_answer(questions: [{ question: "Where are there wildfires?", answer_format: "List of countries in ISO 3166-1 alpha-2 format", answer_options: ["US", "CA"] }, { question: "Is global warming affecting wildfires?", answer_options: ["yes", "no"] }])
309
396
  def question_answer(questions:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
310
- temperature: nil, additional_properties: nil, request_options: nil)
397
+ temperature: nil, request_options: nil)
311
398
  Async do
312
- response = @request_client.conn.post("/lemur/v3/generate/question-answer") do |req|
399
+ response = @request_client.conn.post do |req|
313
400
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
314
401
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
315
402
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -321,36 +408,45 @@ module AssemblyAI
321
408
  final_model: final_model,
322
409
  max_output_size: max_output_size,
323
410
  temperature: temperature,
324
- additional_properties: additional_properties,
325
411
  questions: questions
326
412
  }.compact
413
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/question-answer"
327
414
  end
328
- Lemur::LemurQuestionAnswerResponse.from_json(json_object: response.body)
415
+ AssemblyAI::Lemur::LemurQuestionAnswerResponse.from_json(json_object: response.body)
329
416
  end
330
417
  end
331
418
 
332
419
  # Use LeMUR to generate a list of action items from a transcript
333
420
  #
334
- # @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.
335
- # Use either transcript_ids or input_text as input into LeMUR.
336
- # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the selected model, which defaults to 100000.
337
- # Use either transcript_ids or input_text as input into LeMUR.
421
+ # @param transcript_ids [Array<String>] A list of completed transcripts with text. Up to a maximum of 100 files or 100
422
+ # hours, whichever is lower.
423
+ # Use either transcript_ids or input_text as input into LeMUR.
424
+ # @param input_text [String] Custom formatted transcript data. Maximum size is the context limit of the
425
+ # selected model, which defaults to 100000.
426
+ # Use either transcript_ids or input_text as input into LeMUR.
338
427
  # @param context [String, Hash{String => Object}] Context to provide the model. This can be a string or a free-form JSON value.
339
- # @param final_model [Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
340
- # Defaults to "default".
428
+ # @param final_model [AssemblyAI::Lemur::LemurModel] The model that is used for the final prompt after compression is performed.
429
+ # Defaults to "default".
341
430
  # @param max_output_size [Integer] Max output size in tokens, up to 4000
342
431
  # @param temperature [Float] The temperature to use for the model.
343
- # Higher values result in answers that are more creative, lower values are more conservative.
344
- # Can be any value between 0.0 and 1.0 inclusive.
345
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
432
+ # Higher values result in answers that are more creative, lower values are more
433
+ # conservative.
434
+ # Can be any value between 0.0 and 1.0 inclusive.
346
435
  # @param answer_format [String] How you want the action items to be returned. This can be any text.
347
- # Defaults to "Bullet Points".
348
- # @param request_options [RequestOptions]
349
- # @return [Lemur::LemurActionItemsResponse]
436
+ # Defaults to "Bullet Points".
437
+ # @param request_options [AssemblyAI::RequestOptions]
438
+ # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
439
+ # @example
440
+ # api = AssemblyAI::Client.new(
441
+ # environment: Environment::DEFAULT,
442
+ # base_url: "https://api.example.com",
443
+ # api_key: "YOUR_API_KEY"
444
+ # )
445
+ # api.action_items(answer_format: "Bullet Points")
350
446
  def action_items(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
351
- temperature: nil, additional_properties: nil, answer_format: nil, request_options: nil)
447
+ temperature: nil, answer_format: nil, request_options: nil)
352
448
  Async do
353
- response = @request_client.conn.post("/lemur/v3/generate/action-items") do |req|
449
+ response = @request_client.conn.post do |req|
354
450
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
355
451
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
356
452
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
@@ -362,28 +458,38 @@ module AssemblyAI
362
458
  final_model: final_model,
363
459
  max_output_size: max_output_size,
364
460
  temperature: temperature,
365
- additional_properties: additional_properties,
366
461
  answer_format: answer_format
367
462
  }.compact
463
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/generate/action-items"
368
464
  end
369
- Lemur::LemurActionItemsResponse.from_json(json_object: response.body)
465
+ AssemblyAI::Lemur::LemurActionItemsResponse.from_json(json_object: response.body)
370
466
  end
371
467
  end
372
468
 
373
469
  # Delete the data for a previously submitted LeMUR request.
374
- # The LLM response data, as well as any context provided in the original request will be removed.
470
+ # The LLM response data, as well as any context provided in the original request
471
+ # will be removed.
375
472
  #
376
- # @param request_id [String] The ID of the LeMUR request whose data you want to delete. This would be found in the response of the original request.
377
- # @param request_options [RequestOptions]
378
- # @return [Lemur::PurgeLemurRequestDataResponse]
473
+ # @param request_id [String] The ID of the LeMUR request whose data you want to delete. This would be found
474
+ # in the response of the original request.
475
+ # @param request_options [AssemblyAI::RequestOptions]
476
+ # @return [AssemblyAI::Lemur::PurgeLemurRequestDataResponse]
477
+ # @example
478
+ # api = AssemblyAI::Client.new(
479
+ # environment: Environment::DEFAULT,
480
+ # base_url: "https://api.example.com",
481
+ # api_key: "YOUR_API_KEY"
482
+ # )
483
+ # api.purge_request_data(request_id: "request_id")
379
484
  def purge_request_data(request_id:, request_options: nil)
380
485
  Async do
381
- response = @request_client.conn.delete("/lemur/v3/#{request_id}") do |req|
486
+ response = @request_client.conn.delete do |req|
382
487
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
383
488
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
384
489
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
490
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/#{request_id}"
385
491
  end
386
- Lemur::PurgeLemurRequestDataResponse.from_json(json_object: response.body)
492
+ AssemblyAI::Lemur::PurgeLemurRequestDataResponse.from_json(json_object: response.body)
387
493
  end
388
494
  end
389
495
  end