Skip to main content

extract

Function extract 

Source
pub fn extract<T: DeserializeOwned>(raw: &str) -> Result<T>
Expand description

Pull the first valid JSON object of type T out of raw model output.

Handles (in order):

  1. blocks emitted by reasoning models
  2. json ... and ... markdown fences
  3. Leading prose before the opening brace
  4. Trailing text or a second JSON object after the first closes