Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 36 additions & 59 deletions compass/common/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"If you had to make a selection when reporting the ordinance, be sure to "
"list out all the other options and their conditions in the summary."
)
_YES_NO_PROMPT = (
"Please start your response with either 'Yes' or 'No' and briefly "
"explain your answer."
)
_UNITS_IN_SUMMARY_PROMPT = (
"Also include any clarifications about the units in the summary."
)
Expand Down Expand Up @@ -71,6 +75,7 @@ def setup_graph_no_nodes(d_tree_name="Unknown Decision Tree", **kwargs):
return nx.DiGraph(
SECTION_PROMPT=_SECTION_PROMPT,
SUMMARY_PROMPT=_SUMMARY_PROMPT,
YES_NO_PROMPT=_YES_NO_PROMPT,
UNITS_IN_SUMMARY_PROMPT=_UNITS_IN_SUMMARY_PROMPT,
_d_tree_name=d_tree_name,
**kwargs,
Expand Down Expand Up @@ -194,8 +199,7 @@ def setup_base_setback_graph(**kwargs):
"{system_size_reminder}" # expected to end in space
"Don't forget to pay extra attention to clarifying text found "
"in parentheses and footnotes. "
"Please start your response with either 'Yes' or 'No' and briefly "
"explain your answer."
"{YES_NO_PROMPT}"
'\n\n"""\n{text}\n"""'
),
)
Expand All @@ -208,8 +212,7 @@ def setup_base_setback_graph(**kwargs):
prompt=(
"Did you infer your answer based on setback requirements from "
"something other than {feature}, such as {ignore_features}? "
"Please start your response with either 'Yes' or 'No' and briefly "
"explain your answer."
"{YES_NO_PROMPT}"
),
)
if "roads" in kwargs.get("feature", ""):
Expand All @@ -222,8 +225,8 @@ def setup_base_setback_graph(**kwargs):
"check_if_property_line",
prompt=(
"Is this requirement better classified as a setback from "
"property lines? Please start your response with "
"either 'Yes' or 'No' and briefly explain your answer."
"property lines? "
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand Down Expand Up @@ -272,8 +275,7 @@ def setup_participating_owner(**kwargs):
"related to {ignore_features}. "
"Please only consider setbacks that would apply for "
"{system_size_reminder}"
"Please start your response with either 'Yes' or 'No' "
"and briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge("init", "waiver", condition=llm_response_starts_with_yes)
Expand All @@ -283,8 +285,7 @@ def setup_participating_owner(**kwargs):
"Does the ordinance allow **participating** {owned_type} owners "
"to completely waive or reduce by an unspecified amount the "
"{feature} setbacks requirements? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand All @@ -295,8 +296,7 @@ def setup_participating_owner(**kwargs):
"Does the ordinance for {feature} setbacks explicitly specify "
"that **participating** {owned_type} owners must abide to the "
"same setbacks as **non-participating** {owned_type} owners? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand Down Expand Up @@ -327,8 +327,7 @@ def setup_participating_owner(**kwargs):
"Does the ordinance for {feature} setbacks explicitly specify "
"a **numerical** value that applies to **participating** "
"{owned_type} owners? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge("part", "non_part", condition=llm_response_starts_with_yes)
Expand Down Expand Up @@ -402,8 +401,7 @@ def setup_graph_extra_restriction(is_numerical=True, **kwargs):
"{system_size_reminder}\n"
"4) Pay close attention to clarifying details in parentheses, "
"footnotes, or additional explanatory text.\n"
"5) Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"5) {YES_NO_PROMPT}"
'\n\n"""\n{text}\n"""'
),
)
Expand Down Expand Up @@ -475,8 +473,7 @@ def setup_graph_extra_restriction(is_numerical=True, **kwargs):
"{restriction} for {tech}? "
"As before, focus only on {restriction} specifically for "
"{system_size_reminder}"
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge("enr", "enr_text", condition=llm_response_starts_with_yes)
Expand All @@ -494,8 +491,7 @@ def setup_graph_extra_restriction(is_numerical=True, **kwargs):
"Based on your response, are you still confident that the text "
"**directly** states that there are no regulations around "
"{restriction} for {tech}? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand Down Expand Up @@ -544,11 +540,7 @@ def _add_coverage_clarification_nodes(G): # noqa: N803
G.add_edge("init", "is_area", condition=llm_response_starts_with_yes)
G.add_node(
"is_area",
prompt=(
"Is the coverage reported as an area value? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
),
prompt="Is the coverage reported as an area value? {YES_NO_PROMPT}",
)
G.add_edge("is_area", "value", condition=llm_response_starts_with_no)
return G
Expand All @@ -562,10 +554,8 @@ def _add_land_density_clarification_nodes(G): # noqa: N803
G.add_node(
"correct_density_units",
prompt=(
"Is the density reported as a system size **per area** "
"value? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"Is the density reported as a system size **per area** value? "
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -585,8 +575,7 @@ def _add_minimum_lot_size_clarification_nodes(G): # noqa: N803
"correct_min_ls_units",
prompt=(
"Is the minimum lot size reported as an **area** value? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -604,8 +593,7 @@ def _add_maximum_lot_size_clarification_nodes(G): # noqa: N803
"correct_max_ls_units",
prompt=(
"Is the maximum lot size reported as an **area** value? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -620,12 +608,10 @@ def _add_maximum_project_size_clarification_nodes(G): # noqa: N803
G.add_node(
"is_mps_area",
prompt=(
"Does the project size requirement specifically provide "
"a system size in MW or an installation size (e.g. "
"maximum number of systems or maximum number of solar "
"panels)? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"Does the project size requirement specifically provide a system "
"size in MW or an installation size (e.g. maximum number of "
"systems or maximum number of solar panels)? "
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -638,8 +624,7 @@ def _add_maximum_project_size_clarification_nodes(G): # noqa: N803
prompt=(
"Can the project size requirement be bypassed by applying "
"for a permit? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand All @@ -658,8 +643,7 @@ def _add_maximum_turbine_height_clarification_nodes(G): # noqa: N803
"Are any of the turbine height restrictions measured from a point "
"other than the ground (e.g. a building height or an airspace "
"level, etc.)? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -675,8 +659,7 @@ def _add_maximum_turbine_height_clarification_nodes(G): # noqa: N803
"We are not interested in restrictions that are relative to some "
"level. Does the legal text enact any turbine height restrictions "
"measured from the ground? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand Down Expand Up @@ -765,8 +748,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
prompt=(
"Is there reason to believe that this prohibition is only "
"being proposed and not yet in effect? "
"Please start your response with either 'Yes' or 'No' "
"and briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -787,8 +769,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
"been previously approved?\n"
" - Does it only apply if some other condition is met?\n"
" - etc.\n"
"Please start your response with either 'Yes' or 'No' "
"and briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -799,8 +780,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
prompt=(
"Does the legal text given an expiration date for the "
"prohibition, moratorium, or ban? "
"Please start your response with either 'Yes' or 'No' "
"and briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge("has_end_date", "final", condition=llm_response_starts_with_no)
Expand All @@ -815,8 +795,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
prompt=(
f"Today is {todays_date}. Has the prohibition, "
"moratorium, or ban expired? "
"Please start your response with either 'Yes' or 'No' "
"and briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand Down Expand Up @@ -862,8 +841,8 @@ def setup_graph_permitted_use_districts(**kwargs):
"Does the following legal text explicitly define districts where "
"{tech} (or similar) are {use_type}? {clarifications}"
"Pay extra attention to titles and clarifying text found in "
"parentheses and footnotes. Please start your response with "
"either 'Yes' or 'No' and briefly explain your answer."
"parentheses and footnotes. "
"{YES_NO_PROMPT}"
'\n\n"""\n{text}\n"""'
),
)
Expand All @@ -888,8 +867,7 @@ def setup_graph_permitted_use_districts(**kwargs):
"developers can site {tech} (or similar) as the primary "
"use of the land/parcel/lot? Remember that this is true "
"by assumption for all overlay districts. "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand All @@ -903,8 +881,7 @@ def setup_graph_permitted_use_districts(**kwargs):
"Are these districts representative of locations where "
"developers can site {tech} (or similar) as an accessory "
"structure and/or as a secondary use of the land/parcel/lot? "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand Down
38 changes: 14 additions & 24 deletions compass/extraction/small_wind/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def setup_graph_wes_types(**kwargs):
"system sizes? Distinctions are often made as 'small', "
"'personal', or 'private' vs 'large', 'commercial', or 'utility'. "
"Sometimes the distinction uses actual MW values. "
"Please start your response with either 'Yes' or 'No' and briefly "
"explain your answer."
"{YES_NO_PROMPT}"
'\n\n"""\n{text}\n"""'
),
)
Expand Down Expand Up @@ -68,8 +67,7 @@ def setup_graph_wes_types(**kwargs):
"medium, non-commercial, or something akin to that (i.e. "
"**not** private, micro, building-mounted and **not** large, "
"commercial, or utility-scale)? "
"Please start your response with either 'Yes' or 'No' and briefly "
"explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand All @@ -93,8 +91,7 @@ def setup_graph_wes_types(**kwargs):
"energy generation system (e.g. with the primary purpose of "
"generating electricity for use on-site, as opposed to large, "
"commercial, utility-scale, or other kinds of 'large' systems)? "
"Please start your response with either 'Yes' or 'No' and briefly "
"explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand Down Expand Up @@ -173,8 +170,7 @@ def setup_multiplier(**kwargs):
"{system_size_reminder}"
"Remember that 1 is a valid multiplier, and treat any "
"mention of 'fall zone' as a system height multiplier of 1. "
"Please start your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge("init", "no_multiplier", condition=llm_response_starts_with_no)
Expand All @@ -187,8 +183,7 @@ def setup_multiplier(**kwargs):
"related to {ignore_features}. "
"Please also only consider setbacks specifically for "
"{system_size_reminder}"
"Please start your response with either 'Yes' or "
"'No' and briefly explain your answer."
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand Down Expand Up @@ -277,9 +272,9 @@ def setup_multiplier(**kwargs):
"Do not confuse this value with static setback requirements. "
"Ignore text with clauses such as "
"'no lesser than', 'no greater than', 'the lesser of', or 'the "
"greater of'. Please start your response with either 'Yes' or "
"'No' and briefly explain your answer, stating the adder value "
"if it exists."
"greater of'. "
"{YES_NO_PROMPT} "
"State the adder value if it exists."
),
)
G.add_edge("adder", "out_no_adder", condition=llm_response_starts_with_no)
Expand All @@ -289,9 +284,8 @@ def setup_multiplier(**kwargs):
"adder_eq",
prompt=(
"Does the adder value you identified satisfy the following "
"equation: `multiplier * height + <adder>`? Please begin your "
"response with either 'Yes' or 'No' and briefly explain your "
"answer."
"equation: `multiplier * height + <adder>`? "
"{YES_NO_PROMPT}"
),
)
G.add_edge(
Expand Down Expand Up @@ -384,8 +378,7 @@ def setup_conditional_min(**kwargs):
"when a multiplier is used for the calculation? This value acts "
"like a threshold and is often found within phrases like 'the "
"greater of'. "
"Please begin your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand All @@ -396,8 +389,7 @@ def setup_conditional_min(**kwargs):
"Does the threshold value you identified satisfy the following "
"equation: "
"`setback_distance = max(<threshold>, multiplier_setback)`? "
"Please begin your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand Down Expand Up @@ -463,8 +455,7 @@ def setup_conditional_max(**kwargs):
"setback distance that must be observed in all cases, even when "
"a multiplier is used for the calculation? This value acts like "
"a limit and is often found within phrases like 'the lesser of'. "
"Please begin your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand All @@ -475,8 +466,7 @@ def setup_conditional_max(**kwargs):
"Does the limit value you identified satisfy the following "
"equation: "
"`setback_distance = min(multiplier_setback, <limit>)`? "
"Please begin your response with either 'Yes' or 'No' and "
"briefly explain your answer."
"{YES_NO_PROMPT}"
),
)

Expand Down
Loading