Class: TranslationAPI::Llm::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/translation_api/llm/prompt.rb

Constant Summary collapse

SYSTEM_PROMPT_BASE =
<<~TEXT
  Translate only.
  Return result only, no extra info
  Keep symbols
TEXT

Instance Method Summary collapse

Constructor Details

#initialize(except_words:, language:, custom_prompt:) ⇒ Prompt

Returns a new instance of Prompt.



12
13
14
15
16
# File 'lib/translation_api/llm/prompt.rb', line 12

def initialize(except_words:, language:, custom_prompt:)
  @except_words  = except_words
  @language      = language
  @custom_prompt = custom_prompt
end

Instance Method Details

#system_promptObject



18
19
20
# File 'lib/translation_api/llm/prompt.rb', line 18

def system_prompt
  SYSTEM_PROMPT_BASE + except_option_text
end

#user_promptObject



22
23
24
25
26
27
# File 'lib/translation_api/llm/prompt.rb', line 22

def user_prompt
  <<~TEXT
    #{@custom_prompt || ""}
    Please translate this text to #{@language}:
  TEXT
end