extract

Function extract 

Source
pub async fn extract(
    text_or_documents: &str,
    prompt_description: Option<&str>,
    examples: &[ExampleData],
    config: ExtractConfig,
) -> LangExtractResult<AnnotatedDocument>
Expand description

Main extraction function that mirrors the Python API

Extracts structured information from text using a language model based on the provided examples and configuration.

§Arguments

  • text_or_documents - The source text to extract information from, or a URL starting with http/https
  • prompt_description - Instructions for what to extract from the text
  • examples - Example data to guide the extraction
  • config - Configuration parameters for the extraction

§Returns

An AnnotatedDocument with the extracted information

§Errors

Returns an error if:

  • Examples are empty
  • No API key is provided
  • URL download fails
  • Language model inference fails