Skip to main content

parse_messages_oaicompat

Function parse_messages_oaicompat 

Source
pub fn parse_messages_oaicompat(
    messages_json: &str,
) -> Result<String, ChatError>
Expand description

Validate and normalise an OpenAI-shaped messages array.

Expands the shorthands llama.cpp accepts — typed content parts, legacy function_call — into the canonical form, and rejects malformed input before it reaches a template.

§Errors

Returns ChatError::BadJson if the input is not valid JSON, or ChatError::Failed if it is not a valid message array.