compass.extraction.solar.ordinance.SolarOrdinanceTextCollector#

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

Bases: StructuredLLMCaller

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

CONTAINS_ORD_PROMPT

Prompt to check if chunk contains SEF ordinance info

IS_UTILITY_SCALE_PROMPT

Prompt to check if chunk is for utility-scale SEF

contains_ord_info

Flag indicating whether text contains ordinance info

ordinance_text

Combined ordinance text from the individual chunks

CONTAINS_ORD_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 zoning, 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 wind 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."#

Prompt to check if chunk contains SEF ordinance info

IS_UTILITY_SCALE_PROMPT = "You 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."#

Prompt to check if chunk is for utility-scale SEF

async check_chunk(chunk_parser, ind)[source]#

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 solar energy farm ordinance text.

property contains_ord_info#

Flag indicating whether text contains ordinance info

Type:

bool

property ordinance_text#

Combined ordinance text from the individual chunks

Type:

str

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.