Skip to main content

request_structured_json

Function request_structured_json 

Source
pub async fn request_structured_json<T: DeserializeOwned>(
    input: Vec<APIInputMessage>,
    model: String,
    params: LLMRequestParams,
    max_output_tokens: Option<i32>,
    format: LLMRequestResponseFormatParam,
    app_config: &ApplicationConfiguration,
    on_invalid_response: impl FnOnce() -> ChatbotError,
) -> ChatbotResult<T>
Expand description

Sends input as a one-shot structured-JSON request and deserializes the reply as T.

on_invalid_response builds the error raised when the reply doesn’t parse as T, so each caller can raise its own ChatbotErrorType and wording for that failure.