# `GettextTranslator.Processor.LLM`
[🔗](https://github.com/marmend-company/gettext_translator/blob/main/lib/gettext_translator/processor/llm.ex#L1)

 LLM processor for the translator behaviour.

# `build_translategemma_prompt`

```elixir
@spec build_translategemma_prompt(String.t(), String.t(), String.t()) :: String.t()
```

Builds a TranslateGemma-formatted prompt for translation.

TranslateGemma expects a single user message with a specific structure:
professional translator persona, followed by two blank lines before the text.

## Parameters

  - `message` - The text to translate
  - `source_code` - POSIX code of the source language (e.g., "en")
  - `target_code` - POSIX code of the target language (e.g., "es")

## Examples

    iex> GettextTranslator.Processor.LLM.build_translategemma_prompt("Hello", "en", "es")
    "You are a professional English (en) to Spanish (es) translator. " <>
    "Your goal is to accurately convey the meaning and nuances of the original English text " <>
    "while adhering to Spanish grammar, vocabulary, and cultural sensitivities.\n" <>
    "Produce only the Spanish translation, without any additional explanations or commentary. " <>
    "Please translate the following English text into Spanish:\n\n\nHello"

# `translate`

```elixir
@spec translate(
  GettextTranslator.Processor.Translator.provider(),
  GettextTranslator.Processor.Translator.opts()
) :: {:ok, String.t()} | {:error, any()}
```

# `translate_single`

```elixir
@spec translate_single(
  GettextTranslator.Processor.Translator.provider(),
  map(),
  String.t() | nil
) ::
  {:ok, map()} | {:error, any()}
```

Translates a single message using the configured LLM provider, with optional
additional instructions to guide the translation.

## Parameters

  - `provider` - The provider config map from `Parser.parse_provider/0`
  - `opts` - Map with `:language_code`, `:message`, `:type`, and optionally `:plural_message`
  - `additional_instructions` - Optional string with extra instructions for the LLM

## Returns

  - `{:ok, %{translation: String.t(), plural_translation: String.t() | nil}}`
  - `{:error, reason}`

# `translategemma?`

```elixir
@spec translategemma?(String.t()) :: boolean()
```

Checks if the given model name is a TranslateGemma model.

## Examples

    iex> GettextTranslator.Processor.LLM.translategemma?("translategemma-27b")
    true

    iex> GettextTranslator.Processor.LLM.translategemma?("gpt-4")
    false

---

*Consult [api-reference.md](api-reference.md) for complete listing*
