compass.extraction.solar.ordinance.SolarOrdinanceTextCollector#

class SolarOrdinanceTextCollector(*args, **kwargs)[source]#

Bases: PromptBasedTextCollector

Check text chunks for ordinances and collect them if they do

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

call(sys_msg, content[, usage_sub_label])

Call LLM for structured data retrieval

check_chunk(chunk_parser, ind)

Check a chunk at a given ind to see if it contains ordinance

Attributes

OUT_LABEL

Identifier for text collected by this class

PROMPTS

Dicts defining the prompts for ordinance text collection

relevant_text

Combined ordinance text from the individual chunks

OUT_LABEL = 'relevant_text'#

Identifier for text collected by this class

PROMPTS = [{'key': 'contains_ord_info', 'label': 'contains ordinance info', 'prompt': "You extract structured data from text. Return your answer in JSON format (not markdown). Your JSON file must include exactly two  keys. The first key is 'solar_reqs', which is a string that summarizes all\nzoning, siting, setback, system design, and operational requirements/restrictions that are explicitly enacted in the legal text for solar  energy systems for a given jurisdiction. Note that solar energy bans are an important restriction to track. Include any **closely related provisions**  if they clearly pertain to the **development, operation, modification, or  removal** of solar energy systems (or solar panels). All restrictions should  be enforceable - ignore any text that only provides a legal definition of  the regulation. If the text does not specify any concrete zoning, siting, setback, system design, or operational requirements/restrictions  for a solar energy system, set this key to `null`. The last key is '{key}', which is a boolean that is set to True if the text excerpt  explicitly details zoning, siting, setback, system design, or operational requirements/restrictions for a solar energy system and False  otherwise."}, {'key': 'x', 'label': 'for utility-scale SEF', 'prompt': "\nYou are a legal scholar that reads ordinance text and determines whether it  applies to zoning, siting, setback, system design, or operational requirements/restrictions for **large solar energy systems**. Large  solar  energy systems (SES) may also be referred to as  solar panels, solar energy conversion systems (SECS), solar energy facilities (SEF), solar energy farms (SEF), solar farms (SF), utility-scale solar energy systems (USES), commercial solar energy systems (CSES), ground-mounted solar energy systems (GSES), alternate energy systems (AES), commercial energy production systems (CEPCS), or similar. Your client is a commercial solar developer that does  not care about ordinances related to CSP, private, residential, roof-mounted, micro, small, or medium sized solar energy systems.  Ignore any text related to such systems. Return your answer as a dictionary  in JSON format (not markdown). Your JSON file must include exactly two keys.  The first key is 'summary' which contains a string that summarizes the types  of solar energy systems the text applies to (if any). The second key is  '{key}', which is a boolean that is set to True if any part of the text  excerpt details zoning, siting, setback, system design, or operational requirements/restrictions for the **large solar energy conversion  systems** (or similar) that the client is interested in and False otherwise."}]#

Dicts defining the prompts for ordinance text collection

async call(sys_msg, content, usage_sub_label=LLMUsageCategory.DEFAULT)#

Call LLM for structured data retrieval

Parameters:
  • sys_msg (str) – The LLM system message. If this text does not contain the instruction text “Return your answer as a dictionary in JSON format”, it will be added.

  • content (str) – LLM call content (typically some text to extract info from).

  • usage_sub_label (str, optional) – Label to store token usage under. By default, "default".

Returns:

dict – Dictionary containing the LLM-extracted features. Dictionary may be empty if there was an error during the LLM call.

async check_chunk(chunk_parser, ind)#

Check a chunk at a given ind to see if it contains ordinance

Parameters:
  • chunk_parser (ParseChunksWithMemory) – Instance that contains a parse_from_ind method.

  • ind (int) – Index of the chunk to check.

Returns:

bool – Boolean flag indicating whether or not the text in the chunk contains large wind energy conversion system ordinance text.

property relevant_text#

Combined ordinance text from the individual chunks

Type:

str