Skip to main content

request_structured_output

Function request_structured_output 

Source
pub async fn request_structured_output(
    provider: &dyn LlmProvider,
    structured_request: &StructuredOutputRequest,
) -> Result<Value, RunnerError>
Expand description

Request structured JSON output from any provider, with schema validation and retry.

§Flow

  1. Append schema instructions to the system message
  2. Call provider.complete() and extract JSON from the response
  3. Validate against the schema
  4. On failure, append errors as user feedback and retry up to max_retries
  5. After exhaustion, return RunnerError::external_service

§Errors

Returns RunnerError if the provider fails or validation is exhausted.