Spaces:
Build error
Build error
fix: add info on unused documents
Browse filesFormer-commit-id: 2723beb529ea4a60f16344e3cf4b036ee1e60970 [formerly f160c54bcb76a16803b59a641252bd44f3dedcb1]
Former-commit-id: 8ca6a279a0c088afc3e96a0141cd5682acb9d84f
- app.py +2 -2
- planning_ai/document.py +10 -6
- planning_ai/nodes/reduce_node.py +11 -1
- planning_ai/states.py +2 -0
app.py
CHANGED
@@ -136,7 +136,7 @@ if st.session_state["completed"]:
|
|
136 |
col1, col2 = st.columns(2, border=True)
|
137 |
with col1:
|
138 |
with open(summaries_path, "rb") as pdf_file:
|
139 |
-
st.markdown("**
|
140 |
st.download_button(
|
141 |
label=f"{rep}",
|
142 |
data=pdf_file,
|
@@ -146,7 +146,7 @@ if st.session_state["completed"]:
|
|
146 |
)
|
147 |
with col2:
|
148 |
with open(report_path, "rb") as pdf_file:
|
149 |
-
st.markdown("**
|
150 |
st.download_button(
|
151 |
label=f"{rep}",
|
152 |
data=pdf_file,
|
|
|
136 |
col1, col2 = st.columns(2, border=True)
|
137 |
with col1:
|
138 |
with open(summaries_path, "rb") as pdf_file:
|
139 |
+
st.markdown("**Executive Report Download**")
|
140 |
st.download_button(
|
141 |
label=f"{rep}",
|
142 |
data=pdf_file,
|
|
|
146 |
)
|
147 |
with col2:
|
148 |
with open(report_path, "rb") as pdf_file:
|
149 |
+
st.markdown("**Represtations Summary Download**")
|
150 |
st.download_button(
|
151 |
label=f"{rep}",
|
152 |
data=pdf_file,
|
planning_ai/document.py
CHANGED
@@ -332,16 +332,17 @@ def build_final_report(out, rep):
|
|
332 |
This report was produced using a generative pre-trained transformer (GPT) large-language model (LLM) to produce an abstractive summary of all responses to the related planning application. This model automatically reviews every response in detail, and extracts key information to inform decision making. This document first consolidates this information into a single-page executive summary, highlighting areas of particular interest to consider, and the broad consensus of responses. Figures generated from responses then give both a geographic and statistical overview, highlighting any demographic imbalances in responses. The document then extracts detailed information from responses, grouped by theme and policy. In this section we incorporate citations which relate with the 'Summary Responses' document, to increase transparency.
|
333 |
"""
|
334 |
figures_paragraph = r"""
|
335 |
-
This section describes the characteristics of where submissions were received from. This can help to identify how representative submissions were and whether there were any communities whose views were not being considered. \ref{fig-wards} shows the number (frequency) of submitted representations by Ward based on the address attached to the submission. To interpret the figure, areas which are coloured white had no submissions from residents, and then areas are coloured in based on the total number of submissions with yellows and greens representing the largest numbers. This figure helps to identify which Wards are more active in terms of participation and representation in this report.
|
336 |
|
337 |
-
|
338 |
|
339 |
-
|
340 |
"""
|
341 |
themes_paragraph = """
|
342 |
The following section provides a detailed breakdown of notable details from responses, grouped by themes and policies. Both themes and associated policies are automatically determined through an analysis of the summary content by an LLM agent. Each theme is grouped by whether a responses is supporting, opposed, or a general comment. This section aims to give a comprehensive view of the key issues raised by the respondents with respect to the themes and policies outlined. We have incorporated citations into eac hpoint (see numbers in square brackets) which relate to the specific document they were made in, to promote the transparency of where information was sourced from. @tbl-themes gives a breakdown of the number of submissions that relate with each theme, submissions may relate to more than one theme.
|
343 |
"""
|
344 |
final = out["generate_final_report"]
|
|
|
345 |
support_policies, object_policies, other_policies = _process_policies(final)
|
346 |
postcodes = _process_postcodes(final)
|
347 |
stances = _process_stances(final)
|
@@ -370,9 +371,9 @@ The following section provides a detailed breakdown of notable details from resp
|
|
370 |
f"{introduction_paragraph}\n\n"
|
371 |
"\n# Profile of Submissions\n\n"
|
372 |
f"{figures_paragraph}\n\n"
|
373 |
-
f"\n\n"
|
374 |
-
f"\n\n"
|
375 |
-
f"\n\n"
|
376 |
r"\newpage"
|
377 |
"\n\n# Themes and Policies\n\n"
|
378 |
f"{themes_paragraph}\n\n"
|
@@ -389,6 +390,9 @@ The following section provides a detailed breakdown of notable details from resp
|
|
389 |
"The following section presents a list of all points raised in representations that do not support "
|
390 |
"or object to the plan, grouped by theme and policy.\n\n"
|
391 |
f"{other_policies or '_No other representations._'}\n\n"
|
|
|
|
|
|
|
392 |
)
|
393 |
|
394 |
out_path = Paths.SUMMARY / f"Summary_of_Submitted_Responses-{rep}.md"
|
|
|
332 |
This report was produced using a generative pre-trained transformer (GPT) large-language model (LLM) to produce an abstractive summary of all responses to the related planning application. This model automatically reviews every response in detail, and extracts key information to inform decision making. This document first consolidates this information into a single-page executive summary, highlighting areas of particular interest to consider, and the broad consensus of responses. Figures generated from responses then give both a geographic and statistical overview, highlighting any demographic imbalances in responses. The document then extracts detailed information from responses, grouped by theme and policy. In this section we incorporate citations which relate with the 'Summary Responses' document, to increase transparency.
|
333 |
"""
|
334 |
figures_paragraph = r"""
|
335 |
+
This section describes the characteristics of where submissions were received from. This can help to identify how representative submissions were and whether there were any communities whose views were not being considered. Figure \ref{fig-wards} shows the number (frequency) of submitted representations by Ward based on the address attached to the submission. To interpret the figure, areas which are coloured white had no submissions from residents, and then areas are coloured in based on the total number of submissions with yellows and greens representing the largest numbers. This figure helps to identify which Wards are more active in terms of participation and representation in this report.
|
336 |
|
337 |
+
Figure \ref{fig-oas} displays the percentage of representations submitted by the Output Area Classification (2021). The Output Area Classification is the Office for National Statistics preferred classification of neighbourhoods. This measure groups neighbourhoods (here defined as Output Areas, typically containing 100 people) into categories that capture similar types of people based on population, demographic and socioeconomic characteristics. It therefore provides an insightful view of the types of communities who submitted representations. To interpret the figure, where bars extend higher/upwards, this represents a larger population share within a specific area type. The blue bars represent the characteristics of who submitted representations, and the orange bars represent the underlying population – allowing one to compare whether the profile of submissions matched the characteristics of the local population. This figure uses OAC 'Supergroups', which are the highest level of the hierarchy, and provide information relative to the average values for the UK population at large.
|
338 |
|
339 |
+
Figure \ref{fig-imd} shows the percentage of responses by level of neighbourhood socioeconomic deprivation. The information is presented using the 2019 Index of Multiple Deprivation, divided into quintiles (i.e., dividing the English population into equal fifths). This measure is the UK Government’s preferred measure of socioeconomic deprivation and is based on information about income, employment, education, health, crime, housing and the local environment for small areas (Lower Super Output Areas, typically containing 1600 people). To interpret the graph, bars represent the share of population from each quintile. Quintile 1 represents the most deprived 20% of areas, and quintile 5 the least deprived 20% of areas. The orange bars represent the distribution of people who submitted representations (i.e., larger bars mean that more people from these areas submitted representations). The blue bars show the distribution of the local population, allowing one to evaluate whether the evidence submitted was from the same communities in the area.
|
340 |
"""
|
341 |
themes_paragraph = """
|
342 |
The following section provides a detailed breakdown of notable details from responses, grouped by themes and policies. Both themes and associated policies are automatically determined through an analysis of the summary content by an LLM agent. Each theme is grouped by whether a responses is supporting, opposed, or a general comment. This section aims to give a comprehensive view of the key issues raised by the respondents with respect to the themes and policies outlined. We have incorporated citations into eac hpoint (see numbers in square brackets) which relate to the specific document they were made in, to promote the transparency of where information was sourced from. @tbl-themes gives a breakdown of the number of submissions that relate with each theme, submissions may relate to more than one theme.
|
343 |
"""
|
344 |
final = out["generate_final_report"]
|
345 |
+
unused_documents = out["generate_final_report"]["unused_documents"]
|
346 |
support_policies, object_policies, other_policies = _process_policies(final)
|
347 |
postcodes = _process_postcodes(final)
|
348 |
stances = _process_stances(final)
|
|
|
371 |
f"{introduction_paragraph}\n\n"
|
372 |
"\n# Profile of Submissions\n\n"
|
373 |
f"{figures_paragraph}\n\n"
|
374 |
+
f"\n\n"
|
375 |
+
f"\n\n"
|
376 |
+
f"\n\n"
|
377 |
r"\newpage"
|
378 |
"\n\n# Themes and Policies\n\n"
|
379 |
f"{themes_paragraph}\n\n"
|
|
|
390 |
"The following section presents a list of all points raised in representations that do not support "
|
391 |
"or object to the plan, grouped by theme and policy.\n\n"
|
392 |
f"{other_policies or '_No other representations._'}\n\n"
|
393 |
+
"## Unused Documents\n\n"
|
394 |
+
"Please note that the following documents were not used to produce this report:\n\n"
|
395 |
+
f"{str(unused_documents)}"
|
396 |
)
|
397 |
|
398 |
out_path = Paths.SUMMARY / f"Summary_of_Submitted_Responses-{rep}.md"
|
planning_ai/nodes/reduce_node.py
CHANGED
@@ -130,6 +130,11 @@ def generate_final_report(state: OverallState):
|
|
130 |
|
131 |
def final_output(final_docs):
|
132 |
docs = [doc for doc in final_docs if not doc["failed"]]
|
|
|
|
|
|
|
|
|
|
|
133 |
docs = add_doc_id(docs)
|
134 |
|
135 |
policy_groups = extract_policies_from_docs(docs)
|
@@ -139,4 +144,9 @@ def final_output(final_docs):
|
|
139 |
executive = reduce_chain_final.invoke(
|
140 |
{"context": "Executive Report:\n\n".join(batch_executive)}
|
141 |
)
|
142 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
def final_output(final_docs):
|
132 |
docs = [doc for doc in final_docs if not doc["failed"]]
|
133 |
+
|
134 |
+
# TODO: say which docs are not considered in the final report
|
135 |
+
failed_docs = [
|
136 |
+
doc["document"].metadata["filename"] for doc in final_docs if doc["failed"]
|
137 |
+
]
|
138 |
docs = add_doc_id(docs)
|
139 |
|
140 |
policy_groups = extract_policies_from_docs(docs)
|
|
|
144 |
executive = reduce_chain_final.invoke(
|
145 |
{"context": "Executive Report:\n\n".join(batch_executive)}
|
146 |
)
|
147 |
+
return {
|
148 |
+
"executive": executive,
|
149 |
+
"documents": docs,
|
150 |
+
"policies": policies,
|
151 |
+
"unused_documents": failed_docs,
|
152 |
+
}
|
planning_ai/states.py
CHANGED
@@ -31,4 +31,6 @@ class OverallState(TypedDict):
|
|
31 |
executive: str
|
32 |
policies: pl.DataFrame
|
33 |
|
|
|
|
|
34 |
n_docs: int
|
|
|
31 |
executive: str
|
32 |
policies: pl.DataFrame
|
33 |
|
34 |
+
unused_documents: list[int]
|
35 |
+
|
36 |
n_docs: int
|