Skip to main content

load_examples

Function load_examples 

Source
pub fn load_examples(path: Option<&Path>, validate: bool) -> Result<String>
Expand description

Loads few-shot examples for a prompt.

path is a directory (every *.json inside it) or a glob pattern. Each example is wrapped in ---BEGIN <stem>--- / ---END <stem>--- markers so the model can tell where one ends and the next begins, and files are read in sorted order so the prompt is byte-stable across runs.

A path that matches nothing yields an empty string: examples are an optimization, and a missing directory should not take an agent down.

ยงErrors

With validate set, returns Error::Catalog if an example is not valid JSON.