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/httpsprompt_description
- Instructions for what to extract from the textexamples
- Example data to guide the extractionconfig
- 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