compass.plugin.ordinance.BaseTextExtractor#

class BaseTextExtractor(llm_service, usage_tracker=None, **kwargs)[source]#

Bases: BaseLLMCaller, ABC

Extract succinct extraction text from input

Parameters:
  • llm_service (Service) – LLM service used for queries.

  • usage_tracker (UsageTracker, optional) – Optional tracker instance to monitor token usage during LLM calls. By default, None.

  • **kwargs

    Keyword arguments to be passed to the underlying service processing function (i.e. llm_service.call(**kwargs)). Should not contain the following keys:

    • usage_sub_label

    • messages

    These arguments are provided by this caller object.

Methods

Attributes

IN_LABEL

Identifier for text ingested by this class

OUT_LABEL

Identifier for final text extracted by this class

TASK_DESCRIPTION

Task description to show in progress bar

TASK_ID

ID to use for this extraction for linking with LLM configs

parsers

Generator of (key, extractor) pairs

TASK_DESCRIPTION = 'Condensing text for extraction'#

Task description to show in progress bar

TASK_ID = 'text_extraction'#

ID to use for this extraction for linking with LLM configs

abstract property IN_LABEL#

Identifier for text ingested by this class

Type:

str

abstract property OUT_LABEL#

Identifier for final text extracted by this class

Type:

str

abstract property parsers#

Generator of (key, extractor) pairs

extractor should be an async callable that accepts a list of text chunks and returns the shortened (succinct) text to be used for extraction. The key should be a string identifier for the text returned by the extractor. Multiple (key, extractor) pairs can be chained in generator order to iteratively refine the text for extraction.

Type:

Generator