diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e7fd77bf --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.vscode +.ipynb_checkpoints +content +.env +__pycache__ \ No newline at end of file diff --git a/gpt_author_v2.ipynb b/gpt_author_v2.ipynb index fc41160b..9ca90e76 100644 --- a/gpt_author_v2.ipynb +++ b/gpt_author_v2.ipynb @@ -453,6 +453,12 @@ "\n", " print(f'Output for prompt \"{prompt}\" has been written to {file_path}\\n')\n", "\n", + "import re\n", + "\n", + "def escape_double_quotes(input_string):\n", + " # Update double quotes with escaped double quote mark to fix chapter_titles format error\n", + " cleaned_string = re.sub(r'\"', \"\\\"\", input_string)\n", + " return cleaned_string\n", "\n", "def write_fantasy_novel(prompt, num_chapters, writing_style, claude_true=False):\n", " plots = generate_plots(prompt)\n", @@ -469,7 +475,7 @@ "\n", " storyline = generate_storyline(improved_plot, num_chapters)\n", " print('storyline generated')\n", - " chapter_titles = ast.literal_eval(storyline)\n", + " chapter_titles = ast.literal_eval(escape_double_quotes(str(storyline)))\n", "\n", "\n", " novel = f\"Storyline:\\n{storyline}\\n\\n\"\n", @@ -539,4 +545,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +}