Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -894,7 +894,7 @@ Only output valid JSON with no comments or code fences."""
|
|
| 894 |
prompt_refs = (
|
| 895 |
f"\nYou are a technical editor.\n\n"
|
| 896 |
"Review the following updated report HTML. If any new inline citations (e.g., [x]) have been added that are not in the original reference table,\n"
|
| 897 |
-
"generate an updated
|
| 898 |
f"Updated Report HTML:\n{updated_report_html}"
|
| 899 |
)
|
| 900 |
# Increase token limit to 1500 for this call
|
|
@@ -903,7 +903,7 @@ Only output valid JSON with no comments or code fences."""
|
|
| 903 |
|
| 904 |
if updated_refs and not updated_refs.lower().startswith("error: empty response"):
|
| 905 |
soup_updated = BeautifulSoup(updated_report_html, "html.parser")
|
| 906 |
-
ref_heading = soup_updated.find(lambda tag: tag.name in ["h1", "h2", "h3", "h4"] and "
|
| 907 |
if ref_heading:
|
| 908 |
next_sibling = ref_heading.find_next_sibling()
|
| 909 |
if next_sibling:
|
|
@@ -1088,7 +1088,7 @@ Only output valid JSON.
|
|
| 1088 |
prompt_adjust = (f"""
|
| 1089 |
You are a technical editor.
|
| 1090 |
Given the following HTML container (including its outer tags) extracted from a larger report and based on the user expansion request, produce an expanded version by elaborating on the content.
|
| 1091 |
-
Preserve all inline citations (formatted as [x]) and ensure that if you add any new citations, they are consistent with sources that must also be reflected in the final
|
| 1092 |
Skip lines occasionally to improve readability.
|
| 1093 |
The expanded version will be put back in the exact same location and must maintain the outer HTML tags.
|
| 1094 |
|
|
@@ -1108,7 +1108,7 @@ Additional Guidance:
|
|
| 1108 |
- Complementary Guidance:
|
| 1109 |
{complementary_guidance}
|
| 1110 |
|
| 1111 |
-
Ensure that any inline citation (e.g., [1], [2], etc.) within the expanded content is preserved or newly included so they can all be captured in the final
|
| 1112 |
|
| 1113 |
Output a JSON object with exactly two keys:
|
| 1114 |
- "expanded" (the expanded container's full HTML)
|
|
@@ -1140,11 +1140,11 @@ Only output valid JSON with no comments or code fences.
|
|
| 1140 |
|
| 1141 |
updated_report_html = str(soup)
|
| 1142 |
|
| 1143 |
-
# Step 5 (and 6): Update the
|
| 1144 |
prompt_refs = (
|
| 1145 |
f"\nYou are a technical editor.\n\n"
|
| 1146 |
"Review the following updated report HTML. If any new inline citations (e.g., [x]) have been added that are not in the original reference table, "
|
| 1147 |
-
"generate an updated
|
| 1148 |
" Every inline citation found in the report must have a corresponding entry in this table. "
|
| 1149 |
"Output only the updated table without any additional comments.\n\n"
|
| 1150 |
f"Updated Report HTML:\n{updated_report_html}"
|
|
@@ -1155,7 +1155,7 @@ Only output valid JSON with no comments or code fences.
|
|
| 1155 |
|
| 1156 |
if updated_refs and not updated_refs.lower().startswith("error: empty response"):
|
| 1157 |
soup_updated = BeautifulSoup(updated_report_html, "html.parser")
|
| 1158 |
-
ref_heading = soup_updated.find(lambda tag: tag.name in ["h1", "h2", "h3", "h4"] and "
|
| 1159 |
if ref_heading:
|
| 1160 |
next_sibling = ref_heading.find_next_sibling()
|
| 1161 |
if next_sibling:
|
|
|
|
| 894 |
prompt_refs = (
|
| 895 |
f"\nYou are a technical editor.\n\n"
|
| 896 |
"Review the following updated report HTML. If any new inline citations (e.g., [x]) have been added that are not in the original reference table,\n"
|
| 897 |
+
"generate an updated References Summary Table as valid HTML. Output only the updated table without any additional comments.\n\n"
|
| 898 |
f"Updated Report HTML:\n{updated_report_html}"
|
| 899 |
)
|
| 900 |
# Increase token limit to 1500 for this call
|
|
|
|
| 903 |
|
| 904 |
if updated_refs and not updated_refs.lower().startswith("error: empty response"):
|
| 905 |
soup_updated = BeautifulSoup(updated_report_html, "html.parser")
|
| 906 |
+
ref_heading = soup_updated.find(lambda tag: tag.name in ["h1", "h2", "h3", "h4"] and "references summary table" in tag.get_text(strip=True).lower())
|
| 907 |
if ref_heading:
|
| 908 |
next_sibling = ref_heading.find_next_sibling()
|
| 909 |
if next_sibling:
|
|
|
|
| 1088 |
prompt_adjust = (f"""
|
| 1089 |
You are a technical editor.
|
| 1090 |
Given the following HTML container (including its outer tags) extracted from a larger report and based on the user expansion request, produce an expanded version by elaborating on the content.
|
| 1091 |
+
Preserve all inline citations (formatted as [x]) and ensure that if you add any new citations, they are consistent with sources that must also be reflected in the final References Summary Table.
|
| 1092 |
Skip lines occasionally to improve readability.
|
| 1093 |
The expanded version will be put back in the exact same location and must maintain the outer HTML tags.
|
| 1094 |
|
|
|
|
| 1108 |
- Complementary Guidance:
|
| 1109 |
{complementary_guidance}
|
| 1110 |
|
| 1111 |
+
Ensure that any inline citation (e.g., [1], [2], etc.) within the expanded content is preserved or newly included so they can all be captured in the final References Summary Table.
|
| 1112 |
|
| 1113 |
Output a JSON object with exactly two keys:
|
| 1114 |
- "expanded" (the expanded container's full HTML)
|
|
|
|
| 1140 |
|
| 1141 |
updated_report_html = str(soup)
|
| 1142 |
|
| 1143 |
+
# Step 5 (and 6): Update the References Summary Table.
|
| 1144 |
prompt_refs = (
|
| 1145 |
f"\nYou are a technical editor.\n\n"
|
| 1146 |
"Review the following updated report HTML. If any new inline citations (e.g., [x]) have been added that are not in the original reference table, "
|
| 1147 |
+
"generate an updated References Summary Table as valid HTML."
|
| 1148 |
" Every inline citation found in the report must have a corresponding entry in this table. "
|
| 1149 |
"Output only the updated table without any additional comments.\n\n"
|
| 1150 |
f"Updated Report HTML:\n{updated_report_html}"
|
|
|
|
| 1155 |
|
| 1156 |
if updated_refs and not updated_refs.lower().startswith("error: empty response"):
|
| 1157 |
soup_updated = BeautifulSoup(updated_report_html, "html.parser")
|
| 1158 |
+
ref_heading = soup_updated.find(lambda tag: tag.name in ["h1", "h2", "h3", "h4"] and "references summary table" in tag.get_text(strip=True).lower())
|
| 1159 |
if ref_heading:
|
| 1160 |
next_sibling = ref_heading.find_next_sibling()
|
| 1161 |
if next_sibling:
|