Class: RubyLLM::Providers::VertexAI::Transcription

Inherits:
VertexAI::Gemini
  • Object
show all
Includes:
RubyLLM::Protocols::Gemini::FileTranscription
Defined in:
lib/ruby_llm/providers/vertexai/transcription.rb

Overview

:nodoc: all

Instance Method Summary collapse

Methods included from RubyLLM::Protocols::Gemini::FileTranscription

#transcribe

Instance Method Details

#render_transcription_options(timestamps:) ⇒ Object

Raises:



7
8
9
10
11
12
# File 'lib/ruby_llm/providers/vertexai/transcription.rb', line 7

def render_transcription_options(timestamps:, **)
  return {} if timestamps.nil?
  raise ArgumentError, 'Vertex AI transcription timestamps must be word' unless timestamps == :word

  { generationConfig: { audioTranscriptionConfig: { wordTimestamp: true } } }
end

#render_transcription_payload(attachment, language:, speaker_names:, provider_options:, prompt:) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/ruby_llm/providers/vertexai/transcription.rb', line 23

def render_transcription_payload(attachment, language:, speaker_names:, provider_options:, prompt:, **)
  config = { languageCodes: language && Array(language), customVocabulary: prompt && Array(prompt),
             diarization: speaker_names && true }.compact
  payload = { contents: [{ role: 'user', parts: [format_audio_part(attachment)] }],
              generationConfig: { audioTranscriptionConfig: config } }
  Support::Utils.deep_merge(payload, provider_options)
end

#validate_transcription_requestObject

Raises:



16
17
18
19
20
21
# File 'lib/ruby_llm/providers/vertexai/transcription.rb', line 16

def validate_transcription_request(...)
  super
  return if @config.vertexai_location == 'global'

  raise ArgumentError, 'Vertex AI dedicated transcription requires vertexai_location = "global"'
end