Zackriya-Solutions/meetily · error · anyhow::Error

Unknown template: {}

Error message

Unknown template: {}

What it means

format_prompt supports exactly two chat templates: 'gemma3' and 'qwen3.5_nonthinking'. Any other template_name hits the catch-all arm and returns this error before any string formatting.

Source

Thrown at frontend/src-tauri/src/summary/summary_engine/models.rs:305

/// Format a prompt using the specified template
///
/// # Arguments
/// * `template_name` - Template identifier (e.g., "gemma3", "chatml", "llama3")
/// * `system_prompt` - System message (instructions for the model)
/// * `user_prompt` - User message (actual task/question)
///
/// # Returns
/// Formatted prompt string ready to send to llama-helper
pub fn format_prompt(
    template_name: &str,
    system_prompt: &str,
    user_prompt: &str,
) -> Result<String> {
    let template = match template_name {
        "gemma3" => GEMMA3_TEMPLATE,
        "qwen3.5_nonthinking" => QWEN35_NONTHINKING_TEMPLATE,
        _ => return Err(anyhow!("Unknown template: {}", template_name)),
    };

    let escaped_user_prompt = escape_user_prompt_control_markers(user_prompt);

    let formatted = template
        .replace("{system_prompt}", system_prompt)
        .replace("{user_prompt}", &escaped_user_prompt);

    Ok(formatted)
}

// ============================================================================
// Configuration Constants
// ============================================================================

/// Default max tokens for generation (increased for better summary quality)
pub const DEFAULT_MAX_TOKENS: i32 = 4096;

View on GitHub (pinned to 0281737d87)

Solutions

  1. Set the model's prompt_template to 'gemma3' or 'qwen3.5_nonthinking' (whichever matches its chat format)
  2. If adding a new model, define its template constant in models.rs and add a match arm in format_prompt before shipping the catalog entry
  3. Check for typos and case differences in the ModelDef

Example fix

// models.rs - before: new model references a template with no match arm
const MY_MODEL: ModelDef = ModelDef { name: "my-model", prompt_template: "llama3", /* ... */ };
// format_prompt -> Err("Unknown template: llama3")

// after: add the template constant and the match arm
const LLAMA3_TEMPLATE: &str = "<|system|>\n{system_prompt}<|user|>\n{user_prompt}<|assistant|>";

pub fn format_prompt(template_name: &str, system_prompt: &str, user_prompt: &str) -> Result<String> {
    let template = match template_name {
        "gemma3" => GEMMA3_TEMPLATE,
        "qwen3.5_nonthinking" => QWEN35_NONTHINKING_TEMPLATE,
        "llama3" => LLAMA3_TEMPLATE,
        _ => return Err(anyhow!("Unknown template: {}", template_name)),
    };
    // ...
}
Defensive patterns

Strategy: type-guard

Validate before calling

const SUPPORTED_TEMPLATES: &[&str] = &["gemma3", "qwen3.5_nonthinking"];
if !SUPPORTED_TEMPLATES.contains(&model.prompt_template.as_str()) {
    return Err(anyhow!("model {} needs template {:?}; supported: {:?}",
        model.name, model.prompt_template, SUPPORTED_TEMPLATES));
}

Type guard

fn is_supported_template(name: &str) -> bool {
    matches!(name, "gemma3" | "qwen3.5_nonthinking")
}

Prevention

When it happens

Trigger: A ModelDef whose prompt_template field is not one of the two supported literals is passed to format_prompt - typically after adding a new model to the catalog in models.rs without also adding its template constant and match arm.

Common situations: Extending the model catalog with a new LLM but forgetting the template; typo or wrong case in the prompt_template string; renaming a template without updating the match arms.

Related errors


AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16). Data as JSON: /api/errors/9e63d32ea6ece3b9. Report an issue: GitHub.