assemblyai 1.0.0.pre.beta.9 → 1.0.0.pre.beta.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8966cf8fd4bf25ddc706a276125abd055e0d959ab9a9e08a244cf62e673f5117
4
- data.tar.gz: 49482eed13d7dbdd01846510dcfad1e9c22a910a79bf96f50c01932bb858a821
3
+ metadata.gz: 157742ad6decb8b828c23cf549a4e700d4cb0b2fdd9435bef9ca5e44424fdbda
4
+ data.tar.gz: a97d6acfec405cb63d78c6388602ede6ff6c885053feb054f82044ea17658a92
5
5
  SHA512:
6
- metadata.gz: 01705c2608ea28815a847e01bffb4f7224e050e6b61dd3692b1f44d16eeabf2e6561e93356331709b32a2702c3c1c3a75864a1659a75d48a354739d832f0853f
7
- data.tar.gz: 2789963c8e6e1f1b39013d0c398eaad39b8bd05dd13af4b80389bddf1337101465804360e6585ca29ab44ded1a9580bed610e3fcc8405537414a2557b12bf819
6
+ metadata.gz: 3136c68cf8ebeefb44cde0e3e55f968726bbf1d748a414d727ea6e0d73f244ac6a51f4edd688d4343ba857d2db28475fdcd4786f911ab2ce854d9206a3945b8a
7
+ data.tar.gz: 8f28783285bea24b5bd283f4385d748d81b0187276f6fedb4923df3be63493191391a99adcc478fd15d9b551186ca054a7822f76d16eae690292420c78d23339
@@ -8,6 +8,7 @@ require_relative "types/lemur_summary_response"
8
8
  require_relative "types/lemur_question"
9
9
  require_relative "types/lemur_question_answer_response"
10
10
  require_relative "types/lemur_action_items_response"
11
+ require_relative "types/lemur_response"
11
12
  require_relative "types/purge_lemur_request_data_response"
12
13
  require "async"
13
14
 
@@ -44,11 +45,11 @@ module AssemblyAI
44
45
  # @return [AssemblyAI::Lemur::LemurTaskResponse]
45
46
  # @example
46
47
  # api = AssemblyAI::Client.new(
47
- # environment: Environment::DEFAULT,
48
+ # environment: AssemblyAI::Environment::DEFAULT,
48
49
  # base_url: "https://api.example.com",
49
50
  # api_key: "YOUR_API_KEY"
50
51
  # )
51
- # api.task(prompt: "List all the locations affected by wildfires.")
52
+ # api.lemur.task(prompt: "List all the locations affected by wildfires.")
52
53
  def task(prompt:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
53
54
  temperature: nil, request_options: nil)
54
55
  response = @request_client.conn.post do |req|
@@ -95,11 +96,11 @@ module AssemblyAI
95
96
  # @return [AssemblyAI::Lemur::LemurSummaryResponse]
96
97
  # @example
97
98
  # api = AssemblyAI::Client.new(
98
- # environment: Environment::DEFAULT,
99
+ # environment: AssemblyAI::Environment::DEFAULT,
99
100
  # base_url: "https://api.example.com",
100
101
  # api_key: "YOUR_API_KEY"
101
102
  # )
102
- # api.summary
103
+ # api.lemur.summary
103
104
  def summary(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
104
105
  temperature: nil, answer_format: nil, request_options: nil)
105
106
  response = @request_client.conn.post do |req|
@@ -150,11 +151,11 @@ module AssemblyAI
150
151
  # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
151
152
  # @example
152
153
  # api = AssemblyAI::Client.new(
153
- # environment: Environment::DEFAULT,
154
+ # environment: AssemblyAI::Environment::DEFAULT,
154
155
  # base_url: "https://api.example.com",
155
156
  # api_key: "YOUR_API_KEY"
156
157
  # )
157
- # 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"] }])
158
+ # api.lemur.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"] }])
158
159
  def question_answer(questions:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
159
160
  temperature: nil, request_options: nil)
160
161
  response = @request_client.conn.post do |req|
@@ -198,11 +199,11 @@ module AssemblyAI
198
199
  # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
199
200
  # @example
200
201
  # api = AssemblyAI::Client.new(
201
- # environment: Environment::DEFAULT,
202
+ # environment: AssemblyAI::Environment::DEFAULT,
202
203
  # base_url: "https://api.example.com",
203
204
  # api_key: "YOUR_API_KEY"
204
205
  # )
205
- # api.action_items(answer_format: "Bullet Points")
206
+ # api.lemur.action_items(answer_format: "Bullet Points")
206
207
  def action_items(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
207
208
  temperature: nil, answer_format: nil, request_options: nil)
208
209
  response = @request_client.conn.post do |req|
@@ -224,6 +225,29 @@ module AssemblyAI
224
225
  AssemblyAI::Lemur::LemurActionItemsResponse.from_json(json_object: response.body)
225
226
  end
226
227
 
228
+ # Retrieve a LeMUR response that was previously generated.
229
+ #
230
+ # @param request_id [String] The ID of the LeMUR request you previously made.
231
+ # This would be found in the response of the original request.
232
+ # @param request_options [AssemblyAI::RequestOptions]
233
+ # @return [AssemblyAI::Lemur::LemurTaskResponse, AssemblyAI::Lemur::LemurSummaryResponse, AssemblyAI::Lemur::LemurQuestionAnswerResponse, AssemblyAI::Lemur::LemurActionItemsResponse]
234
+ # @example
235
+ # api = AssemblyAI::Client.new(
236
+ # environment: AssemblyAI::Environment::DEFAULT,
237
+ # base_url: "https://api.example.com",
238
+ # api_key: "YOUR_API_KEY"
239
+ # )
240
+ # api.lemur.get_response(request_id: "request_id")
241
+ def get_response(request_id:, request_options: nil)
242
+ response = @request_client.conn.get do |req|
243
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
244
+ req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
245
+ req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
246
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/#{request_id}"
247
+ end
248
+ AssemblyAI::Lemur::LemurResponse.from_json(json_object: response.body)
249
+ end
250
+
227
251
  # Delete the data for a previously submitted LeMUR request.
228
252
  # The LLM response data, as well as any context provided in the original request
229
253
  # will be removed.
@@ -234,11 +258,11 @@ module AssemblyAI
234
258
  # @return [AssemblyAI::Lemur::PurgeLemurRequestDataResponse]
235
259
  # @example
236
260
  # api = AssemblyAI::Client.new(
237
- # environment: Environment::DEFAULT,
261
+ # environment: AssemblyAI::Environment::DEFAULT,
238
262
  # base_url: "https://api.example.com",
239
263
  # api_key: "YOUR_API_KEY"
240
264
  # )
241
- # api.purge_request_data(request_id: "request_id")
265
+ # api.lemur.purge_request_data(request_id: "request_id")
242
266
  def purge_request_data(request_id:, request_options: nil)
243
267
  response = @request_client.conn.delete do |req|
244
268
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -282,11 +306,11 @@ module AssemblyAI
282
306
  # @return [AssemblyAI::Lemur::LemurTaskResponse]
283
307
  # @example
284
308
  # api = AssemblyAI::Client.new(
285
- # environment: Environment::DEFAULT,
309
+ # environment: AssemblyAI::Environment::DEFAULT,
286
310
  # base_url: "https://api.example.com",
287
311
  # api_key: "YOUR_API_KEY"
288
312
  # )
289
- # api.task(prompt: "List all the locations affected by wildfires.")
313
+ # api.lemur.task(prompt: "List all the locations affected by wildfires.")
290
314
  def task(prompt:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
291
315
  temperature: nil, request_options: nil)
292
316
  Async do
@@ -335,11 +359,11 @@ module AssemblyAI
335
359
  # @return [AssemblyAI::Lemur::LemurSummaryResponse]
336
360
  # @example
337
361
  # api = AssemblyAI::Client.new(
338
- # environment: Environment::DEFAULT,
362
+ # environment: AssemblyAI::Environment::DEFAULT,
339
363
  # base_url: "https://api.example.com",
340
364
  # api_key: "YOUR_API_KEY"
341
365
  # )
342
- # api.summary
366
+ # api.lemur.summary
343
367
  def summary(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
344
368
  temperature: nil, answer_format: nil, request_options: nil)
345
369
  Async do
@@ -392,11 +416,11 @@ module AssemblyAI
392
416
  # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
393
417
  # @example
394
418
  # api = AssemblyAI::Client.new(
395
- # environment: Environment::DEFAULT,
419
+ # environment: AssemblyAI::Environment::DEFAULT,
396
420
  # base_url: "https://api.example.com",
397
421
  # api_key: "YOUR_API_KEY"
398
422
  # )
399
- # 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"] }])
423
+ # api.lemur.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"] }])
400
424
  def question_answer(questions:, transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
401
425
  temperature: nil, request_options: nil)
402
426
  Async do
@@ -442,11 +466,11 @@ module AssemblyAI
442
466
  # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
443
467
  # @example
444
468
  # api = AssemblyAI::Client.new(
445
- # environment: Environment::DEFAULT,
469
+ # environment: AssemblyAI::Environment::DEFAULT,
446
470
  # base_url: "https://api.example.com",
447
471
  # api_key: "YOUR_API_KEY"
448
472
  # )
449
- # api.action_items(answer_format: "Bullet Points")
473
+ # api.lemur.action_items(answer_format: "Bullet Points")
450
474
  def action_items(transcript_ids: nil, input_text: nil, context: nil, final_model: nil, max_output_size: nil,
451
475
  temperature: nil, answer_format: nil, request_options: nil)
452
476
  Async do
@@ -470,6 +494,31 @@ module AssemblyAI
470
494
  end
471
495
  end
472
496
 
497
+ # Retrieve a LeMUR response that was previously generated.
498
+ #
499
+ # @param request_id [String] The ID of the LeMUR request you previously made.
500
+ # This would be found in the response of the original request.
501
+ # @param request_options [AssemblyAI::RequestOptions]
502
+ # @return [AssemblyAI::Lemur::LemurTaskResponse, AssemblyAI::Lemur::LemurSummaryResponse, AssemblyAI::Lemur::LemurQuestionAnswerResponse, AssemblyAI::Lemur::LemurActionItemsResponse]
503
+ # @example
504
+ # api = AssemblyAI::Client.new(
505
+ # environment: AssemblyAI::Environment::DEFAULT,
506
+ # base_url: "https://api.example.com",
507
+ # api_key: "YOUR_API_KEY"
508
+ # )
509
+ # api.lemur.get_response(request_id: "request_id")
510
+ def get_response(request_id:, request_options: nil)
511
+ Async do
512
+ response = @request_client.conn.get do |req|
513
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
514
+ req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
515
+ req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
516
+ req.url "#{@request_client.get_url(request_options: request_options)}/lemur/v3/#{request_id}"
517
+ end
518
+ AssemblyAI::Lemur::LemurResponse.from_json(json_object: response.body)
519
+ end
520
+ end
521
+
473
522
  # Delete the data for a previously submitted LeMUR request.
474
523
  # The LLM response data, as well as any context provided in the original request
475
524
  # will be removed.
@@ -480,11 +529,11 @@ module AssemblyAI
480
529
  # @return [AssemblyAI::Lemur::PurgeLemurRequestDataResponse]
481
530
  # @example
482
531
  # api = AssemblyAI::Client.new(
483
- # environment: Environment::DEFAULT,
532
+ # environment: AssemblyAI::Environment::DEFAULT,
484
533
  # base_url: "https://api.example.com",
485
534
  # api_key: "YOUR_API_KEY"
486
535
  # )
487
- # api.purge_request_data(request_id: "request_id")
536
+ # api.lemur.purge_request_data(request_id: "request_id")
488
537
  def purge_request_data(request_id:, request_options: nil)
489
538
  Async do
490
539
  response = @request_client.conn.delete do |req|
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "lemur_usage"
3
4
  require "ostruct"
4
5
  require "json"
5
6
 
@@ -10,6 +11,8 @@ module AssemblyAI
10
11
  attr_reader :response
11
12
  # @return [String] The ID of the LeMUR request
12
13
  attr_reader :request_id
14
+ # @return [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
15
+ attr_reader :usage
13
16
  # @return [OpenStruct] Additional properties unmapped to the current class definition
14
17
  attr_reader :additional_properties
15
18
  # @return [Object]
@@ -20,13 +23,15 @@ module AssemblyAI
20
23
 
21
24
  # @param response [String] The response generated by LeMUR
22
25
  # @param request_id [String] The ID of the LeMUR request
26
+ # @param usage [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
23
27
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
28
  # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
25
- def initialize(response:, request_id:, additional_properties: nil)
29
+ def initialize(response:, request_id:, usage:, additional_properties: nil)
26
30
  @response = response
27
31
  @request_id = request_id
32
+ @usage = usage
28
33
  @additional_properties = additional_properties
29
- @_field_set = { "response": response, "request_id": request_id }
34
+ @_field_set = { "response": response, "request_id": request_id, "usage": usage }
30
35
  end
31
36
 
32
37
  # Deserialize a JSON object to an instance of LemurActionItemsResponse
@@ -35,11 +40,19 @@ module AssemblyAI
35
40
  # @return [AssemblyAI::Lemur::LemurActionItemsResponse]
36
41
  def self.from_json(json_object:)
37
42
  struct = JSON.parse(json_object, object_class: OpenStruct)
43
+ parsed_json = JSON.parse(json_object)
38
44
  response = struct["response"]
39
45
  request_id = struct["request_id"]
46
+ if parsed_json["usage"].nil?
47
+ usage = nil
48
+ else
49
+ usage = parsed_json["usage"].to_json
50
+ usage = AssemblyAI::Lemur::LemurUsage.from_json(json_object: usage)
51
+ end
40
52
  new(
41
53
  response: response,
42
54
  request_id: request_id,
55
+ usage: usage,
43
56
  additional_properties: struct
44
57
  )
45
58
  end
@@ -60,6 +73,7 @@ module AssemblyAI
60
73
  def self.validate_raw(obj:)
61
74
  obj.response.is_a?(String) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
62
75
  obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
76
+ AssemblyAI::Lemur::LemurUsage.validate_raw(obj: obj.usage)
63
77
  end
64
78
  end
65
79
  end
@@ -79,6 +79,7 @@ module AssemblyAI
79
79
  # @return [AssemblyAI::Lemur::LemurBaseParams]
80
80
  def self.from_json(json_object:)
81
81
  struct = JSON.parse(json_object, object_class: OpenStruct)
82
+ parsed_json = JSON.parse(json_object)
82
83
  transcript_ids = struct["transcript_ids"]
83
84
  input_text = struct["input_text"]
84
85
  if parsed_json["context"].nil?
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "lemur_usage"
3
4
  require "ostruct"
4
5
  require "json"
5
6
 
@@ -8,6 +9,8 @@ module AssemblyAI
8
9
  class LemurBaseResponse
9
10
  # @return [String] The ID of the LeMUR request
10
11
  attr_reader :request_id
12
+ # @return [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
13
+ attr_reader :usage
11
14
  # @return [OpenStruct] Additional properties unmapped to the current class definition
12
15
  attr_reader :additional_properties
13
16
  # @return [Object]
@@ -17,12 +20,14 @@ module AssemblyAI
17
20
  OMIT = Object.new
18
21
 
19
22
  # @param request_id [String] The ID of the LeMUR request
23
+ # @param usage [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
20
24
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
21
25
  # @return [AssemblyAI::Lemur::LemurBaseResponse]
22
- def initialize(request_id:, additional_properties: nil)
26
+ def initialize(request_id:, usage:, additional_properties: nil)
23
27
  @request_id = request_id
28
+ @usage = usage
24
29
  @additional_properties = additional_properties
25
- @_field_set = { "request_id": request_id }
30
+ @_field_set = { "request_id": request_id, "usage": usage }
26
31
  end
27
32
 
28
33
  # Deserialize a JSON object to an instance of LemurBaseResponse
@@ -31,8 +36,19 @@ module AssemblyAI
31
36
  # @return [AssemblyAI::Lemur::LemurBaseResponse]
32
37
  def self.from_json(json_object:)
33
38
  struct = JSON.parse(json_object, object_class: OpenStruct)
39
+ parsed_json = JSON.parse(json_object)
34
40
  request_id = struct["request_id"]
35
- new(request_id: request_id, additional_properties: struct)
41
+ if parsed_json["usage"].nil?
42
+ usage = nil
43
+ else
44
+ usage = parsed_json["usage"].to_json
45
+ usage = AssemblyAI::Lemur::LemurUsage.from_json(json_object: usage)
46
+ end
47
+ new(
48
+ request_id: request_id,
49
+ usage: usage,
50
+ additional_properties: struct
51
+ )
36
52
  end
37
53
 
38
54
  # Serialize an instance of LemurBaseResponse to a JSON object
@@ -50,6 +66,7 @@ module AssemblyAI
50
66
  # @return [Void]
51
67
  def self.validate_raw(obj:)
52
68
  obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
69
+ AssemblyAI::Lemur::LemurUsage.validate_raw(obj: obj.usage)
53
70
  end
54
71
  end
55
72
  end
@@ -57,6 +57,7 @@ module AssemblyAI
57
57
  # @return [AssemblyAI::Lemur::LemurQuestion]
58
58
  def self.from_json(json_object:)
59
59
  struct = JSON.parse(json_object, object_class: OpenStruct)
60
+ parsed_json = JSON.parse(json_object)
60
61
  question = struct["question"]
61
62
  if parsed_json["context"].nil?
62
63
  context = nil
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "lemur_question_answer"
4
+ require_relative "lemur_usage"
4
5
  require "ostruct"
5
6
  require "json"
6
7
 
@@ -11,6 +12,8 @@ module AssemblyAI
11
12
  attr_reader :response
12
13
  # @return [String] The ID of the LeMUR request
13
14
  attr_reader :request_id
15
+ # @return [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
16
+ attr_reader :usage
14
17
  # @return [OpenStruct] Additional properties unmapped to the current class definition
15
18
  attr_reader :additional_properties
16
19
  # @return [Object]
@@ -21,13 +24,15 @@ module AssemblyAI
21
24
 
22
25
  # @param response [Array<AssemblyAI::Lemur::LemurQuestionAnswer>] The answers generated by LeMUR and their questions
23
26
  # @param request_id [String] The ID of the LeMUR request
27
+ # @param usage [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
24
28
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25
29
  # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
26
- def initialize(response:, request_id:, additional_properties: nil)
30
+ def initialize(response:, request_id:, usage:, additional_properties: nil)
27
31
  @response = response
28
32
  @request_id = request_id
33
+ @usage = usage
29
34
  @additional_properties = additional_properties
30
- @_field_set = { "response": response, "request_id": request_id }
35
+ @_field_set = { "response": response, "request_id": request_id, "usage": usage }
31
36
  end
32
37
 
33
38
  # Deserialize a JSON object to an instance of LemurQuestionAnswerResponse
@@ -36,14 +41,22 @@ module AssemblyAI
36
41
  # @return [AssemblyAI::Lemur::LemurQuestionAnswerResponse]
37
42
  def self.from_json(json_object:)
38
43
  struct = JSON.parse(json_object, object_class: OpenStruct)
44
+ parsed_json = JSON.parse(json_object)
39
45
  response = parsed_json["response"]&.map do |v|
40
46
  v = v.to_json
41
47
  AssemblyAI::Lemur::LemurQuestionAnswer.from_json(json_object: v)
42
48
  end
43
49
  request_id = struct["request_id"]
50
+ if parsed_json["usage"].nil?
51
+ usage = nil
52
+ else
53
+ usage = parsed_json["usage"].to_json
54
+ usage = AssemblyAI::Lemur::LemurUsage.from_json(json_object: usage)
55
+ end
44
56
  new(
45
57
  response: response,
46
58
  request_id: request_id,
59
+ usage: usage,
47
60
  additional_properties: struct
48
61
  )
49
62
  end
@@ -64,6 +77,7 @@ module AssemblyAI
64
77
  def self.validate_raw(obj:)
65
78
  obj.response.is_a?(Array) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
66
79
  obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
80
+ AssemblyAI::Lemur::LemurUsage.validate_raw(obj: obj.usage)
67
81
  end
68
82
  end
69
83
  end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "lemur_task_response"
5
+ require_relative "lemur_summary_response"
6
+ require_relative "lemur_question_answer_response"
7
+ require_relative "lemur_action_items_response"
8
+
9
+ module AssemblyAI
10
+ class Lemur
11
+ class LemurResponse
12
+ # Deserialize a JSON object to an instance of LemurResponse
13
+ #
14
+ # @param json_object [String]
15
+ # @return [AssemblyAI::Lemur::LemurResponse]
16
+ def self.from_json(json_object:)
17
+ struct = JSON.parse(json_object, object_class: OpenStruct)
18
+ begin
19
+ AssemblyAI::Lemur::LemurTaskResponse.validate_raw(obj: struct)
20
+ return AssemblyAI::Lemur::LemurTaskResponse.from_json(json_object: json_object) unless json_object.nil?
21
+
22
+ return nil
23
+ rescue StandardError
24
+ # noop
25
+ end
26
+ begin
27
+ AssemblyAI::Lemur::LemurSummaryResponse.validate_raw(obj: struct)
28
+ return AssemblyAI::Lemur::LemurSummaryResponse.from_json(json_object: json_object) unless json_object.nil?
29
+
30
+ return nil
31
+ rescue StandardError
32
+ # noop
33
+ end
34
+ begin
35
+ AssemblyAI::Lemur::LemurQuestionAnswerResponse.validate_raw(obj: struct)
36
+ unless json_object.nil?
37
+ return AssemblyAI::Lemur::LemurQuestionAnswerResponse.from_json(json_object: json_object)
38
+ end
39
+
40
+ return nil
41
+ rescue StandardError
42
+ # noop
43
+ end
44
+ begin
45
+ AssemblyAI::Lemur::LemurActionItemsResponse.validate_raw(obj: struct)
46
+ return AssemblyAI::Lemur::LemurActionItemsResponse.from_json(json_object: json_object) unless json_object.nil?
47
+
48
+ return nil
49
+ rescue StandardError
50
+ # noop
51
+ end
52
+ struct
53
+ end
54
+
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.
58
+ #
59
+ # @param obj [Object]
60
+ # @return [Void]
61
+ def self.validate_raw(obj:)
62
+ begin
63
+ return AssemblyAI::Lemur::LemurTaskResponse.validate_raw(obj: obj)
64
+ rescue StandardError
65
+ # noop
66
+ end
67
+ begin
68
+ return AssemblyAI::Lemur::LemurSummaryResponse.validate_raw(obj: obj)
69
+ rescue StandardError
70
+ # noop
71
+ end
72
+ begin
73
+ return AssemblyAI::Lemur::LemurQuestionAnswerResponse.validate_raw(obj: obj)
74
+ rescue StandardError
75
+ # noop
76
+ end
77
+ begin
78
+ return AssemblyAI::Lemur::LemurActionItemsResponse.validate_raw(obj: obj)
79
+ rescue StandardError
80
+ # noop
81
+ end
82
+ raise("Passed value matched no type within the union, validation failed.")
83
+ end
84
+ end
85
+ end
86
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "lemur_usage"
3
4
  require "ostruct"
4
5
  require "json"
5
6
 
@@ -10,6 +11,8 @@ module AssemblyAI
10
11
  attr_reader :response
11
12
  # @return [String] The ID of the LeMUR request
12
13
  attr_reader :request_id
14
+ # @return [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
15
+ attr_reader :usage
13
16
  # @return [OpenStruct] Additional properties unmapped to the current class definition
14
17
  attr_reader :additional_properties
15
18
  # @return [Object]
@@ -20,13 +23,15 @@ module AssemblyAI
20
23
 
21
24
  # @param response [String] The response generated by LeMUR
22
25
  # @param request_id [String] The ID of the LeMUR request
26
+ # @param usage [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
23
27
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
28
  # @return [AssemblyAI::Lemur::LemurSummaryResponse]
25
- def initialize(response:, request_id:, additional_properties: nil)
29
+ def initialize(response:, request_id:, usage:, additional_properties: nil)
26
30
  @response = response
27
31
  @request_id = request_id
32
+ @usage = usage
28
33
  @additional_properties = additional_properties
29
- @_field_set = { "response": response, "request_id": request_id }
34
+ @_field_set = { "response": response, "request_id": request_id, "usage": usage }
30
35
  end
31
36
 
32
37
  # Deserialize a JSON object to an instance of LemurSummaryResponse
@@ -35,11 +40,19 @@ module AssemblyAI
35
40
  # @return [AssemblyAI::Lemur::LemurSummaryResponse]
36
41
  def self.from_json(json_object:)
37
42
  struct = JSON.parse(json_object, object_class: OpenStruct)
43
+ parsed_json = JSON.parse(json_object)
38
44
  response = struct["response"]
39
45
  request_id = struct["request_id"]
46
+ if parsed_json["usage"].nil?
47
+ usage = nil
48
+ else
49
+ usage = parsed_json["usage"].to_json
50
+ usage = AssemblyAI::Lemur::LemurUsage.from_json(json_object: usage)
51
+ end
40
52
  new(
41
53
  response: response,
42
54
  request_id: request_id,
55
+ usage: usage,
43
56
  additional_properties: struct
44
57
  )
45
58
  end
@@ -60,6 +73,7 @@ module AssemblyAI
60
73
  def self.validate_raw(obj:)
61
74
  obj.response.is_a?(String) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
62
75
  obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
76
+ AssemblyAI::Lemur::LemurUsage.validate_raw(obj: obj.usage)
63
77
  end
64
78
  end
65
79
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "lemur_usage"
3
4
  require "ostruct"
4
5
  require "json"
5
6
 
@@ -10,6 +11,8 @@ module AssemblyAI
10
11
  attr_reader :response
11
12
  # @return [String] The ID of the LeMUR request
12
13
  attr_reader :request_id
14
+ # @return [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
15
+ attr_reader :usage
13
16
  # @return [OpenStruct] Additional properties unmapped to the current class definition
14
17
  attr_reader :additional_properties
15
18
  # @return [Object]
@@ -20,13 +23,15 @@ module AssemblyAI
20
23
 
21
24
  # @param response [String] The response generated by LeMUR.
22
25
  # @param request_id [String] The ID of the LeMUR request
26
+ # @param usage [AssemblyAI::Lemur::LemurUsage] The usage numbers for the LeMUR request
23
27
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
28
  # @return [AssemblyAI::Lemur::LemurTaskResponse]
25
- def initialize(response:, request_id:, additional_properties: nil)
29
+ def initialize(response:, request_id:, usage:, additional_properties: nil)
26
30
  @response = response
27
31
  @request_id = request_id
32
+ @usage = usage
28
33
  @additional_properties = additional_properties
29
- @_field_set = { "response": response, "request_id": request_id }
34
+ @_field_set = { "response": response, "request_id": request_id, "usage": usage }
30
35
  end
31
36
 
32
37
  # Deserialize a JSON object to an instance of LemurTaskResponse
@@ -35,11 +40,19 @@ module AssemblyAI
35
40
  # @return [AssemblyAI::Lemur::LemurTaskResponse]
36
41
  def self.from_json(json_object:)
37
42
  struct = JSON.parse(json_object, object_class: OpenStruct)
43
+ parsed_json = JSON.parse(json_object)
38
44
  response = struct["response"]
39
45
  request_id = struct["request_id"]
46
+ if parsed_json["usage"].nil?
47
+ usage = nil
48
+ else
49
+ usage = parsed_json["usage"].to_json
50
+ usage = AssemblyAI::Lemur::LemurUsage.from_json(json_object: usage)
51
+ end
40
52
  new(
41
53
  response: response,
42
54
  request_id: request_id,
55
+ usage: usage,
43
56
  additional_properties: struct
44
57
  )
45
58
  end
@@ -60,6 +73,7 @@ module AssemblyAI
60
73
  def self.validate_raw(obj:)
61
74
  obj.response.is_a?(String) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
62
75
  obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
76
+ AssemblyAI::Lemur::LemurUsage.validate_raw(obj: obj.usage)
63
77
  end
64
78
  end
65
79
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module AssemblyAI
7
+ class Lemur
8
+ # The usage numbers for the LeMUR request
9
+ class LemurUsage
10
+ # @return [Integer] The number of input tokens used by the model
11
+ attr_reader :input_tokens
12
+ # @return [Integer] The number of output tokens generated by the model
13
+ attr_reader :output_tokens
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
21
+
22
+ # @param input_tokens [Integer] The number of input tokens used by the model
23
+ # @param output_tokens [Integer] The number of output tokens generated by the model
24
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25
+ # @return [AssemblyAI::Lemur::LemurUsage]
26
+ def initialize(input_tokens:, output_tokens:, additional_properties: nil)
27
+ @input_tokens = input_tokens
28
+ @output_tokens = output_tokens
29
+ @additional_properties = additional_properties
30
+ @_field_set = { "input_tokens": input_tokens, "output_tokens": output_tokens }
31
+ end
32
+
33
+ # Deserialize a JSON object to an instance of LemurUsage
34
+ #
35
+ # @param json_object [String]
36
+ # @return [AssemblyAI::Lemur::LemurUsage]
37
+ def self.from_json(json_object:)
38
+ struct = JSON.parse(json_object, object_class: OpenStruct)
39
+ input_tokens = struct["input_tokens"]
40
+ output_tokens = struct["output_tokens"]
41
+ new(
42
+ input_tokens: input_tokens,
43
+ output_tokens: output_tokens,
44
+ additional_properties: struct
45
+ )
46
+ end
47
+
48
+ # Serialize an instance of LemurUsage to a JSON object
49
+ #
50
+ # @return [String]
51
+ def to_json(*_args)
52
+ @_field_set&.to_json
53
+ end
54
+
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.
58
+ #
59
+ # @param obj [Object]
60
+ # @return [Void]
61
+ def self.validate_raw(obj:)
62
+ obj.input_tokens.is_a?(Integer) != false || raise("Passed value for field obj.input_tokens is not the expected type, validation failed.")
63
+ obj.output_tokens.is_a?(Integer) != false || raise("Passed value for field obj.output_tokens is not the expected type, validation failed.")
64
+ end
65
+ end
66
+ end
67
+ end
@@ -22,11 +22,11 @@ module AssemblyAI
22
22
  # @return [AssemblyAI::Realtime::RealtimeTemporaryTokenResponse]
23
23
  # @example
24
24
  # api = AssemblyAI::Client.new(
25
- # environment: Environment::DEFAULT,
25
+ # environment: AssemblyAI::Environment::DEFAULT,
26
26
  # base_url: "https://api.example.com",
27
27
  # api_key: "YOUR_API_KEY"
28
28
  # )
29
- # api.create_temporary_token(expires_in: 480)
29
+ # api.realtime.create_temporary_token(expires_in: 480)
30
30
  def create_temporary_token(expires_in:, request_options: nil)
31
31
  response = @request_client.conn.post do |req|
32
32
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -56,11 +56,11 @@ module AssemblyAI
56
56
  # @return [AssemblyAI::Realtime::RealtimeTemporaryTokenResponse]
57
57
  # @example
58
58
  # api = AssemblyAI::Client.new(
59
- # environment: Environment::DEFAULT,
59
+ # environment: AssemblyAI::Environment::DEFAULT,
60
60
  # base_url: "https://api.example.com",
61
61
  # api_key: "YOUR_API_KEY"
62
62
  # )
63
- # api.create_temporary_token(expires_in: 480)
63
+ # api.realtime.create_temporary_token(expires_in: 480)
64
64
  def create_temporary_token(expires_in:, request_options: nil)
65
65
  Async do
66
66
  response = @request_client.conn.post do |req|
@@ -2,34 +2,52 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Transcripts
5
+ # The type of PII to redact
5
6
  class PiiPolicy
6
- MEDICAL_PROCESS = "medical_process"
7
- MEDICAL_CONDITION = "medical_condition"
7
+ ACCOUNT_NUMBER = "account_number"
8
+ BANKING_INFORMATION = "banking_information"
8
9
  BLOOD_TYPE = "blood_type"
9
- DRUG = "drug"
10
- INJURY = "injury"
11
- NUMBER_SEQUENCE = "number_sequence"
12
- EMAIL_ADDRESS = "email_address"
13
- DATE_OF_BIRTH = "date_of_birth"
14
- PHONE_NUMBER = "phone_number"
15
- US_SOCIAL_SECURITY_NUMBER = "us_social_security_number"
16
- CREDIT_CARD_NUMBER = "credit_card_number"
17
- CREDIT_CARD_EXPIRATION = "credit_card_expiration"
18
10
  CREDIT_CARD_CVV = "credit_card_cvv"
11
+ CREDIT_CARD_EXPIRATION = "credit_card_expiration"
12
+ CREDIT_CARD_NUMBER = "credit_card_number"
19
13
  DATE = "date"
20
- NATIONALITY = "nationality"
14
+ DATE_INTERVAL = "date_interval"
15
+ DATE_OF_BIRTH = "date_of_birth"
16
+ DRIVERS_LICENSE = "drivers_license"
17
+ DRUG = "drug"
18
+ DURATION = "duration"
19
+ EMAIL_ADDRESS = "email_address"
21
20
  EVENT = "event"
21
+ FILENAME = "filename"
22
+ GENDER_SEXUALITY = "gender_sexuality"
23
+ HEALTHCARE_NUMBER = "healthcare_number"
24
+ INJURY = "injury"
25
+ IP_ADDRESS = "ip_address"
22
26
  LANGUAGE = "language"
23
27
  LOCATION = "location"
28
+ MARITAL_STATUS = "marital_status"
29
+ MEDICAL_CONDITION = "medical_condition"
30
+ MEDICAL_PROCESS = "medical_process"
24
31
  MONEY_AMOUNT = "money_amount"
25
- PERSON_NAME = "person_name"
26
- PERSON_AGE = "person_age"
32
+ NATIONALITY = "nationality"
33
+ NUMBER_SEQUENCE = "number_sequence"
34
+ OCCUPATION = "occupation"
27
35
  ORGANIZATION = "organization"
36
+ PASSPORT_NUMBER = "passport_number"
37
+ PASSWORD = "password"
38
+ PERSON_AGE = "person_age"
39
+ PERSON_NAME = "person_name"
40
+ PHONE_NUMBER = "phone_number"
41
+ PHYSICAL_ATTRIBUTE = "physical_attribute"
28
42
  POLITICAL_AFFILIATION = "political_affiliation"
29
- OCCUPATION = "occupation"
30
43
  RELIGION = "religion"
31
- DRIVERS_LICENSE = "drivers_license"
32
- BANKING_INFORMATION = "banking_information"
44
+ STATISTICS = "statistics"
45
+ TIME = "time"
46
+ URL = "url"
47
+ US_SOCIAL_SECURITY_NUMBER = "us_social_security_number"
48
+ USERNAME = "username"
49
+ VEHICLE_ID = "vehicle_id"
50
+ ZODIAC_SIGN = "zodiac_sign"
33
51
  end
34
52
  end
35
53
  end
@@ -46,6 +46,7 @@ module AssemblyAI
46
46
  # @return [AssemblyAI::Transcripts::TopicDetectionModelResult]
47
47
  def self.from_json(json_object:)
48
48
  struct = JSON.parse(json_object, object_class: OpenStruct)
49
+ parsed_json = JSON.parse(json_object)
49
50
  status = struct["status"]
50
51
  results = parsed_json["results"]&.map do |v|
51
52
  v = v.to_json
@@ -443,6 +443,7 @@ module AssemblyAI
443
443
  # @return [AssemblyAI::Transcripts::Transcript]
444
444
  def self.from_json(json_object:)
445
445
  struct = JSON.parse(json_object, object_class: OpenStruct)
446
+ parsed_json = JSON.parse(json_object)
446
447
  id = struct["id"]
447
448
  language_model = struct["language_model"]
448
449
  acoustic_model = struct["acoustic_model"]
@@ -68,6 +68,7 @@ module AssemblyAI
68
68
  # @return [AssemblyAI::Transcripts::TranscriptListItem]
69
69
  def self.from_json(json_object:)
70
70
  struct = JSON.parse(json_object, object_class: OpenStruct)
71
+ parsed_json = JSON.parse(json_object)
71
72
  id = struct["id"]
72
73
  resource_url = struct["resource_url"]
73
74
  status = struct["status"]
@@ -283,6 +283,7 @@ module AssemblyAI
283
283
  # @return [AssemblyAI::Transcripts::TranscriptOptionalParams]
284
284
  def self.from_json(json_object:)
285
285
  struct = JSON.parse(json_object, object_class: OpenStruct)
286
+ parsed_json = JSON.parse(json_object)
286
287
  language_code = struct["language_code"]
287
288
  punctuate = struct["punctuate"]
288
289
  format_text = struct["format_text"]
@@ -65,6 +65,7 @@ module AssemblyAI
65
65
  # @return [AssemblyAI::Transcripts::TranscriptParagraph]
66
66
  def self.from_json(json_object:)
67
67
  struct = JSON.parse(json_object, object_class: OpenStruct)
68
+ parsed_json = JSON.parse(json_object)
68
69
  text = struct["text"]
69
70
  start = struct["start"]
70
71
  end_ = struct["end"]
@@ -65,6 +65,7 @@ module AssemblyAI
65
65
  # @return [AssemblyAI::Transcripts::TranscriptSentence]
66
66
  def self.from_json(json_object:)
67
67
  struct = JSON.parse(json_object, object_class: OpenStruct)
68
+ parsed_json = JSON.parse(json_object)
68
69
  text = struct["text"]
69
70
  start = struct["start"]
70
71
  end_ = struct["end"]
@@ -61,6 +61,7 @@ module AssemblyAI
61
61
  # @return [AssemblyAI::Transcripts::TranscriptUtterance]
62
62
  def self.from_json(json_object:)
63
63
  struct = JSON.parse(json_object, object_class: OpenStruct)
64
+ parsed_json = JSON.parse(json_object)
64
65
  confidence = struct["confidence"]
65
66
  start = struct["start"]
66
67
  end_ = struct["end"]
data/lib/requests.rb CHANGED
@@ -22,14 +22,14 @@ module AssemblyAI
22
22
  # @param timeout_in_seconds [Long]
23
23
  # @param api_key [String]
24
24
  # @return [AssemblyAI::RequestClient]
25
- def initialize(api_key:, environment: Environment::DEFAULT, base_url: nil, max_retries: nil,
25
+ def initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil,
26
26
  timeout_in_seconds: nil)
27
27
  @default_environment = environment
28
28
  @base_url = environment || base_url
29
29
  @headers = {
30
30
  "X-Fern-Language": "Ruby",
31
31
  "X-Fern-SDK-Name": "assemblyai",
32
- "X-Fern-SDK-Version": "1.0.0-beta.9",
32
+ "X-Fern-SDK-Version": "1.0.0-beta.11",
33
33
  "Authorization": api_key.to_s
34
34
  }
35
35
  @conn = Faraday.new(headers: @headers) do |faraday|
@@ -63,14 +63,14 @@ module AssemblyAI
63
63
  # @param timeout_in_seconds [Long]
64
64
  # @param api_key [String]
65
65
  # @return [AssemblyAI::AsyncRequestClient]
66
- def initialize(api_key:, environment: Environment::DEFAULT, base_url: nil, max_retries: nil,
66
+ def initialize(api_key:, environment: AssemblyAI::Environment::DEFAULT, base_url: nil, max_retries: nil,
67
67
  timeout_in_seconds: nil)
68
68
  @default_environment = environment
69
69
  @base_url = environment || base_url
70
70
  @headers = {
71
71
  "X-Fern-Language": "Ruby",
72
72
  "X-Fern-SDK-Name": "assemblyai",
73
- "X-Fern-SDK-Version": "1.0.0-beta.9",
73
+ "X-Fern-SDK-Version": "1.0.0-beta.11",
74
74
  "Authorization": api_key.to_s
75
75
  }
76
76
  @conn = Faraday.new(headers: @headers) do |faraday|
data/lib/types_export.rb CHANGED
@@ -66,16 +66,18 @@ require_relative "assemblyai/realtime/types/audio_encoding"
66
66
  require_relative "assemblyai/realtime/types/realtime_temporary_token_response"
67
67
  require_relative "assemblyai/lemur/types/purge_lemur_request_data_response"
68
68
  require_relative "assemblyai/lemur/types/lemur_base_response"
69
+ require_relative "assemblyai/lemur/types/lemur_task_response"
69
70
  require_relative "assemblyai/lemur/types/lemur_summary_response"
70
71
  require_relative "assemblyai/lemur/types/lemur_question_answer_response"
71
72
  require_relative "assemblyai/lemur/types/lemur_question_answer"
72
73
  require_relative "assemblyai/lemur/types/lemur_action_items_response"
73
- require_relative "assemblyai/lemur/types/lemur_task_response"
74
+ require_relative "assemblyai/lemur/types/lemur_response"
74
75
  require_relative "assemblyai/lemur/types/lemur_base_params_context"
75
76
  require_relative "assemblyai/lemur/types/lemur_base_params"
76
77
  require_relative "assemblyai/lemur/types/lemur_question_context"
77
78
  require_relative "assemblyai/lemur/types/lemur_question"
78
79
  require_relative "assemblyai/lemur/types/lemur_model"
80
+ require_relative "assemblyai/lemur/types/lemur_usage"
79
81
  require_relative "assemblyai/streaming/types/streaming"
80
82
  require_relative "assemblyai/streaming/types/receive_message"
81
83
  require_relative "assemblyai/streaming/types/send_message"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assemblyai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.9
4
+ version: 1.0.0.pre.beta.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-30 00:00:00.000000000 Z
11
+ date: 2024-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http-faraday
@@ -109,8 +109,10 @@ files:
109
109
  - lib/assemblyai/lemur/types/lemur_question_answer.rb
110
110
  - lib/assemblyai/lemur/types/lemur_question_answer_response.rb
111
111
  - lib/assemblyai/lemur/types/lemur_question_context.rb
112
+ - lib/assemblyai/lemur/types/lemur_response.rb
112
113
  - lib/assemblyai/lemur/types/lemur_summary_response.rb
113
114
  - lib/assemblyai/lemur/types/lemur_task_response.rb
115
+ - lib/assemblyai/lemur/types/lemur_usage.rb
114
116
  - lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb
115
117
  - lib/assemblyai/realtime/client.rb
116
118
  - lib/assemblyai/realtime/types/audio_encoding.rb