Skip to content

NG Plants PR - #539

Open
gokuparanjothi wants to merge 2 commits into
mainfrom
natural-gas-extraction-plugin
Open

NG Plants PR#539
gokuparanjothi wants to merge 2 commits into
mainfrom
natural-gas-extraction-plugin

Conversation

@gokuparanjothi

Copy link
Copy Markdown
Collaborator

Adds schema and plugin config for the Natural Gas Plants extraction plugin. Successfully runs collection for 4 jurisdictions and returns 21 docs, extraction is not run yet, blocked on azure endpoint access part.

@castelao castelao added enhancement Update to logic or general code improvements p-medium Priority: medium topic-python-general Issues/pull requests related to python labels Aug 26, 2026
@gokuparanjothi
gokuparanjothi marked this pull request as draft August 26, 2026 15:46
Comment on lines +93 to +235
collection_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 'gas_gen_reqs', which is a string that summarizes all
zoning, siting, setback, design, and operational
requirements/restrictions that are explicitly enacted in the text
for a natural gas-fired electric generating facility (or power plant)
for a given jurisdiction. Note that outright bans are an important
restriction to track. Requirements that apply to the facility through a
general zoning district (such as heavy industrial) count, even if the
text never names natural gas generation specifically. Include any
**closely related provisions** if they clearly pertain to the
**development, operation, modification, or removal** of an electric
generating facility. 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, design, or
operational requirements/restrictions for an electric generating facility,
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,
design, or operational requirements/restrictions for an electric generating
facility and False otherwise.

- key: x
label: for gas-fired generation
prompt: |-
You are a legal scholar that reads ordinance text and determines whether
any of it applies to zoning, siting, setback, design, or operational
requirements/restrictions for **natural gas-fired electric generating
facilities**. These may also be referred to as gas-fired electric
generating facilities, electric generating plants, electric generation
facilities, power plants, power generating facilities, energy generation
facilities, combined cycle plants, simple cycle plants, peaking plants,
cogeneration facilities, or public utility facilities. Your client is a
developer of utility-scale natural gas generation that sells power
offsite. Your client does NOT care about ordinances related to: natural
gas extraction, drilling, or well operations; pipelines, compressor
stations, metering stations, or gas storage; LNG or CNG facilities
including fueling stations; propane distribution; gas service lines,
meters, or appliances within buildings; or emergency, standby, or backup
generators serving a single onsite building. Ignore any text related to
such uses. Note that many jurisdictions regulate these facilities only
through general zoning districts such as heavy industrial rather than
through a technology-specific section - such text IS relevant and should
be treated as applying to the client. 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 lists all of
the types of facilities or uses 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, design, or operational
requirements/restrictions for the **natural gas-fired electric generating
facilities** (or similar) that the client is interested in and False
otherwise.

text_extraction_prompts:
- key: gas_generation_text
out_fn: "{jurisdiction} Gas Generation Ordinance.txt"
prompt: |-
# CONTEXT #
We want to reduce the provided excerpt to only contain information about
**electric generating facilities**. The extracted text will be used for
structured data extraction, so it must be both **comprehensive** (retaining
all relevant details) and **focused** (excluding unrelated content), with
**zero rewriting or paraphrasing**. Ensure that all retained information is
**directly applicable to electric generating facilities** while preserving
full context and accuracy.

# OBJECTIVE #
Extract all text **pertaining to electric generating facilities** from the provided excerpt.

# RESPONSE #
Follow these guidelines carefully:

1. ## Scope of Extraction ##:
- Include all text that pertains to **electric generating facilities or power plants**.
- Include zoning district tables and setback tables that would apply to such a facility, even where the facility is not named explicitly.
- Explicitly include any text related to **bans or prohibitions** on electric generating facilities.
- Explicitly include any text related to the adoption or enactment date of the ordinance (if any).

2. ## Exclusions ##:
- Do **not** include text that does not pertain to electric generating facilities.

3. ## Formatting & Structure ##:
- **Preserve _all_ section titles, headers, and numberings** for reference.
- **Maintain the original wording, formatting, and structure** to ensure accuracy.

4. ## Output Handling ##:
- This is a strict extraction task — act like a text filter, **not** a summarizer or writer.
- Do not add, explain, reword, or summarize anything.
- The output must be a **copy-paste** of the original excerpt. **Absolutely no paraphrasing or rewriting.**
- The output must consist **only** of contiguous or discontiguous verbatim blocks copied from the input.
- If **no relevant text** is found, return the response: 'No relevant text.'

- key: cleaned_text_for_extraction
out_fn: "{jurisdiction} Natural Gas Generation Ordinance.txt"
prompt: |-
# CONTEXT #
We want to reduce the provided excerpt to only contain information about
**natural gas-fired electric generating facilities**. The extracted text
will be used for structured data extraction, so it must be both
**comprehensive** (retaining all relevant details) and **focused**
(excluding unrelated content), with **zero rewriting or paraphrasing**.

# OBJECTIVE #
Extract all text **pertaining to natural gas-fired electric generating facilities** from the provided excerpt.

# RESPONSE #
Follow these guidelines carefully:

1. ## Scope of Extraction ##:
- Include all text that pertains to **electric generating facilities**, even if referred to by different names such as: gas-fired electric generating facilities, electric generating plants, electric generation facilities, power plants, power generating facilities, energy generation facilities, combined cycle plants, simple cycle plants, peaking plants, cogeneration facilities, or public utility facilities.
- Include zoning district requirements and setback tables that apply to the district in which such a facility is permitted, even where the facility is not named explicitly in the table.
- Explicitly include any text related to **bans or prohibitions** on electric generating facilities.
- Explicitly include any text related to the adoption or enactment date of the ordinance (if any).
- **Retain all relevant technical, design, operational, safety, environmental, and infrastructure-related provisions** that apply to the topic, such as (but not limited to):
- Compliance with legal or regulatory standards.
- Site, structural, or design specifications.
- Noise, air quality, and water use provisions.
- Environmental impact considerations.
- Safety and risk mitigation measures.
- Infrastructure, implementation, operation, and maintenance details.
- All other **closely related provisions**.

2. ## Exclusions ##:
- Do **not** include text that applies **only** to natural gas extraction, drilling, or well operations.
- Do **not** include text that applies **only** to pipelines, compressor stations, metering stations, or gas storage.
- Do **not** include text that applies **only** to LNG, CNG, or propane facilities, including fueling stations.
- Do **not** include text that applies **only** to gas service lines, meters, or appliances within buildings.
- Do **not** include text that applies **only** to emergency, standby, or backup generators serving a single onsite building.
- Do **not** include text that does not pertain at all to electric generating facilities.

3. ## Formatting & Structure ##:
- **Preserve _all_ section titles, headers, and numberings** for reference.
- **Maintain the original wording, formatting, and structure** to ensure accuracy.

4. ## Output Handling ##:
- This is a strict extraction task — act like a text filter, **not** a summarizer or writer.
- Do not add, explain, reword, or summarize anything.
- The output must be a **copy-paste** of the original excerpt. **Absolutely no paraphrasing or rewriting.**
- The output must consist **only** of contiguous or discontiguous verbatim blocks copied from the input.
- If **no relevant text** is found, return the response: 'No relevant text.'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite surprised that you needed to include these in a first pass. Can you please try just setting collection_prompts: True and leaving text_extraction_prompts out of the config completely? Then, if you see poor performance, we can add these back in slowly

- "gas line"

collection_prompts: true
text_extraction_prompts: true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would run some tests without this option as well TBH. Maybe compare a run with and without and see what performs better

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this performs better for now. It returned a .csv for Linn County that matches very well with what interns pulled. only one value is different and i think Compass maybe more right than the interns' on that. other 3 counties are returning a blank and i am investigating

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah so when i remove collection prompts and text extraction prompts line, it collects more documents but quality is bad, gets me solar data

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I mean without the text_extraction_prompts: true option. I do think having collection_prompts: true is good and its great to hear that this is in line with the behavior you saw

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.11%. Comparing base (b0afba3) to head (c0a76c1).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #539      +/-   ##
==========================================
+ Coverage   63.98%   65.11%   +1.13%     
==========================================
  Files          78       78              
  Lines        7446     7490      +44     
  Branches      755      754       -1     
==========================================
+ Hits         4764     4877     +113     
+ Misses       2523     2453      -70     
- Partials      159      160       +1     
Flag Coverage Δ
unittests 65.11% <ø> (+1.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gokuparanjothi
gokuparanjothi marked this pull request as ready for review August 27, 2026 16:06
@gokuparanjothi

Copy link
Copy Markdown
Collaborator Author

Extraction works now after switching to auto-generated prompts. Linn County returns 35 rows and matches our interns' hand-extraction on most values. Investigating other counties' non-results

@ppinchuk

Copy link
Copy Markdown
Collaborator

Extraction works now after switching to auto-generated prompts. Linn County returns 35 rows and matches our interns' hand-extraction on most values. Investigating other counties' non-results

Excellent! I made one more comment, and also let's get the linter issue fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Update to logic or general code improvements p-medium Priority: medium topic-python-general Issues/pull requests related to python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants