assemblyai 1.0.0.pre.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/assemblyai/files/client.rb +63 -0
- data/lib/assemblyai/files/types/uploaded_file.rb +47 -0
- data/lib/assemblyai/lemur/client.rb +390 -0
- data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +52 -0
- data/lib/assemblyai/lemur/types/lemur_base_params.rb +99 -0
- data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +75 -0
- data/lib/assemblyai/lemur/types/lemur_base_response.rb +47 -0
- data/lib/assemblyai/lemur/types/lemur_model.rb +13 -0
- data/lib/assemblyai/lemur/types/lemur_question.rb +74 -0
- data/lib/assemblyai/lemur/types/lemur_question_answer.rb +53 -0
- data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +56 -0
- data/lib/assemblyai/lemur/types/lemur_question_context.rb +75 -0
- data/lib/assemblyai/lemur/types/lemur_summary_response.rb +52 -0
- data/lib/assemblyai/lemur/types/lemur_task_response.rb +52 -0
- data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +58 -0
- data/lib/assemblyai/realtime/client.rb +61 -0
- data/lib/assemblyai/realtime/types/audio_data.rb +7 -0
- data/lib/assemblyai/realtime/types/audio_encoding.rb +8 -0
- data/lib/assemblyai/realtime/types/final_transcript.rb +107 -0
- data/lib/assemblyai/realtime/types/message_type.rb +13 -0
- data/lib/assemblyai/realtime/types/partial_transcript.rb +94 -0
- data/lib/assemblyai/realtime/types/realtime_base_message.rb +48 -0
- data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +87 -0
- data/lib/assemblyai/realtime/types/realtime_error.rb +47 -0
- data/lib/assemblyai/realtime/types/realtime_message.rb +115 -0
- data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +47 -0
- data/lib/assemblyai/realtime/types/realtime_transcript.rb +76 -0
- data/lib/assemblyai/realtime/types/realtime_transcript_type.rb +8 -0
- data/lib/assemblyai/realtime/types/session_begins.rb +58 -0
- data/lib/assemblyai/realtime/types/session_terminated.rb +47 -0
- data/lib/assemblyai/realtime/types/terminate_session.rb +56 -0
- data/lib/assemblyai/realtime/types/word.rb +62 -0
- data/lib/assemblyai/transcripts/client.rb +525 -0
- data/lib/assemblyai/transcripts/polling_client.rb +173 -0
- data/lib/assemblyai/transcripts/types/audio_intelligence_model_status.rb +8 -0
- data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +66 -0
- data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +53 -0
- data/lib/assemblyai/transcripts/types/chapter.rb +68 -0
- data/lib/assemblyai/transcripts/types/content_safety_label.rb +57 -0
- data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +84 -0
- data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +75 -0
- data/lib/assemblyai/transcripts/types/entity.rb +69 -0
- data/lib/assemblyai/transcripts/types/entity_type.rb +38 -0
- data/lib/assemblyai/transcripts/types/page_details.rb +74 -0
- data/lib/assemblyai/transcripts/types/paragraphs_response.rb +67 -0
- data/lib/assemblyai/transcripts/types/pii_policy.rb +36 -0
- data/lib/assemblyai/transcripts/types/polling_options.rb +21 -0
- data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +8 -0
- data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +53 -0
- data/lib/assemblyai/transcripts/types/redacted_audio_status.rb +7 -0
- data/lib/assemblyai/transcripts/types/sentences_response.rb +67 -0
- data/lib/assemblyai/transcripts/types/sentiment.rb +8 -0
- data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +82 -0
- data/lib/assemblyai/transcripts/types/severity_score_summary.rb +57 -0
- data/lib/assemblyai/transcripts/types/speech_model.rb +7 -0
- data/lib/assemblyai/transcripts/types/substitution_policy.rb +8 -0
- data/lib/assemblyai/transcripts/types/subtitle_format.rb +8 -0
- data/lib/assemblyai/transcripts/types/summary_model.rb +8 -0
- data/lib/assemblyai/transcripts/types/summary_type.rb +14 -0
- data/lib/assemblyai/transcripts/types/timestamp.rb +53 -0
- data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +68 -0
- data/lib/assemblyai/transcripts/types/topic_detection_result.rb +68 -0
- data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +52 -0
- data/lib/assemblyai/transcripts/types/transcript.rb +454 -0
- data/lib/assemblyai/transcripts/types/transcript_boost_param.rb +8 -0
- data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +53 -0
- data/lib/assemblyai/transcripts/types/transcript_language_code.rb +29 -0
- data/lib/assemblyai/transcripts/types/transcript_list.rb +62 -0
- data/lib/assemblyai/transcripts/types/transcript_list_item.rb +82 -0
- data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +280 -0
- data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_sentence.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_status.rb +8 -0
- data/lib/assemblyai/transcripts/types/transcript_utterance.rb +84 -0
- data/lib/assemblyai/transcripts/types/transcript_word.rb +68 -0
- data/lib/assemblyai/transcripts/types/word_search_match.rb +63 -0
- data/lib/assemblyai/transcripts/types/word_search_response.rb +61 -0
- data/lib/assemblyai/transcripts/types/word_search_timestamp.rb +7 -0
- data/lib/assemblyai/types/error.rb +50 -0
- data/lib/assemblyai.rb +48 -0
- data/lib/environment.rb +7 -0
- data/lib/gemconfig.rb +14 -0
- data/lib/requests.rb +87 -0
- data/lib/types_export.rb +75 -0
- metadata +170 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Lemur
|
|
7
|
+
# Context to provide the model. This can be a string or a free-form JSON value.
|
|
8
|
+
class LemurBaseParamsContext
|
|
9
|
+
attr_reader :member
|
|
10
|
+
alias kind_of? is_a?
|
|
11
|
+
# @param member [Object]
|
|
12
|
+
# @return [Lemur::LemurBaseParamsContext]
|
|
13
|
+
def initialize(member:)
|
|
14
|
+
# @type [Object]
|
|
15
|
+
@member = member
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Deserialize a JSON object to an instance of LemurBaseParamsContext
|
|
19
|
+
#
|
|
20
|
+
# @param json_object [JSON]
|
|
21
|
+
# @return [Lemur::LemurBaseParamsContext]
|
|
22
|
+
def self.from_json(json_object:)
|
|
23
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
24
|
+
begin
|
|
25
|
+
struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
|
26
|
+
member = json_object
|
|
27
|
+
return new(member: member)
|
|
28
|
+
rescue StandardError
|
|
29
|
+
# noop
|
|
30
|
+
end
|
|
31
|
+
begin
|
|
32
|
+
struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
|
33
|
+
member = json_object
|
|
34
|
+
return new(member: member)
|
|
35
|
+
rescue StandardError
|
|
36
|
+
# noop
|
|
37
|
+
end
|
|
38
|
+
new(member: struct)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
|
42
|
+
#
|
|
43
|
+
# @return [JSON]
|
|
44
|
+
def to_json(*_args)
|
|
45
|
+
@member.to_json
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# 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.
|
|
49
|
+
#
|
|
50
|
+
# @param obj [Object]
|
|
51
|
+
# @return [Void]
|
|
52
|
+
def self.validate_raw(obj:)
|
|
53
|
+
begin
|
|
54
|
+
return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
|
55
|
+
rescue StandardError
|
|
56
|
+
# noop
|
|
57
|
+
end
|
|
58
|
+
begin
|
|
59
|
+
return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
|
60
|
+
rescue StandardError
|
|
61
|
+
# noop
|
|
62
|
+
end
|
|
63
|
+
raise("Passed value matched no type within the union, validation failed.")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
|
67
|
+
#
|
|
68
|
+
# @param obj [Object]
|
|
69
|
+
# @return [Boolean]
|
|
70
|
+
def is_a?(obj)
|
|
71
|
+
@member.is_a?(obj)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Lemur
|
|
7
|
+
class LemurBaseResponse
|
|
8
|
+
attr_reader :request_id, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param request_id [String] The ID of the LeMUR request
|
|
11
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
12
|
+
# @return [Lemur::LemurBaseResponse]
|
|
13
|
+
def initialize(request_id:, additional_properties: nil)
|
|
14
|
+
# @type [String] The ID of the LeMUR request
|
|
15
|
+
@request_id = request_id
|
|
16
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
17
|
+
@additional_properties = additional_properties
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Deserialize a JSON object to an instance of LemurBaseResponse
|
|
21
|
+
#
|
|
22
|
+
# @param json_object [JSON]
|
|
23
|
+
# @return [Lemur::LemurBaseResponse]
|
|
24
|
+
def self.from_json(json_object:)
|
|
25
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
26
|
+
JSON.parse(json_object)
|
|
27
|
+
request_id = struct.request_id
|
|
28
|
+
new(request_id: request_id, additional_properties: struct)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Serialize an instance of LemurBaseResponse to a JSON object
|
|
32
|
+
#
|
|
33
|
+
# @return [JSON]
|
|
34
|
+
def to_json(*_args)
|
|
35
|
+
{ "request_id": @request_id }.to_json
|
|
36
|
+
end
|
|
37
|
+
|
|
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.
|
|
39
|
+
#
|
|
40
|
+
# @param obj [Object]
|
|
41
|
+
# @return [Void]
|
|
42
|
+
def self.validate_raw(obj:)
|
|
43
|
+
obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AssemblyAI
|
|
4
|
+
class Lemur
|
|
5
|
+
# @type [LEMUR_MODEL]
|
|
6
|
+
LEMUR_MODEL = {
|
|
7
|
+
default: "default",
|
|
8
|
+
basic: "basic",
|
|
9
|
+
assemblyai_mistral7b: "assemblyai/mistral-7b",
|
|
10
|
+
anthropic_claude21: "anthropic/claude-2-1"
|
|
11
|
+
}.freeze
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lemur_question_context"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Lemur
|
|
8
|
+
class LemurQuestion
|
|
9
|
+
attr_reader :question, :context, :answer_format, :answer_options, :additional_properties
|
|
10
|
+
|
|
11
|
+
# @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"]
|
|
15
|
+
# @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.
|
|
19
|
+
@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
|
|
27
|
+
@additional_properties = additional_properties
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Deserialize a JSON object to an instance of LemurQuestion
|
|
31
|
+
#
|
|
32
|
+
# @param json_object [JSON]
|
|
33
|
+
# @return [Lemur::LemurQuestion]
|
|
34
|
+
def self.from_json(json_object:)
|
|
35
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
36
|
+
parsed_json = JSON.parse(json_object)
|
|
37
|
+
question = struct.question
|
|
38
|
+
if parsed_json["context"].nil?
|
|
39
|
+
context = nil
|
|
40
|
+
else
|
|
41
|
+
context = parsed_json["context"].to_json
|
|
42
|
+
context = Lemur::LemurQuestionContext.from_json(json_object: context)
|
|
43
|
+
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)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Serialize an instance of LemurQuestion to a JSON object
|
|
51
|
+
#
|
|
52
|
+
# @return [JSON]
|
|
53
|
+
def to_json(*_args)
|
|
54
|
+
{
|
|
55
|
+
"question": @question,
|
|
56
|
+
"context": @context,
|
|
57
|
+
"answer_format": @answer_format,
|
|
58
|
+
"answer_options": @answer_options
|
|
59
|
+
}.to_json
|
|
60
|
+
end
|
|
61
|
+
|
|
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.
|
|
63
|
+
#
|
|
64
|
+
# @param obj [Object]
|
|
65
|
+
# @return [Void]
|
|
66
|
+
def self.validate_raw(obj:)
|
|
67
|
+
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)
|
|
69
|
+
obj.answer_format&.is_a?(String) != false || raise("Passed value for field obj.answer_format is not the expected type, validation failed.")
|
|
70
|
+
obj.answer_options&.is_a?(Array) != false || raise("Passed value for field obj.answer_options is not the expected type, validation failed.")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Lemur
|
|
7
|
+
# An answer generated by LeMUR and its question
|
|
8
|
+
class LemurQuestionAnswer
|
|
9
|
+
attr_reader :question, :answer, :additional_properties
|
|
10
|
+
|
|
11
|
+
# @param question [String] The question for LeMUR to answer
|
|
12
|
+
# @param answer [String] The answer generated by LeMUR
|
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
14
|
+
# @return [Lemur::LemurQuestionAnswer]
|
|
15
|
+
def initialize(question:, answer:, additional_properties: nil)
|
|
16
|
+
# @type [String] The question for LeMUR to answer
|
|
17
|
+
@question = question
|
|
18
|
+
# @type [String] The answer generated by LeMUR
|
|
19
|
+
@answer = answer
|
|
20
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
21
|
+
@additional_properties = additional_properties
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Deserialize a JSON object to an instance of LemurQuestionAnswer
|
|
25
|
+
#
|
|
26
|
+
# @param json_object [JSON]
|
|
27
|
+
# @return [Lemur::LemurQuestionAnswer]
|
|
28
|
+
def self.from_json(json_object:)
|
|
29
|
+
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)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Serialize an instance of LemurQuestionAnswer to a JSON object
|
|
37
|
+
#
|
|
38
|
+
# @return [JSON]
|
|
39
|
+
def to_json(*_args)
|
|
40
|
+
{ "question": @question, "answer": @answer }.to_json
|
|
41
|
+
end
|
|
42
|
+
|
|
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.
|
|
44
|
+
#
|
|
45
|
+
# @param obj [Object]
|
|
46
|
+
# @return [Void]
|
|
47
|
+
def self.validate_raw(obj:)
|
|
48
|
+
obj.question.is_a?(String) != false || raise("Passed value for field obj.question is not the expected type, validation failed.")
|
|
49
|
+
obj.answer.is_a?(String) != false || raise("Passed value for field obj.answer is not the expected type, validation failed.")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lemur_question_answer"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module AssemblyAI
|
|
7
|
+
class Lemur
|
|
8
|
+
class LemurQuestionAnswerResponse
|
|
9
|
+
attr_reader :response, :request_id, :additional_properties
|
|
10
|
+
|
|
11
|
+
# @param response [Array<Lemur::LemurQuestionAnswer>] The answers generated by LeMUR and their questions
|
|
12
|
+
# @param request_id [String] The ID of the LeMUR request
|
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
14
|
+
# @return [Lemur::LemurQuestionAnswerResponse]
|
|
15
|
+
def initialize(response:, request_id:, additional_properties: nil)
|
|
16
|
+
# @type [Array<Lemur::LemurQuestionAnswer>] The answers generated by LeMUR and their questions
|
|
17
|
+
@response = response
|
|
18
|
+
# @type [String] The ID of the LeMUR request
|
|
19
|
+
@request_id = request_id
|
|
20
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
21
|
+
@additional_properties = additional_properties
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Deserialize a JSON object to an instance of LemurQuestionAnswerResponse
|
|
25
|
+
#
|
|
26
|
+
# @param json_object [JSON]
|
|
27
|
+
# @return [Lemur::LemurQuestionAnswerResponse]
|
|
28
|
+
def self.from_json(json_object:)
|
|
29
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
30
|
+
parsed_json = JSON.parse(json_object)
|
|
31
|
+
response = parsed_json["response"]&.map do |v|
|
|
32
|
+
v = v.to_json
|
|
33
|
+
Lemur::LemurQuestionAnswer.from_json(json_object: v)
|
|
34
|
+
end
|
|
35
|
+
request_id = struct.request_id
|
|
36
|
+
new(response: response, request_id: request_id, additional_properties: struct)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Serialize an instance of LemurQuestionAnswerResponse to a JSON object
|
|
40
|
+
#
|
|
41
|
+
# @return [JSON]
|
|
42
|
+
def to_json(*_args)
|
|
43
|
+
{ "response": @response, "request_id": @request_id }.to_json
|
|
44
|
+
end
|
|
45
|
+
|
|
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.
|
|
47
|
+
#
|
|
48
|
+
# @param obj [Object]
|
|
49
|
+
# @return [Void]
|
|
50
|
+
def self.validate_raw(obj:)
|
|
51
|
+
obj.response.is_a?(Array) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
|
|
52
|
+
obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Lemur
|
|
7
|
+
# Any context about the transcripts you wish to provide. This can be a string or any object.
|
|
8
|
+
class LemurQuestionContext
|
|
9
|
+
attr_reader :member
|
|
10
|
+
alias kind_of? is_a?
|
|
11
|
+
# @param member [Object]
|
|
12
|
+
# @return [Lemur::LemurQuestionContext]
|
|
13
|
+
def initialize(member:)
|
|
14
|
+
# @type [Object]
|
|
15
|
+
@member = member
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Deserialize a JSON object to an instance of LemurQuestionContext
|
|
19
|
+
#
|
|
20
|
+
# @param json_object [JSON]
|
|
21
|
+
# @return [Lemur::LemurQuestionContext]
|
|
22
|
+
def self.from_json(json_object:)
|
|
23
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
24
|
+
begin
|
|
25
|
+
struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
|
26
|
+
member = json_object
|
|
27
|
+
return new(member: member)
|
|
28
|
+
rescue StandardError
|
|
29
|
+
# noop
|
|
30
|
+
end
|
|
31
|
+
begin
|
|
32
|
+
struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.")
|
|
33
|
+
member = json_object
|
|
34
|
+
return new(member: member)
|
|
35
|
+
rescue StandardError
|
|
36
|
+
# noop
|
|
37
|
+
end
|
|
38
|
+
new(member: struct)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
|
42
|
+
#
|
|
43
|
+
# @return [JSON]
|
|
44
|
+
def to_json(*_args)
|
|
45
|
+
@member.to_json
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# 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.
|
|
49
|
+
#
|
|
50
|
+
# @param obj [Object]
|
|
51
|
+
# @return [Void]
|
|
52
|
+
def self.validate_raw(obj:)
|
|
53
|
+
begin
|
|
54
|
+
return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
|
55
|
+
rescue StandardError
|
|
56
|
+
# noop
|
|
57
|
+
end
|
|
58
|
+
begin
|
|
59
|
+
return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.")
|
|
60
|
+
rescue StandardError
|
|
61
|
+
# noop
|
|
62
|
+
end
|
|
63
|
+
raise("Passed value matched no type within the union, validation failed.")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
|
67
|
+
#
|
|
68
|
+
# @param obj [Object]
|
|
69
|
+
# @return [Boolean]
|
|
70
|
+
def is_a?(obj)
|
|
71
|
+
@member.is_a?(obj)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Lemur
|
|
7
|
+
class LemurSummaryResponse
|
|
8
|
+
attr_reader :response, :request_id, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param response [String] The response generated by LeMUR
|
|
11
|
+
# @param request_id [String] The ID of the LeMUR request
|
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
13
|
+
# @return [Lemur::LemurSummaryResponse]
|
|
14
|
+
def initialize(response:, request_id:, additional_properties: nil)
|
|
15
|
+
# @type [String] The response generated by LeMUR
|
|
16
|
+
@response = response
|
|
17
|
+
# @type [String] The ID of the LeMUR request
|
|
18
|
+
@request_id = request_id
|
|
19
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
20
|
+
@additional_properties = additional_properties
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Deserialize a JSON object to an instance of LemurSummaryResponse
|
|
24
|
+
#
|
|
25
|
+
# @param json_object [JSON]
|
|
26
|
+
# @return [Lemur::LemurSummaryResponse]
|
|
27
|
+
def self.from_json(json_object:)
|
|
28
|
+
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)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Serialize an instance of LemurSummaryResponse to a JSON object
|
|
36
|
+
#
|
|
37
|
+
# @return [JSON]
|
|
38
|
+
def to_json(*_args)
|
|
39
|
+
{ "response": @response, "request_id": @request_id }.to_json
|
|
40
|
+
end
|
|
41
|
+
|
|
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.
|
|
43
|
+
#
|
|
44
|
+
# @param obj [Object]
|
|
45
|
+
# @return [Void]
|
|
46
|
+
def self.validate_raw(obj:)
|
|
47
|
+
obj.response.is_a?(String) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
|
|
48
|
+
obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Lemur
|
|
7
|
+
class LemurTaskResponse
|
|
8
|
+
attr_reader :response, :request_id, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param response [String] The response generated by LeMUR.
|
|
11
|
+
# @param request_id [String] The ID of the LeMUR request
|
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
13
|
+
# @return [Lemur::LemurTaskResponse]
|
|
14
|
+
def initialize(response:, request_id:, additional_properties: nil)
|
|
15
|
+
# @type [String] The response generated by LeMUR.
|
|
16
|
+
@response = response
|
|
17
|
+
# @type [String] The ID of the LeMUR request
|
|
18
|
+
@request_id = request_id
|
|
19
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
20
|
+
@additional_properties = additional_properties
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Deserialize a JSON object to an instance of LemurTaskResponse
|
|
24
|
+
#
|
|
25
|
+
# @param json_object [JSON]
|
|
26
|
+
# @return [Lemur::LemurTaskResponse]
|
|
27
|
+
def self.from_json(json_object:)
|
|
28
|
+
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)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Serialize an instance of LemurTaskResponse to a JSON object
|
|
36
|
+
#
|
|
37
|
+
# @return [JSON]
|
|
38
|
+
def to_json(*_args)
|
|
39
|
+
{ "response": @response, "request_id": @request_id }.to_json
|
|
40
|
+
end
|
|
41
|
+
|
|
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.
|
|
43
|
+
#
|
|
44
|
+
# @param obj [Object]
|
|
45
|
+
# @return [Void]
|
|
46
|
+
def self.validate_raw(obj:)
|
|
47
|
+
obj.response.is_a?(String) != false || raise("Passed value for field obj.response is not the expected type, validation failed.")
|
|
48
|
+
obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module AssemblyAI
|
|
6
|
+
class Lemur
|
|
7
|
+
class PurgeLemurRequestDataResponse
|
|
8
|
+
attr_reader :request_id, :request_id_to_purge, :deleted, :additional_properties
|
|
9
|
+
|
|
10
|
+
# @param request_id [String] The ID of the deletion request of the LeMUR request
|
|
11
|
+
# @param request_id_to_purge [String] The ID of the LeMUR request to purge the data for
|
|
12
|
+
# @param deleted [Boolean] Whether the request data was deleted
|
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
14
|
+
# @return [Lemur::PurgeLemurRequestDataResponse]
|
|
15
|
+
def initialize(request_id:, request_id_to_purge:, deleted:, additional_properties: nil)
|
|
16
|
+
# @type [String] The ID of the deletion request of the LeMUR request
|
|
17
|
+
@request_id = request_id
|
|
18
|
+
# @type [String] The ID of the LeMUR request to purge the data for
|
|
19
|
+
@request_id_to_purge = request_id_to_purge
|
|
20
|
+
# @type [Boolean] Whether the request data was deleted
|
|
21
|
+
@deleted = deleted
|
|
22
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
|
23
|
+
@additional_properties = additional_properties
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Deserialize a JSON object to an instance of PurgeLemurRequestDataResponse
|
|
27
|
+
#
|
|
28
|
+
# @param json_object [JSON]
|
|
29
|
+
# @return [Lemur::PurgeLemurRequestDataResponse]
|
|
30
|
+
def self.from_json(json_object:)
|
|
31
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
32
|
+
JSON.parse(json_object)
|
|
33
|
+
request_id = struct.request_id
|
|
34
|
+
request_id_to_purge = struct.request_id_to_purge
|
|
35
|
+
deleted = struct.deleted
|
|
36
|
+
new(request_id: request_id, request_id_to_purge: request_id_to_purge, deleted: deleted,
|
|
37
|
+
additional_properties: struct)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Serialize an instance of PurgeLemurRequestDataResponse to a JSON object
|
|
41
|
+
#
|
|
42
|
+
# @return [JSON]
|
|
43
|
+
def to_json(*_args)
|
|
44
|
+
{ "request_id": @request_id, "request_id_to_purge": @request_id_to_purge, "deleted": @deleted }.to_json
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# 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.
|
|
48
|
+
#
|
|
49
|
+
# @param obj [Object]
|
|
50
|
+
# @return [Void]
|
|
51
|
+
def self.validate_raw(obj:)
|
|
52
|
+
obj.request_id.is_a?(String) != false || raise("Passed value for field obj.request_id is not the expected type, validation failed.")
|
|
53
|
+
obj.request_id_to_purge.is_a?(String) != false || raise("Passed value for field obj.request_id_to_purge is not the expected type, validation failed.")
|
|
54
|
+
obj.deleted.is_a?(Boolean) != false || raise("Passed value for field obj.deleted is not the expected type, validation failed.")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../requests"
|
|
4
|
+
require_relative "types/realtime_temporary_token_response"
|
|
5
|
+
require "async"
|
|
6
|
+
|
|
7
|
+
module AssemblyAI
|
|
8
|
+
class RealtimeClient
|
|
9
|
+
attr_reader :request_client
|
|
10
|
+
|
|
11
|
+
# @param request_client [RequestClient]
|
|
12
|
+
# @return [RealtimeClient]
|
|
13
|
+
def initialize(request_client:)
|
|
14
|
+
# @type [RequestClient]
|
|
15
|
+
@request_client = request_client
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Create a temporary authentication token for real-time transcription
|
|
19
|
+
#
|
|
20
|
+
# @param expires_in [Integer] The amount of time until the token expires in seconds
|
|
21
|
+
# @param request_options [RequestOptions]
|
|
22
|
+
# @return [Realtime::RealtimeTemporaryTokenResponse]
|
|
23
|
+
def create_temporary_token(expires_in:, request_options: nil)
|
|
24
|
+
response = @request_client.conn.post("/v2/realtime/token") do |req|
|
|
25
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
26
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
|
27
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
|
28
|
+
req.body = { **(request_options&.additional_body_parameters || {}), expires_in: expires_in }.compact
|
|
29
|
+
end
|
|
30
|
+
Realtime::RealtimeTemporaryTokenResponse.from_json(json_object: response.body)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class AsyncRealtimeClient
|
|
35
|
+
attr_reader :request_client
|
|
36
|
+
|
|
37
|
+
# @param request_client [AsyncRequestClient]
|
|
38
|
+
# @return [AsyncRealtimeClient]
|
|
39
|
+
def initialize(request_client:)
|
|
40
|
+
# @type [AsyncRequestClient]
|
|
41
|
+
@request_client = request_client
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Create a temporary authentication token for real-time transcription
|
|
45
|
+
#
|
|
46
|
+
# @param expires_in [Integer] The amount of time until the token expires in seconds
|
|
47
|
+
# @param request_options [RequestOptions]
|
|
48
|
+
# @return [Realtime::RealtimeTemporaryTokenResponse]
|
|
49
|
+
def create_temporary_token(expires_in:, request_options: nil)
|
|
50
|
+
Async do
|
|
51
|
+
response = @request_client.conn.post("/v2/realtime/token") do |req|
|
|
52
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
53
|
+
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
|
|
54
|
+
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
|
|
55
|
+
req.body = { **(request_options&.additional_body_parameters || {}), expires_in: expires_in }.compact
|
|
56
|
+
end
|
|
57
|
+
Realtime::RealtimeTemporaryTokenResponse.from_json(json_object: response.body)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|