| import re |
|
|
| with open("backend/prompts/synthesis.py", "r", encoding="utf-8") as f: |
| content = f.read() |
|
|
| |
| idx = content.find('WRITING_PROMPT = """') |
| if idx == -1: |
| print("Could not find WRITING_PROMPT") |
| exit(1) |
|
|
| master_part = content[:idx] |
| rest_part = content[idx:] |
|
|
| |
| |
| rest_part = rest_part.replace(r"\section{{{section}}}", r"\section{{section}}") |
| |
| rest_part = rest_part.replace(r"\subsection{{}}", r"\subsection{}") |
| |
| rest_part = rest_part.replace(r"\subsubsection{{}}", r"\subsubsection{}") |
| |
| rest_part = rest_part.replace(r"\textbf{{texto}}", r"\textbf{texto}") |
| |
| rest_part = rest_part.replace(r"\textit{{texto}}", r"\textit{texto}") |
| |
| rest_part = rest_part.replace(r"\begin{{itemize}}", r"\begin{itemize}") |
| |
| rest_part = rest_part.replace(r"\end{{itemize}}", r"\end{itemize}") |
| |
| rest_part = rest_part.replace(r"{{{{BIB:ID}}}}", r"{{BIB:ID}}") |
|
|
| |
| |
| |
| rest_part = rest_part.replace(r"{{BIB:ID}}", r"__BIB_ID__") |
| rest_part = rest_part.replace(r"{{", r"{") |
| rest_part = rest_part.replace(r"}}", r"}") |
| rest_part = rest_part.replace(r"__BIB_ID__", r"{{BIB:ID}}") |
|
|
| |
| with open("backend/prompts/synthesis.py", "w", encoding="utf-8") as f: |
| f.write(master_part + rest_part) |
|
|
| print("Fixed backend/prompts/synthesis.py") |
|
|