Module: RubyLLM::Text::Translate
- Defined in:
- lib/ruby_llm/text/translate.rb
Class Method Summary collapse
- .build_prompt(text, to:, from:) ⇒ Object
- .call(text, to:, from: nil, model: nil, **options) ⇒ Object
Class Method Details
.build_prompt(text, to:, from:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby_llm/text/translate.rb', line 13 def self.build_prompt(text, to:, from:) from_instruction = from ? "from #{from} " : "" <<~PROMPT Translate the following text #{from_instruction}to #{to}. Return only the translated text, no explanation or notes. Text: #{text} PROMPT end |
.call(text, to:, from: nil, model: nil, **options) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/ruby_llm/text/translate.rb', line 4 def self.call(text, to:, from: nil, model: nil, **) model ||= RubyLLM::Text.config.model_for(:translate) prompt = build_prompt(text, to: to, from: from) Base.call_llm(prompt, model: model, **) end |