agrag.ingestion.extract.BAMLExtractor
BAMLExtractor(*, settings:ExtractionLLMSettings | None = None, client:object | None = None, tracer:Tracer | None = None, include_heading_path:bool = True) -> None
Bases: Extractor
Extract entities and relations with an LLM through a typed BAML function.
The extractor calls ExtractEntitiesAndRelations on the clients in
ExtractionLLMSettings and retries failed calls with the backoff from
its configuration. The response type comes from the graph schema, so the
model can return only declared labels and property keys, and it can fill
entity properties. Needs the llm extra and a reachable LLM endpoint.
Parameters:
- settings (
ExtractionLLMSettings | None) – LLM client configuration. Defaults toExtractionLLMSettings(), loaded from the environment or.env. Ignored whenclientis given. An injected client also disablessettings.retrybecause its caller owns retry behavior. - client (
object | None) – An already-built BAML client exposingExtractEntitiesAndRelations. - tracer (
Tracer | None) – Opensagrag.extraction.bamlandagrag.llm.callspans.Noneopens no recorded span. - include_heading_path (
bool) – Whether to pass the chunk's heading path as a separatesectionline. Offsets still indexchunk.text; only this extractor uses heading context.
Functions:
- extract – Extract with an LLM call through the configured ClientRegistry.
Attributes:
- settings –
extract
extract(chunk:Chunk, schema:GraphSchema) -> ExtractionResult
Extract with an LLM call through the configured ClientRegistry.
Parameters:
- chunk (
Chunk) – The chunk to read. Onlychunk.textandchunk.idare used. - schema (
GraphSchema) – The entity and relation types to extract.
Returns:
ExtractionResult– The normalized entities and relations found in the chunk.
Raises:
ExtractorMissingExtraError– Thellmpackage extra is not installed.ValueError–chunk.idisNone.
settings
settings = settings