fix(arr): gate the shared LLM prompt helpers

#193 moved them out of openai.rs so the command backend could share them,
but left them ungated: with neither LLM backend compiled in they are dead
code. just ci missed it because it lints the workspace with --all-features;
building arr-api alone does not enable arr-subs' features.
This commit is contained in:
Miguel Palhas
2026-08-25 02:50:55 +01:00
parent 9ca3c3ce43
commit 4003c3a5a0
+4
View File
@@ -154,6 +154,7 @@ pub type Result<T> = std::result::Result<T, Error>;
/// Strip a ```` ```json ```` / ```` ``` ```` fence a model wrapped its reply
/// in despite being told not to. Cheaper than retrying the whole batch over a
/// habit some models never break.
#[cfg(any(feature = "translate-openai", feature = "translate-command"))]
pub(crate) fn strip_code_fence(content: &str) -> &str {
let trimmed = content.trim();
let trimmed = trimmed
@@ -164,6 +165,7 @@ pub(crate) fn strip_code_fence(content: &str) -> &str {
}
/// How a language reads in a prompt meant for an LLM, not a settings row.
#[cfg(any(feature = "translate-openai", feature = "translate-command"))]
pub(crate) fn language_name(language: &Language) -> String {
match language {
Language::PortuguesePortugal => "European Portuguese (pt-PT)".to_owned(),
@@ -177,6 +179,7 @@ pub(crate) fn language_name(language: &Language) -> String {
/// answering the wrong Portuguese. Generic advice ("respect the variant")
/// is easy for a model to nod at and ignore; naming the words it must not
/// reach for is not.
#[cfg(any(feature = "translate-openai", feature = "translate-command"))]
fn variant_note(target: &Language) -> Option<&'static str> {
match target {
Language::PortuguesePortugal => Some(
@@ -195,6 +198,7 @@ fn variant_note(target: &Language) -> Option<&'static str> {
/// The instruction every LLM-shaped backend sends ahead of the batch. Shared
/// rather than per-backend so the reply contract — JSON only, every cue back
/// under its original number — cannot drift between them.
#[cfg(any(feature = "translate-openai", feature = "translate-command"))]
pub(crate) fn system_prompt(source: &Language, target: &Language) -> String {
let mut prompt = format!(
"You translate subtitle cues for a film or TV episode from {} into {}. Write natural, \