2929 "If you had to make a selection when reporting the ordinance, be sure to "
3030 "list out all the other options and their conditions in the summary."
3131)
32+ _YES_NO_PROMPT = (
33+ "Please start your response with either 'Yes' or 'No' and briefly "
34+ "explain your answer."
35+ )
3236_UNITS_IN_SUMMARY_PROMPT = (
3337 "Also include any clarifications about the units in the summary."
3438)
@@ -71,6 +75,7 @@ def setup_graph_no_nodes(d_tree_name="Unknown Decision Tree", **kwargs):
7175 return nx .DiGraph (
7276 SECTION_PROMPT = _SECTION_PROMPT ,
7377 SUMMARY_PROMPT = _SUMMARY_PROMPT ,
78+ YES_NO_PROMPT = _YES_NO_PROMPT ,
7479 UNITS_IN_SUMMARY_PROMPT = _UNITS_IN_SUMMARY_PROMPT ,
7580 _d_tree_name = d_tree_name ,
7681 ** kwargs ,
@@ -194,8 +199,7 @@ def setup_base_setback_graph(**kwargs):
194199 "{system_size_reminder}" # expected to end in space
195200 "Don't forget to pay extra attention to clarifying text found "
196201 "in parentheses and footnotes. "
197- "Please start your response with either 'Yes' or 'No' and briefly "
198- "explain your answer."
202+ "{YES_NO_PROMPT}"
199203 '\n \n """\n {text}\n """'
200204 ),
201205 )
@@ -208,8 +212,7 @@ def setup_base_setback_graph(**kwargs):
208212 prompt = (
209213 "Did you infer your answer based on setback requirements from "
210214 "something other than {feature}, such as {ignore_features}? "
211- "Please start your response with either 'Yes' or 'No' and briefly "
212- "explain your answer."
215+ "{YES_NO_PROMPT}"
213216 ),
214217 )
215218 if "roads" in kwargs .get ("feature" , "" ):
@@ -222,8 +225,8 @@ def setup_base_setback_graph(**kwargs):
222225 "check_if_property_line" ,
223226 prompt = (
224227 "Is this requirement better classified as a setback from "
225- "property lines? Please start your response with "
226- "either 'Yes' or 'No' and briefly explain your answer. "
228+ "property lines? "
229+ "{YES_NO_PROMPT} "
227230 ),
228231 )
229232 G .add_edge (
@@ -272,8 +275,7 @@ def setup_participating_owner(**kwargs):
272275 "related to {ignore_features}. "
273276 "Please only consider setbacks that would apply for "
274277 "{system_size_reminder}"
275- "Please start your response with either 'Yes' or 'No' "
276- "and briefly explain your answer."
278+ "{YES_NO_PROMPT}"
277279 ),
278280 )
279281 G .add_edge ("init" , "waiver" , condition = llm_response_starts_with_yes )
@@ -283,8 +285,7 @@ def setup_participating_owner(**kwargs):
283285 "Does the ordinance allow **participating** {owned_type} owners "
284286 "to completely waive or reduce by an unspecified amount the "
285287 "{feature} setbacks requirements? "
286- "Please start your response with either 'Yes' or 'No' and "
287- "briefly explain your answer."
288+ "{YES_NO_PROMPT}"
288289 ),
289290 )
290291
@@ -295,8 +296,7 @@ def setup_participating_owner(**kwargs):
295296 "Does the ordinance for {feature} setbacks explicitly specify "
296297 "that **participating** {owned_type} owners must abide to the "
297298 "same setbacks as **non-participating** {owned_type} owners? "
298- "Please start your response with either 'Yes' or 'No' and "
299- "briefly explain your answer."
299+ "{YES_NO_PROMPT}"
300300 ),
301301 )
302302
@@ -327,8 +327,7 @@ def setup_participating_owner(**kwargs):
327327 "Does the ordinance for {feature} setbacks explicitly specify "
328328 "a **numerical** value that applies to **participating** "
329329 "{owned_type} owners? "
330- "Please start your response with either 'Yes' or 'No' and "
331- "briefly explain your answer."
330+ "{YES_NO_PROMPT}"
332331 ),
333332 )
334333 G .add_edge ("part" , "non_part" , condition = llm_response_starts_with_yes )
@@ -402,8 +401,7 @@ def setup_graph_extra_restriction(is_numerical=True, **kwargs):
402401 "{system_size_reminder}\n "
403402 "4) Pay close attention to clarifying details in parentheses, "
404403 "footnotes, or additional explanatory text.\n "
405- "5) Please start your response with either 'Yes' or 'No' and "
406- "briefly explain your answer."
404+ "5) {YES_NO_PROMPT}"
407405 '\n \n """\n {text}\n """'
408406 ),
409407 )
@@ -475,8 +473,7 @@ def setup_graph_extra_restriction(is_numerical=True, **kwargs):
475473 "{restriction} for {tech}? "
476474 "As before, focus only on {restriction} specifically for "
477475 "{system_size_reminder}"
478- "Please start your response with either 'Yes' or 'No' and "
479- "briefly explain your answer."
476+ "{YES_NO_PROMPT}"
480477 ),
481478 )
482479 G .add_edge ("enr" , "enr_text" , condition = llm_response_starts_with_yes )
@@ -494,8 +491,7 @@ def setup_graph_extra_restriction(is_numerical=True, **kwargs):
494491 "Based on your response, are you still confident that the text "
495492 "**directly** states that there are no regulations around "
496493 "{restriction} for {tech}? "
497- "Please start your response with either 'Yes' or 'No' and "
498- "briefly explain your answer."
494+ "{YES_NO_PROMPT}"
499495 ),
500496 )
501497 G .add_edge (
@@ -544,11 +540,7 @@ def _add_coverage_clarification_nodes(G): # noqa: N803
544540 G .add_edge ("init" , "is_area" , condition = llm_response_starts_with_yes )
545541 G .add_node (
546542 "is_area" ,
547- prompt = (
548- "Is the coverage reported as an area value? "
549- "Please start your response with either 'Yes' or 'No' and "
550- "briefly explain your answer."
551- ),
543+ prompt = "Is the coverage reported as an area value? {YES_NO_PROMPT}" ,
552544 )
553545 G .add_edge ("is_area" , "value" , condition = llm_response_starts_with_no )
554546 return G
@@ -562,10 +554,8 @@ def _add_land_density_clarification_nodes(G): # noqa: N803
562554 G .add_node (
563555 "correct_density_units" ,
564556 prompt = (
565- "Is the density reported as a system size **per area** "
566- "value? "
567- "Please start your response with either 'Yes' or 'No' and "
568- "briefly explain your answer."
557+ "Is the density reported as a system size **per area** value? "
558+ "{YES_NO_PROMPT}"
569559 ),
570560 )
571561 G .add_edge (
@@ -585,8 +575,7 @@ def _add_minimum_lot_size_clarification_nodes(G): # noqa: N803
585575 "correct_min_ls_units" ,
586576 prompt = (
587577 "Is the minimum lot size reported as an **area** value? "
588- "Please start your response with either 'Yes' or 'No' and "
589- "briefly explain your answer."
578+ "{YES_NO_PROMPT}"
590579 ),
591580 )
592581 G .add_edge (
@@ -604,8 +593,7 @@ def _add_maximum_lot_size_clarification_nodes(G): # noqa: N803
604593 "correct_max_ls_units" ,
605594 prompt = (
606595 "Is the maximum lot size reported as an **area** value? "
607- "Please start your response with either 'Yes' or 'No' and "
608- "briefly explain your answer."
596+ "{YES_NO_PROMPT}"
609597 ),
610598 )
611599 G .add_edge (
@@ -620,12 +608,10 @@ def _add_maximum_project_size_clarification_nodes(G): # noqa: N803
620608 G .add_node (
621609 "is_mps_area" ,
622610 prompt = (
623- "Does the project size requirement specifically provide "
624- "a system size in MW or an installation size (e.g. "
625- "maximum number of systems or maximum number of solar "
626- "panels)? "
627- "Please start your response with either 'Yes' or 'No' and "
628- "briefly explain your answer."
611+ "Does the project size requirement specifically provide a system "
612+ "size in MW or an installation size (e.g. maximum number of "
613+ "systems or maximum number of solar panels)? "
614+ "{YES_NO_PROMPT}"
629615 ),
630616 )
631617 G .add_edge (
@@ -638,8 +624,7 @@ def _add_maximum_project_size_clarification_nodes(G): # noqa: N803
638624 prompt = (
639625 "Can the project size requirement be bypassed by applying "
640626 "for a permit? "
641- "Please start your response with either 'Yes' or 'No' and "
642- "briefly explain your answer."
627+ "{YES_NO_PROMPT}"
643628 ),
644629 )
645630
@@ -658,8 +643,7 @@ def _add_maximum_turbine_height_clarification_nodes(G): # noqa: N803
658643 "Are any of the turbine height restrictions measured from a point "
659644 "other than the ground (e.g. a building height or an airspace "
660645 "level, etc.)? "
661- "Please start your response with either 'Yes' or 'No' and "
662- "briefly explain your answer."
646+ "{YES_NO_PROMPT}"
663647 ),
664648 )
665649 G .add_edge (
@@ -675,8 +659,7 @@ def _add_maximum_turbine_height_clarification_nodes(G): # noqa: N803
675659 "We are not interested in restrictions that are relative to some "
676660 "level. Does the legal text enact any turbine height restrictions "
677661 "measured from the ground? "
678- "Please start your response with either 'Yes' or 'No' and "
679- "briefly explain your answer."
662+ "{YES_NO_PROMPT}"
680663 ),
681664 )
682665
@@ -765,8 +748,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
765748 prompt = (
766749 "Is there reason to believe that this prohibition is only "
767750 "being proposed and not yet in effect? "
768- "Please start your response with either 'Yes' or 'No' "
769- "and briefly explain your answer."
751+ "{YES_NO_PROMPT}"
770752 ),
771753 )
772754 G .add_edge (
@@ -787,8 +769,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
787769 "been previously approved?\n "
788770 " - Does it only apply if some other condition is met?\n "
789771 " - etc.\n "
790- "Please start your response with either 'Yes' or 'No' "
791- "and briefly explain your answer."
772+ "{YES_NO_PROMPT}"
792773 ),
793774 )
794775 G .add_edge (
@@ -799,8 +780,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
799780 prompt = (
800781 "Does the legal text given an expiration date for the "
801782 "prohibition, moratorium, or ban? "
802- "Please start your response with either 'Yes' or 'No' "
803- "and briefly explain your answer."
783+ "{YES_NO_PROMPT}"
804784 ),
805785 )
806786 G .add_edge ("has_end_date" , "final" , condition = llm_response_starts_with_no )
@@ -815,8 +795,7 @@ def _add_prohibitions_extraction_nodes(G): # noqa: N803
815795 prompt = (
816796 f"Today is { todays_date } . Has the prohibition, "
817797 "moratorium, or ban expired? "
818- "Please start your response with either 'Yes' or 'No' "
819- "and briefly explain your answer."
798+ "{YES_NO_PROMPT}"
820799 ),
821800 )
822801 G .add_edge (
@@ -862,8 +841,8 @@ def setup_graph_permitted_use_districts(**kwargs):
862841 "Does the following legal text explicitly define districts where "
863842 "{tech} (or similar) are {use_type}? {clarifications}"
864843 "Pay extra attention to titles and clarifying text found in "
865- "parentheses and footnotes. Please start your response with "
866- "either 'Yes' or 'No' and briefly explain your answer. "
844+ "parentheses and footnotes. "
845+ "{YES_NO_PROMPT} "
867846 '\n \n """\n {text}\n """'
868847 ),
869848 )
@@ -888,8 +867,7 @@ def setup_graph_permitted_use_districts(**kwargs):
888867 "developers can site {tech} (or similar) as the primary "
889868 "use of the land/parcel/lot? Remember that this is true "
890869 "by assumption for all overlay districts. "
891- "Please start your response with either 'Yes' or 'No' and "
892- "briefly explain your answer."
870+ "{YES_NO_PROMPT}"
893871 ),
894872 )
895873 G .add_edge (
@@ -903,8 +881,7 @@ def setup_graph_permitted_use_districts(**kwargs):
903881 "Are these districts representative of locations where "
904882 "developers can site {tech} (or similar) as an accessory "
905883 "structure and/or as a secondary use of the land/parcel/lot? "
906- "Please start your response with either 'Yes' or 'No' and "
907- "briefly explain your answer."
884+ "{YES_NO_PROMPT}"
908885 ),
909886 )
910887 G .add_edge (
0 commit comments