-
Notifications
You must be signed in to change notification settings - Fork 0
Enforce target novel length via expansion agent and length validation #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
85b4f64
c906378
ee16d1b
ed539c8
f2d9125
ab58220
1c0edd7
8f03266
a0e6d6f
5f8daa6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,8 @@ def _run_chapter_generation_internal( | |
| consequence_log: list[dict] = [] # tracks irreversible consequences per chapter | ||
| exposition_log: list[dict] = [] # tracks dramatization ratio per chapter | ||
| thematic_phrase_log: list[str] = [] # tracks thematic phrases to avoid repeating | ||
| length_enforcement_log: list[dict] = [] # tracks per-chapter length enforcement results | ||
| total_words_generated: int = 0 # running total for global length tracking | ||
|
|
||
| # Format voice seed for prompt injection | ||
| from novelforge.voice import format_voice_prompt | ||
|
|
@@ -423,6 +425,7 @@ def _set_step(step_label: str) -> None: | |
| degraded_passes=degraded_passes, | ||
| chapter_rhythm_shape=chapter_rhythm_shape, | ||
| chapter_rhythm_reason=chapter_rhythm_reason, | ||
| target_words=target_per_chapter, | ||
| ) | ||
| summaries.append(summary) | ||
|
|
||
|
|
@@ -494,6 +497,22 @@ def _set_step(step_label: str) -> None: | |
| chapter_usage = get_llm_usage() | ||
| chapter_word_count = len(text.split()) | ||
|
|
||
| # Track length enforcement results | ||
| from novelforge.agents.chapter._helpers import check_chapter_length | ||
| min_pct = config.CHAPTER_MIN_LENGTH_PCT | ||
| _, min_threshold, meets_min = check_chapter_length( | ||
| text, target_per_chapter, min_pct, | ||
| ) | ||
| total_words_generated += chapter_word_count | ||
| length_enforcement_log.append({ | ||
| "chapter_num": chapter_num, | ||
| "target": target_per_chapter, | ||
| "min_threshold": min_threshold, | ||
| "actual": chapter_word_count, | ||
| "meets_min_threshold": meets_min, | ||
| "total_words_so_far": total_words_generated, | ||
|
CyberSecDef marked this conversation as resolved.
|
||
| }) | ||
|
Comment on lines
+500
to
+514
|
||
|
|
||
| chapters_done.append({ | ||
| "number": chapter_num, | ||
| "title": chapter_title, | ||
|
|
@@ -516,6 +535,7 @@ def _set_step(step_label: str) -> None: | |
| "chapters_done": list(chapters_done), | ||
| "character_state_log": list(character_state_log), | ||
| "degraded_passes": list(degraded_passes), | ||
| "length_enforcement": list(length_enforcement_log), | ||
| }) | ||
| _persist_progress(force=True) # always persist on chapter completion | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expand_chapter()accepts atitleparameter but never uses it (not in logging, not in the prompt builder). Either remove the parameter to avoid dead API surface, or incorporatetitleinto the expansion prompt/log context so callers aren’t passing unused data.