Skip to main content

chat_json

Function chat_json 

Source
pub async fn chat_json<T: DeserializeOwned>(
    provider: &AnyProvider,
    system: &str,
    user: &str,
    per_call_timeout: Duration,
) -> Result<(T, u64, u32), ChatJsonError>
Expand description

Call the provider and parse the JSON result, retrying once on parse failure.

Returns (value, approx_tokens, attempt_number) on success.

ยงErrors

Returns ChatJsonError if both attempts fail, the provider errors, or timeout is hit.