Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1990,6 +1990,11 @@ def download_novel(novel_text: str, format: str, language: str, session_id: str
|
|
1990 |
stages = NovelDatabase.get_stages(session_id)
|
1991 |
logger.info(f"Found {len(stages)} stages in database")
|
1992 |
|
|
|
|
|
|
|
|
|
|
|
1993 |
# ํ
์คํธ ๋ชจ๋ ๊ฐ์ง - writer10์ด ์์ผ๋ฉด ํ
์คํธ ๋ชจ๋
|
1994 |
is_test_mode = False
|
1995 |
has_writer10 = any(stage['role'] == 'writer10' for stage in stages)
|
@@ -2043,7 +2048,7 @@ def download_novel(novel_text: str, format: str, language: str, session_id: str
|
|
2043 |
logger.info(f"[TEST MODE] Checking stage: role={stage['role']}, name={stage['stage_name']}, status={stage['status']}")
|
2044 |
|
2045 |
# Writer 1 ์์ ๋ณธ
|
2046 |
-
if stage['role'] == 'writer1' and stage['stage_name'] and 'Revision' in stage['stage_name']:
|
2047 |
content = stage['content'] or ""
|
2048 |
content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', content)
|
2049 |
content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', content)
|
@@ -2091,11 +2096,16 @@ def download_novel(novel_text: str, format: str, language: str, session_id: str
|
|
2091 |
for stage in stages:
|
2092 |
logger.info(f"[NORMAL MODE] Checking stage: role={stage['role']}, name={stage['stage_name']}, status={stage['status']}")
|
2093 |
|
2094 |
-
|
|
|
|
|
|
|
|
|
|
|
2095 |
# ์๊ฐ ๋ฒํธ ์ถ์ถ
|
2096 |
try:
|
2097 |
writer_num = int(stage['role'].replace('writer', ''))
|
2098 |
-
logger.info(f"Found writer {writer_num} revision")
|
2099 |
except:
|
2100 |
logger.warning(f"Could not extract writer number from role: {stage['role']}")
|
2101 |
continue
|
@@ -2212,7 +2222,7 @@ def download_novel(novel_text: str, format: str, language: str, session_id: str
|
|
2212 |
# ํ
์คํธ ๋ชจ๋: writer1 + writer10 ์ฒ๋ฆฌ
|
2213 |
for stage in stages:
|
2214 |
# Writer 1 ์์ ๋ณธ
|
2215 |
-
if stage['role'] == 'writer1' and stage['stage_name'] and 'Revision' in stage['stage_name']:
|
2216 |
content = stage['content'] or ""
|
2217 |
content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', content)
|
2218 |
content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', content)
|
@@ -2256,7 +2266,12 @@ def download_novel(novel_text: str, format: str, language: str, session_id: str
|
|
2256 |
else:
|
2257 |
# ์ผ๋ฐ ๋ชจ๋ - ์์ ๋ ๋ก์ง
|
2258 |
for stage in stages:
|
2259 |
-
|
|
|
|
|
|
|
|
|
|
|
2260 |
# ์๊ฐ ๋ฒํธ ์ถ์ถ
|
2261 |
try:
|
2262 |
writer_num = int(stage['role'].replace('writer', ''))
|
|
|
1990 |
stages = NovelDatabase.get_stages(session_id)
|
1991 |
logger.info(f"Found {len(stages)} stages in database")
|
1992 |
|
1993 |
+
# ๋๋ฒ๊น
: ๋ชจ๋ stage ์ ๋ณด ์ถ๋ ฅ
|
1994 |
+
for stage in stages:
|
1995 |
+
logger.debug(f"Stage: role={stage.get('role')}, stage_name={stage.get('stage_name')}, "
|
1996 |
+
f"content_length={len(stage.get('content', ''))}, status={stage.get('status')}")
|
1997 |
+
|
1998 |
# ํ
์คํธ ๋ชจ๋ ๊ฐ์ง - writer10์ด ์์ผ๋ฉด ํ
์คํธ ๋ชจ๋
|
1999 |
is_test_mode = False
|
2000 |
has_writer10 = any(stage['role'] == 'writer10' for stage in stages)
|
|
|
2048 |
logger.info(f"[TEST MODE] Checking stage: role={stage['role']}, name={stage['stage_name']}, status={stage['status']}")
|
2049 |
|
2050 |
# Writer 1 ์์ ๋ณธ
|
2051 |
+
if stage['role'] == 'writer1' and stage['stage_name'] and ('Revision' in stage['stage_name'] or '์์ ๋ณธ' in stage['stage_name']):
|
2052 |
content = stage['content'] or ""
|
2053 |
content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', content)
|
2054 |
content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', content)
|
|
|
2096 |
for stage in stages:
|
2097 |
logger.info(f"[NORMAL MODE] Checking stage: role={stage['role']}, name={stage['stage_name']}, status={stage['status']}")
|
2098 |
|
2099 |
+
# ์ธ์ด์ ์๊ด์์ด ์๊ฐ ์์ ๋ณธ ์ฐพ๊ธฐ
|
2100 |
+
is_revision = (stage['role'] and stage['role'].startswith('writer') and
|
2101 |
+
stage['stage_name'] and
|
2102 |
+
('Revision' in stage['stage_name'] or '์์ ๋ณธ' in stage['stage_name']))
|
2103 |
+
|
2104 |
+
if is_revision:
|
2105 |
# ์๊ฐ ๋ฒํธ ์ถ์ถ
|
2106 |
try:
|
2107 |
writer_num = int(stage['role'].replace('writer', ''))
|
2108 |
+
logger.info(f"Found writer {writer_num} revision - stage_name: {stage['stage_name']}")
|
2109 |
except:
|
2110 |
logger.warning(f"Could not extract writer number from role: {stage['role']}")
|
2111 |
continue
|
|
|
2222 |
# ํ
์คํธ ๋ชจ๋: writer1 + writer10 ์ฒ๋ฆฌ
|
2223 |
for stage in stages:
|
2224 |
# Writer 1 ์์ ๋ณธ
|
2225 |
+
if stage['role'] == 'writer1' and stage['stage_name'] and ('Revision' in stage['stage_name'] or '์์ ๋ณธ' in stage['stage_name']):
|
2226 |
content = stage['content'] or ""
|
2227 |
content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', content)
|
2228 |
content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', content)
|
|
|
2266 |
else:
|
2267 |
# ์ผ๋ฐ ๋ชจ๋ - ์์ ๋ ๋ก์ง
|
2268 |
for stage in stages:
|
2269 |
+
# ์ธ์ด์ ์๊ด์์ด ์๊ฐ ์์ ๋ณธ ์ฐพ๊ธฐ
|
2270 |
+
is_revision = (stage['role'] and stage['role'].startswith('writer') and
|
2271 |
+
stage['stage_name'] and
|
2272 |
+
('Revision' in stage['stage_name'] or '์์ ๋ณธ' in stage['stage_name']))
|
2273 |
+
|
2274 |
+
if is_revision:
|
2275 |
# ์๊ฐ ๋ฒํธ ์ถ์ถ
|
2276 |
try:
|
2277 |
writer_num = int(stage['role'].replace('writer', ''))
|