Module: RubyLLM::Protocols::Cohere::Transcription
- Defined in:
- lib/ruby_llm/protocols/cohere/transcription.rb
Overview
Audio transcription methods for the Cohere v2 API integration
Constant Summary collapse
- DEFAULT_LANGUAGE =
'en'
Class Method Summary collapse
-
.parse_transcription_response(response, model:) ⇒ Object
Cohere Transcribe returns the transcript alone: no timestamps, segments, or speaker labels.
-
.render_transcription_payload(file_part, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) ⇒ Object
Cohere parses the multipart body as it streams, so every form field has to be written before the file part or the request is rejected as missing them.
- .transcription_url ⇒ Object
Class Method Details
.parse_transcription_response(response, model:) ⇒ Object
Cohere Transcribe returns the transcript alone: no timestamps, segments, or speaker labels.
32 33 34 35 36 37 |
# File 'lib/ruby_llm/protocols/cohere/transcription.rb', line 32 def parse_transcription_response(response, model:) data = response.body return RubyLLM::Transcription.new(text: data, model: model) if data.is_a?(String) RubyLLM::Transcription.new(text: data['text'], model: model) end |
.render_transcription_payload(file_part, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) ⇒ Object
Cohere parses the multipart body as it streams, so every form field has to be written before the file part or the request is rejected as missing them. The file goes in last, after provider options. rubocop:disable-next Lint/UnusedMethodArgument
20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby_llm/protocols/cohere/transcription.rb', line 20 def render_transcription_payload(file_part, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) { model: model, language: language || DEFAULT_LANGUAGE, temperature: temperature }.compact.merge().merge(file: file_part) end |
.transcription_url ⇒ Object
12 13 14 |
# File 'lib/ruby_llm/protocols/cohere/transcription.rb', line 12 def transcription_url 'v2/audio/transcriptions' end |