Skip to content

Commit e2c11a5

Browse files
committed
fix: fallback to default length when parsing fails
1 parent 640e1f2 commit e2c11a5

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

apps/novelclaw/workflow/executor.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ def _is_en(self) -> bool:
120120
return str(getattr(self, "lang", "en")).lower().startswith("en")
121121

122122
def _normalize_target_length(self, target_length: Any, default: int = 5000) -> int:
123-
"""Normalize free-form target-length input into a safe integer."""
123+
"""Normalize target-length input into a safe integer.
124+
125+
Rule:
126+
- If an explicit numeric value can be parsed, use it.
127+
- Otherwise, fall back directly to the default length.
128+
"""
124129
if isinstance(target_length, (int, float)):
125130
return max(1, int(target_length))
126131

@@ -140,14 +145,6 @@ def _normalize_target_length(self, target_length: Any, default: int = 5000) -> i
140145
except Exception:
141146
pass
142147

143-
lower = raw.lower()
144-
if any(token in raw for token in ["长篇", "长文", "超长"]) or "long-form" in lower or "epic" in lower:
145-
return 20000
146-
if any(token in raw for token in ["中篇", "中长"]) or "medium" in lower:
147-
return 10000
148-
if any(token in raw for token in ["短篇", "短文"]) or "short" in lower:
149-
return 3000
150-
151148
return default
152149

153150
def _prompt(self, zh: str, en: str) -> str:

0 commit comments

Comments
 (0)