Fix for chapter repeats.
This commit is contained in:
@@ -950,7 +950,7 @@ def rewrite_chapter_content(bp, manuscript, chapter_num, instruction, folder):
|
||||
utils.log("WRITER", f"Rewriting Ch {chapter_num} with instruction: {instruction}")
|
||||
|
||||
# Find target chapter and previous context
|
||||
target_chap = next((c for c in manuscript if c['num'] == chapter_num), None)
|
||||
target_chap = next((c for c in manuscript if str(c.get('num')) == str(chapter_num)), None)
|
||||
if not target_chap: return None
|
||||
|
||||
prev_text = ""
|
||||
|
||||
@@ -1108,7 +1108,7 @@ def save_chapter(run_id):
|
||||
if os.path.exists(ms_path):
|
||||
ms = utils.load_json(ms_path)
|
||||
for ch in ms:
|
||||
if ch.get('num') == chap_num:
|
||||
if str(ch.get('num')) == str(chap_num):
|
||||
ch['content'] = new_content
|
||||
break
|
||||
with open(ms_path, 'w') as f: json.dump(ms, f, indent=2)
|
||||
|
||||
@@ -367,7 +367,7 @@ def rewrite_chapter_task(run_id, project_path, book_folder, chap_num, instructio
|
||||
if result and result[0]:
|
||||
new_text, summary = result
|
||||
for ch in ms:
|
||||
if ch.get('num') == chap_num:
|
||||
if str(ch.get('num')) == str(chap_num):
|
||||
ch['content'] = new_text
|
||||
break
|
||||
|
||||
|
||||
Reference in New Issue
Block a user