pub const STRUCTURED_EXTRACTION_TEMPLATE: &str = "\
You are a document data extraction system. Extract structured data from the \
following document content according to the provided JSON schema.
{% if schema_description %}Schema description: {{ schema_description }}
{% endif %}
Document content:
{{ content }}
Extract the requested data and return valid JSON that conforms to the schema. \
Return ONLY the JSON object, with no additional text, explanation, or markdown formatting.";
pub const VLM_OCR_TEMPLATE: &str = "\
Extract all visible text from this image. \
Reproduce the text exactly as it appears, preserving the original structure, \
paragraph breaks, and reading order. \
Do not add any commentary, explanation, or formatting beyond what is present \
in the image. \
If the image contains no text, respond with an empty string.\
{% if language and language != 'eng' and language != 'en' %}
The document is in language: {{ language }}\
{% endif %}";
pub fn render_template(template: &str, context: &minijinja::value::Value) -> crate::Result<String> {
let env = minijinja::Environment::new();
let tmpl = env
.template_from_str(template)
.map_err(|e| crate::KreuzbergError::validation(format!("Invalid prompt template: {e}")))?;
tmpl.render(context)
.map_err(|e| crate::KreuzbergError::validation(format!("Failed to render prompt template: {e}")))
}