
Call a provider, validate JSON output, retry on failure
Source:R/vlm-validate.R
validate_or_retry.RdSends prompt to provider, parses the response as
JSON, and validates it against schema (a short schema name
resolved via load_schema). If validation fails, the
error message is appended to the prompt and the call is retried
up to max_retries times.
Arguments
- provider
An
ellmerchat object (fromvlm_provider) or aMockVLMProviderinstance. Must expose a$chat(prompt, ...)method returning text (or a character vector of length 1).- prompt
Character scalar with the initial prompt.
- schema
Short schema name (
"horizon","site").- max_retries
Integer; total attempts will be at most
1 + max_retries.- image
Optional
ellmerimage content object (e.g. fromellmer::content_image_file) to pass alongside the prompt for multimodal calls.