openfree commited on
Commit
625078a
ยท
verified ยท
1 Parent(s): 05e93b4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +1813 -0
app.py ADDED
@@ -0,0 +1,1813 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import json
4
+ import requests
5
+ from datetime import datetime
6
+ import time
7
+ from typing import List, Dict, Any, Generator, Tuple
8
+ import logging
9
+ import re
10
+ import tempfile
11
+ from pathlib import Path
12
+
13
+ # ๋กœ๊น… ์„ค์ •
14
+ logging.basicConfig(level=logging.INFO)
15
+ logger = logging.getLogger(__name__)
16
+
17
+ # Document export imports
18
+ try:
19
+ from docx import Document
20
+ from docx.shared import Inches, Pt, RGBColor
21
+ from docx.enum.text import WD_ALIGN_PARAGRAPH
22
+ from docx.enum.style import WD_STYLE_TYPE
23
+ DOCX_AVAILABLE = True
24
+ except ImportError:
25
+ DOCX_AVAILABLE = False
26
+ logger.warning("python-docx not installed. DOCX export will be disabled.")
27
+
28
+ # ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ ํ† ํฐ ๊ฐ€์ ธ์˜ค๊ธฐ
29
+ FRIENDLI_TOKEN = os.getenv("FRIENDLI_TOKEN", "YOUR_FRIENDLI_TOKEN")
30
+ API_URL = "https://api.friendli.ai/dedicated/v1/chat/completions"
31
+ MODEL_ID = "dep89a2fld32mcm"
32
+ TEST_MODE = os.getenv("TEST_MODE", "false").lower() == "true"
33
+
34
+ # ์ „์—ญ ๋ณ€์ˆ˜
35
+ conversation_history = []
36
+ selected_language = "English" # ๊ธฐ๋ณธ ์–ธ์–ด
37
+ novel_context = {} # ์†Œ์„ค ์ปจํ…์ŠคํŠธ ์ €์žฅ
38
+
39
+ class NovelWritingSystem:
40
+ def __init__(self):
41
+ self.token = FRIENDLI_TOKEN
42
+ self.api_url = API_URL
43
+ self.model_id = MODEL_ID
44
+ self.test_mode = TEST_MODE or (self.token == "YOUR_FRIENDLI_TOKEN")
45
+
46
+ if self.test_mode:
47
+ logger.warning("Running in test mode.")
48
+
49
+ # ์†Œ์„ค ์ž‘์„ฑ ์ง„ํ–‰ ์ƒํƒœ
50
+ self.novel_state = {
51
+ "theme": "",
52
+ "characters": {},
53
+ "plot_outline": "",
54
+ "chapters": [],
55
+ "writer_outputs": {},
56
+ "critic_feedbacks": {}
57
+ }
58
+
59
+ def create_headers(self):
60
+ """API ํ—ค๋” ์ƒ์„ฑ"""
61
+ return {
62
+ "Authorization": f"Bearer {self.token}",
63
+ "Content-Type": "application/json"
64
+ }
65
+
66
+ def create_director_initial_prompt(self, user_query: str, language: str = "English") -> str:
67
+ """Director AI initial prompt - Novel planning"""
68
+ if language == "Korean":
69
+ return f"""๋‹น์‹ ์€ 50ํŽ˜์ด์ง€ ๋ถ„๋Ÿ‰์˜ ์ค‘ํŽธ ์†Œ์„ค์„ ๊ธฐํšํ•˜๋Š” ๋ฌธํ•™ ๊ฐ๋…์ž์ž…๋‹ˆ๋‹ค.
70
+
71
+ ์‚ฌ์šฉ์ž ์š”์ฒญ: {user_query}
72
+
73
+ ๋‹ค์Œ ์š”์†Œ๋“ค์„ ์ฒด๊ณ„์ ์œผ๋กœ ๊ตฌ์„ฑํ•˜์—ฌ 50ํŽ˜์ด์ง€ ์ค‘ํŽธ ์†Œ์„ค์˜ ๊ธฐ์ดˆ๋ฅผ ๋งŒ๋“œ์„ธ์š”:
74
+
75
+ 1. **์ฃผ์ œ์™€ ์žฅ๋ฅด**
76
+ - ํ•ต์‹ฌ ์ฃผ์ œ์™€ ๋ฉ”์‹œ์ง€
77
+ - ์žฅ๋ฅด ๋ฐ ํ†ค
78
+ - ๋ชฉํ‘œ ๋…์ž์ธต
79
+
80
+ 2. **๋“ฑ์žฅ์ธ๋ฌผ ์„ค์ •** (ํ‘œ๋กœ ์ •๋ฆฌ)
81
+ | ์ด๋ฆ„ | ์—ญํ•  | ์„ฑ๊ฒฉ | ๋ฐฐ๊ฒฝ | ๋™๊ธฐ | ๋ณ€ํ™” |
82
+ |------|------|------|------|------|------|
83
+
84
+ 3. **์ธ๋ฌผ ๊ด€๊ณ„๋„**
85
+ - ์ฃผ์š” ์ธ๋ฌผ ๊ฐ„์˜ ๊ด€๊ณ„
86
+ - ๊ฐˆ๋“ฑ ๊ตฌ์กฐ
87
+ - ๊ฐ์ •์  ์—ฐ๊ฒฐ๊ณ ๋ฆฌ
88
+
89
+ 4. **์„œ์‚ฌ ๊ตฌ์กฐ** (50ํŽ˜์ด์ง€๋ฅผ 10๊ฐœ ํŒŒํŠธ๋กœ ๋‚˜๋ˆ„์–ด ๊ฐ 5ํŽ˜์ด์ง€)
90
+ | ํŒŒํŠธ | ํŽ˜์ด์ง€ | ์ฃผ์š” ์‚ฌ๊ฑด | ๊ธด์žฅ๋„ | ์ธ๋ฌผ ๋ฐœ์ „ |
91
+ |------|--------|-----------|---------|-----------|
92
+
93
+ 5. **์„ธ๊ณ„๊ด€ ์„ค์ •**
94
+ - ์‹œ๊ณต๊ฐ„์  ๋ฐฐ๊ฒฝ
95
+ - ์‚ฌํšŒ์ /๋ฌธํ™”์  ๋งฅ๋ฝ
96
+ - ๋ถ„์œ„๊ธฐ์™€ ํ†ค
97
+
98
+ ๊ฐ ์ž‘์„ฑ์ž๊ฐ€ 5ํŽ˜์ด์ง€์”ฉ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ช…ํ™•ํ•œ ๊ฐ€์ด๋“œ๋ผ์ธ์„ ์ œ์‹œํ•˜์„ธ์š”."""
99
+ else:
100
+ return f"""You are a literary director planning a 50-page novella.
101
+
102
+ User Request: {user_query}
103
+
104
+ Systematically compose the following elements to create the foundation for a 50-page novella:
105
+
106
+ 1. **Theme and Genre**
107
+ - Core theme and message
108
+ - Genre and tone
109
+ - Target audience
110
+
111
+ 2. **Character Settings** (organize in table)
112
+ | Name | Role | Personality | Background | Motivation | Arc |
113
+ |------|------|-------------|------------|------------|-----|
114
+
115
+ 3. **Character Relationship Map**
116
+ - Relationships between main characters
117
+ - Conflict structure
118
+ - Emotional connections
119
+
120
+ 4. **Narrative Structure** (divide 50 pages into 10 parts, 5 pages each)
121
+ | Part | Pages | Main Events | Tension | Character Development |
122
+ |------|-------|-------------|---------|---------------------|
123
+
124
+ 5. **World Building**
125
+ - Temporal and spatial setting
126
+ - Social/cultural context
127
+ - Atmosphere and tone
128
+
129
+ Provide clear guidelines for each writer to compose 5 pages."""
130
+
131
+ def create_critic_director_prompt(self, director_plan: str, language: str = "English") -> str:
132
+ """Critic's review of director's plan"""
133
+ if language == "Korean":
134
+ return f"""๋‹น์‹ ์€ ๋ฌธํ•™ ๋น„ํ‰๊ฐ€์ž…๋‹ˆ๋‹ค. ๊ฐ๋…์ž์˜ ์†Œ์„ค ๊ธฐํš์„ ๊ฒ€ํ† ํ•˜๊ณ  ๊ฐœ์„ ์ ์„ ์ œ์‹œํ•˜์„ธ์š”.
135
+
136
+ ๊ฐ๋…์ž์˜ ๊ธฐํš:
137
+ {director_plan}
138
+
139
+ ๋‹ค์Œ ๊ด€์ ์—์„œ ๋น„ํ‰ํ•˜๊ณ  ๊ตฌ์ฒด์ ์ธ ๊ฐœ์„ ์•ˆ์„ ์ œ์‹œํ•˜์„ธ์š”:
140
+
141
+ 1. **์„œ์‚ฌ์  ์™„์„ฑ๋„**
142
+ - ํ”Œ๋กฏ์˜ ๋…ผ๋ฆฌ์„ฑ๊ณผ ๊ฐœ์—ฐ์„ฑ
143
+ - ๊ฐˆ๋“ฑ์˜ ํšจ๊ณผ์„ฑ
144
+ - ํด๋ผ์ด๋งฅ์Šค์˜ ์œ„์น˜์™€ ๊ฐ•๋„
145
+
146
+ 2. **์ธ๋ฌผ ์„ค์ • ๊ฒ€ํ† **
147
+ | ์ธ๋ฌผ | ๊ฐ•์  | ์•ฝ์  | ๊ฐœ์„  ์ œ์•ˆ |
148
+ |------|------|------|-----------|
149
+
150
+ 3. **๊ตฌ์กฐ์  ๊ท ํ˜•**
151
+ - ๊ฐ ํŒŒํŠธ๋ณ„ ๋ถ„๋Ÿ‰ ๋ฐฐ๋ถ„
152
+ - ๊ธด์žฅ๊ณผ ์ด์™„์˜ ๋ฆฌ๋“ฌ
153
+ - ์ „์ฒด์ ์ธ ํ๋ฆ„
154
+
155
+ 4. **๋…์ž ๊ด€์ **
156
+ - ๋ชฐ์ž…๋„ ์˜ˆ์ƒ
157
+ - ๊ฐ์ •์  ์˜ํ–ฅ๋ ฅ
158
+ - ๊ธฐ๋Œ€๏ฟฝ๏ฟฝ ์ถฉ์กฑ๋„
159
+
160
+ 5. **์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ**
161
+ - ๊ฐ ์ž‘์„ฑ์ž๋ฅผ ์œ„ํ•œ ๊ฐ€์ด๋“œ๋ผ์ธ์˜ ๋ช…ํ™•์„ฑ
162
+ - ์ผ๊ด€์„ฑ ์œ ์ง€ ๋ฐฉ์•ˆ
163
+ - ์ž ์žฌ์  ๋ฌธ์ œ์ 
164
+
165
+ ๊ตฌ์ฒด์ ์ด๊ณ  ๊ฑด์„ค์ ์ธ ํ”ผ๋“œ๋ฐฑ์„ ์ œ๊ณตํ•˜์„ธ์š”."""
166
+ else:
167
+ return f"""You are a literary critic. Review the director's novel plan and suggest improvements.
168
+
169
+ Director's Plan:
170
+ {director_plan}
171
+
172
+ Critique from the following perspectives and provide specific improvements:
173
+
174
+ 1. **Narrative Completeness**
175
+ - Plot logic and plausibility
176
+ - Effectiveness of conflicts
177
+ - Climax position and intensity
178
+
179
+ 2. **Character Review**
180
+ | Character | Strengths | Weaknesses | Suggestions |
181
+ |-----------|-----------|------------|-------------|
182
+
183
+ 3. **Structural Balance**
184
+ - Distribution across parts
185
+ - Rhythm of tension and relief
186
+ - Overall flow
187
+
188
+ 4. **Reader Perspective**
189
+ - Expected engagement
190
+ - Emotional impact
191
+ - Expectation fulfillment
192
+
193
+ 5. **Feasibility**
194
+ - Clarity of guidelines for each writer
195
+ - Consistency maintenance
196
+ - Potential issues
197
+
198
+ Provide specific and constructive feedback."""
199
+
200
+ def create_director_revision_prompt(self, initial_plan: str, critic_feedback: str, language: str = "English") -> str:
201
+ """Director's revision based on critic feedback"""
202
+ if language == "Korean":
203
+ return f"""๊ฐ๋…์ž๋กœ์„œ ๋น„ํ‰๊ฐ€์˜ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ˜์˜ํ•˜์—ฌ ์†Œ์„ค ๊ธฐํš์„ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
204
+
205
+ ์ดˆ๊ธฐ ๊ธฐํš:
206
+ {initial_plan}
207
+
208
+ ๋น„ํ‰๊ฐ€ ํ”ผ๋“œ๋ฐฑ:
209
+ {critic_feedback}
210
+
211
+ ๋‹ค์Œ์„ ํฌํ•จํ•œ ์ˆ˜์ •๋œ ์ตœ์ข… ๊ธฐํš์„ ์ œ์‹œํ•˜์„ธ์š”:
212
+
213
+ 1. **์ˆ˜์ •๋œ ์„œ์‚ฌ ๊ตฌ์กฐ**
214
+ | ํŒŒํŠธ | ํŽ˜์ด์ง€ | ์ฃผ์š” ์‚ฌ๊ฑด | ์ž‘์„ฑ ์ง€์นจ | ์ฃผ์˜์‚ฌํ•ญ |
215
+ |------|--------|-----------|-----------|----------|
216
+
217
+ 2. **๊ฐ•ํ™”๋œ ์ธ๋ฌผ ์„ค์ •**
218
+ - ๊ฐ ์ธ๋ฌผ์˜ ๋ช…ํ™•ํ•œ ๋™๊ธฐ์™€ ๋ชฉํ‘œ
219
+ - ์ธ๋ฌผ ๊ฐ„ ๊ฐˆ๋“ฑ์˜ ๊ตฌ์ฒดํ™”
220
+ - ๊ฐ์ •์„ ์˜ ๋ณ€ํ™” ์ถ”์ด
221
+
222
+ 3. **๊ฐ ์ž‘์„ฑ์ž๋ฅผ ์œ„ํ•œ ์ƒ์„ธ ๊ฐ€์ด๋“œ**
223
+ - ํŒŒํŠธ๋ณ„ ์‹œ์ž‘๊ณผ ๋ ์ง€์ 
224
+ - ํ•„์ˆ˜ ํฌํ•จ ์š”์†Œ
225
+ - ๋ฌธ์ฒด์™€ ํ†ค ์ง€์นจ
226
+ - ์ „๋‹ฌํ•ด์•ผ ํ•  ์ •๋ณด
227
+
228
+ 4. **์ผ๊ด€์„ฑ ์œ ์ง€ ์ฒดํฌ๋ฆฌ์ŠคํŠธ**
229
+ - ์‹œ๊ฐ„์„  ๊ด€๋ฆฌ
230
+ - ์ธ๋ฌผ ํŠน์„ฑ ์œ ์ง€
231
+ - ์„ค์ • ์ผ๊ด€์„ฑ
232
+ - ๋ณต์„ ๊ณผ ํ•ด๊ฒฐ
233
+
234
+ 5. **ํ’ˆ์งˆ ๊ธฐ์ค€**
235
+ - ๊ฐ ํŒŒํŠธ์˜ ์™„์„ฑ๋„ ๊ธฐ์ค€
236
+ - ์ „์ฒด์  ํ†ต์ผ์„ฑ
237
+ - ๋…์ž ๋ชฐ์ž… ์œ ์ง€ ๋ฐฉ์•ˆ
238
+
239
+ ๋ชจ๋“  ์ž‘์„ฑ์ž๊ฐ€ ๋ช…ํ™•ํžˆ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ์ข… ๋งˆ์Šคํ„ฐํ”Œ๋žœ์„ ์ž‘์„ฑํ•˜์„ธ์š”."""
240
+ else:
241
+ return f"""As director, revise the novel plan reflecting the critic's feedback.
242
+
243
+ Initial Plan:
244
+ {initial_plan}
245
+
246
+ Critic Feedback:
247
+ {critic_feedback}
248
+
249
+ Present the revised final plan including:
250
+
251
+ 1. **Revised Narrative Structure**
252
+ | Part | Pages | Main Events | Writing Guidelines | Cautions |
253
+ |------|-------|-------------|-------------------|----------|
254
+
255
+ 2. **Enhanced Character Settings**
256
+ - Clear motivations and goals for each character
257
+ - Concrete conflicts between characters
258
+ - Emotional arc progression
259
+
260
+ 3. **Detailed Guide for Each Writer**
261
+ - Start and end points for each part
262
+ - Essential elements to include
263
+ - Style and tone guidelines
264
+ - Information to convey
265
+
266
+ 4. **Consistency Checklist**
267
+ - Timeline management
268
+ - Character trait maintenance
269
+ - Setting consistency
270
+ - Foreshadowing and resolution
271
+
272
+ 5. **Quality Standards**
273
+ - Completion criteria for each part
274
+ - Overall unity
275
+ - Reader engagement maintenance
276
+
277
+ Create a final masterplan that all writers can clearly understand."""
278
+
279
+ def create_writer_prompt(self, writer_number: int, director_plan: str, previous_content: str, language: str = "English") -> str:
280
+ """Individual writer prompt"""
281
+ pages_start = (writer_number - 1) * 5 + 1
282
+ pages_end = writer_number * 5
283
+
284
+ if language == "Korean":
285
+ return f"""๋‹น์‹ ์€ ์ž‘์„ฑ์ž {writer_number}๋ฒˆ์ž…๋‹ˆ๋‹ค. 50ํŽ˜์ด์ง€ ์ค‘ํŽธ ์†Œ์„ค์˜ {pages_start}-{pages_end}ํŽ˜์ด์ง€(5ํŽ˜์ด์ง€)๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”.
286
+
287
+ ๊ฐ๋…์ž์˜ ๋งˆ์Šคํ„ฐํ”Œ๋žœ:
288
+ {director_plan}
289
+
290
+ {'์ด์ „๊นŒ์ง€์˜ ๋‚ด์šฉ:' if previous_content else '๋‹น์‹ ์ด ์ฒซ ๋ฒˆ์งธ ์ž‘์„ฑ์ž์ž…๋‹ˆ๋‹ค.'}
291
+ {previous_content if previous_content else ''}
292
+
293
+ ๋‹ค์Œ ์ง€์นจ์— ๋”ฐ๋ผ ์ž‘์„ฑํ•˜์„ธ์š”:
294
+
295
+ 1. **๋ถ„๋Ÿ‰**: ์ •ํ™•ํžˆ 5ํŽ˜์ด์ง€ (ํŽ˜์ด์ง€๋‹น ์•ฝ 250-300๋‹จ์–ด)
296
+ 2. **์—ฐ์†์„ฑ**: ์ด์ „ ๋‚ด์šฉ๊ณผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ด์–ด์ง€๋„๋ก
297
+ 3. **์ผ๊ด€์„ฑ**:
298
+ - ๋“ฑ์žฅ์ธ๋ฌผ์˜ ์„ฑ๊ฒฉ๊ณผ ๋งํˆฌ ์œ ์ง€
299
+ - ์‹œ๊ฐ„์„ ๊ณผ ๊ณต๊ฐ„ ์„ค์ • ์ค€์ˆ˜
300
+ - ์ด๋ฏธ ์ œ์‹œ๋œ ์‚ฌ์‹ค๋“ค๊ณผ ๋ชจ์ˆœ ์—†์ด
301
+ 4. **๋ฐœ์ „**:
302
+ - ํ”Œ๋กฏ์„ ์ „์ง„์‹œํ‚ค๊ธฐ
303
+ - ์ธ๋ฌผ์˜ ์„ฑ์žฅ์ด๋‚˜ ๋ณ€ํ™” ํ‘œํ˜„
304
+ - ๊ธด์žฅ๊ฐ ์กฐ์ ˆ
305
+ 5. **๋ฌธ์ฒด**:
306
+ - ์ „์ฒด์ ์ธ ํ†ค๊ณผ ๋ถ„์œ„๊ธฐ ์œ ์ง€
307
+ - ๋…์ž์˜ ๋ชฐ์ž…์„ ํ•ด์น˜์ง€ ์•Š๊ธฐ
308
+
309
+ ํŽ˜์ด์ง€ ๊ตฌ๋ถ„์„ ๋ช…ํ™•ํžˆ ํ‘œ์‹œํ•˜์„ธ์š”:
310
+ [ํŽ˜์ด์ง€ {pages_start}]
311
+ ...
312
+ [ํŽ˜์ด์ง€ {pages_end}]"""
313
+ else:
314
+ return f"""You are Writer #{writer_number}. Write pages {pages_start}-{pages_end} (5 pages) of the 50-page novella.
315
+
316
+ Director's Masterplan:
317
+ {director_plan}
318
+
319
+ {'Previous content:' if previous_content else 'You are the first writer.'}
320
+ {previous_content if previous_content else ''}
321
+
322
+ Write according to these guidelines:
323
+
324
+ 1. **Length**: Exactly 5 pages (about 250-300 words per page)
325
+ 2. **Continuity**: Flow naturally from previous content
326
+ 3. **Consistency**:
327
+ - Maintain character personalities and speech
328
+ - Follow timeline and spatial settings
329
+ - No contradictions with established facts
330
+ 4. **Development**:
331
+ - Advance the plot
332
+ - Show character growth or change
333
+ - Control tension
334
+ 5. **Style**:
335
+ - Maintain overall tone and atmosphere
336
+ - Keep reader immersion
337
+
338
+ Clearly mark page divisions:
339
+ [Page {pages_start}]
340
+ ...
341
+ [Page {pages_end}]"""
342
+
343
+ def create_critic_writer_prompt(self, writer_number: int, writer_content: str, director_plan: str, all_previous_content: str, language: str = "English") -> str:
344
+ """Critic's review of individual writer's work"""
345
+ if language == "Korean":
346
+ return f"""์ž‘์„ฑ์ž {writer_number}๋ฒˆ์˜ ์ž‘ํ’ˆ์„ ๋น„ํ‰ํ•ฉ๋‹ˆ๋‹ค.
347
+
348
+ ๊ฐ๋…์ž์˜ ๋งˆ์Šคํ„ฐํ”Œ๋žœ:
349
+ {director_plan}
350
+
351
+ ์ „์ฒด ์ด์ „ ๋‚ด์šฉ:
352
+ {all_previous_content}
353
+
354
+ ์ž‘์„ฑ์ž {writer_number}๋ฒˆ์˜ ๋‚ด์šฉ:
355
+ {writer_content}
356
+
357
+ ๋‹ค์Œ ๊ธฐ์ค€์œผ๋กœ ํ‰๊ฐ€ํ•˜๊ณ  ์ˆ˜์ • ์š”๊ตฌ์‚ฌํ•ญ์„ ์ œ์‹œํ•˜์„ธ์š”:
358
+
359
+ 1. **์ผ๊ด€์„ฑ ๊ฒ€์ฆ** (ํ‘œ๋กœ ์ •๋ฆฌ)
360
+ | ์š”์†Œ | ์ด์ „ ์„ค์ • | ํ˜„์žฌ ํ‘œํ˜„ | ๋ฌธ์ œ์  | ์ˆ˜์ • ํ•„์š” |
361
+ |------|----------|----------|--------|----------|
362
+
363
+ 2. **๋…ผ๋ฆฌ์  ์˜ค๋ฅ˜ ๊ฒ€ํ† **
364
+ - ์‹œ๊ฐ„์„  ๋ชจ์ˆœ
365
+ - ์ธ๋ฌผ ํ–‰๋™์˜ ๊ฐœ์—ฐ์„ฑ
366
+ - ์„ค์ • ์ถฉ๋Œ
367
+ - ์‚ฌ์‹ค๊ด€๊ณ„ ์˜ค๋ฅ˜
368
+
369
+ 3. **์„œ์‚ฌ์  ํšจ๊ณผ์„ฑ**
370
+ - ํ”Œ๋กฏ ์ง„ํ–‰ ๊ธฐ์—ฌ๋„
371
+ - ๊ธด์žฅ๊ฐ ์œ ์ง€
372
+ - ๋…์ž ๋ชฐ์ž…๋„
373
+ - ๊ฐ์ •์  ์˜ํ–ฅ๋ ฅ
374
+
375
+ 4. **๋ฌธ์ฒด์™€ ํ’ˆ์งˆ**
376
+ - ์ „์ฒด ํ†ค๊ณผ์˜ ์ผ์น˜
377
+ - ๋ฌธ์žฅ์˜ ์งˆ
378
+ - ๋ฌ˜์‚ฌ์˜ ์ ์ ˆ์„ฑ
379
+ - ๋Œ€ํ™”์˜ ์ž์—ฐ์Šค๋Ÿฌ์›€
380
+
381
+ 5. **๊ฐœ์„  ์š”๊ตฌ์‚ฌํ•ญ**
382
+ - ํ•„์ˆ˜ ์ˆ˜์ • ์‚ฌํ•ญ (์ผ๊ด€์„ฑ/๋…ผ๋ฆฌ ์˜ค๋ฅ˜)
383
+ - ๊ถŒ์žฅ ๊ฐœ์„  ์‚ฌํ•ญ (ํ’ˆ์งˆ ํ–ฅ์ƒ)
384
+ - ๊ตฌ์ฒด์  ์ˆ˜์ • ์ง€์นจ
385
+
386
+ ๋ฐ˜๋“œ์‹œ ์ˆ˜์ •์ด ํ•„์š”ํ•œ ๋ถ€๋ถ„๊ณผ ์„ ํƒ์  ๊ฐœ์„ ์‚ฌํ•ญ์„ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ œ์‹œํ•˜์„ธ์š”."""
387
+ else:
388
+ return f"""Critiquing Writer #{writer_number}'s work.
389
+
390
+ Director's Masterplan:
391
+ {director_plan}
392
+
393
+ All Previous Content:
394
+ {all_previous_content}
395
+
396
+ Writer #{writer_number}'s Content:
397
+ {writer_content}
398
+
399
+ Evaluate by these criteria and present revision requirements:
400
+
401
+ 1. **Consistency Verification** (organize in table)
402
+ | Element | Previous Setting | Current Expression | Issue | Revision Needed |
403
+ |---------|-----------------|-------------------|-------|-----------------|
404
+
405
+ 2. **Logical Error Review**
406
+ - Timeline contradictions
407
+ - Character action plausibility
408
+ - Setting conflicts
409
+ - Factual errors
410
+
411
+ 3. **Narrative Effectiveness**
412
+ - Plot progression contribution
413
+ - Tension maintenance
414
+ - Reader engagement
415
+ - Emotional impact
416
+
417
+ 4. **Style and Quality**
418
+ - Alignment with overall tone
419
+ - Sentence quality
420
+ - Description appropriateness
421
+ - Dialogue naturalness
422
+
423
+ 5. **Improvement Requirements**
424
+ - Mandatory revisions (consistency/logic errors)
425
+ - Recommended improvements (quality enhancement)
426
+ - Specific revision guidelines
427
+
428
+ Clearly distinguish between mandatory revisions and optional improvements."""
429
+
430
+ def create_writer_revision_prompt(self, writer_number: int, initial_content: str, critic_feedback: str, language: str = "English") -> str:
431
+ """Writer's revision based on critic feedback"""
432
+ if language == "Korean":
433
+ return f"""์ž‘์„ฑ์ž {writer_number}๋ฒˆ์œผ๋กœ์„œ ๋น„ํ‰๊ฐ€์˜ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ˜์˜ํ•˜์—ฌ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.
434
+
435
+ ์ดˆ๊ธฐ ์ž‘์„ฑ ๋‚ด์šฉ:
436
+ {initial_content}
437
+
438
+ ๋น„ํ‰๊ฐ€ ํ”ผ๋“œ๋ฐฑ:
439
+ {critic_feedback}
440
+
441
+ ๋‹ค์Œ ์‚ฌํ•ญ์„ ๋ฐ˜์˜ํ•œ ์ˆ˜์ •๋ณธ์„ ์ž‘์„ฑํ•˜์„ธ์š”:
442
+
443
+ 1. **ํ•„์ˆ˜ ์ˆ˜์ •์‚ฌํ•ญ ๋ฐ˜์˜**
444
+ - ๋ชจ๋“  ์ผ๊ด€์„ฑ ์˜ค๋ฅ˜ ์ˆ˜์ •
445
+ - ๋…ผ๋ฆฌ์  ๋ชจ์ˆœ ํ•ด๊ฒฐ
446
+ - ์‚ฌ์‹ค๊ด€๊ณ„ ์ •์ •
447
+
448
+ 2. **ํ’ˆ์งˆ ๊ฐœ์„ **
449
+ - ๊ถŒ์žฅ์‚ฌํ•ญ ์ค‘ ๊ฐ€๋Šฅํ•œ ๋ถ€๋ถ„ ๋ฐ˜์˜
450
+ - ๋ฌธ์ฒด์™€ ํ†ค ์กฐ์ •
451
+ - ๋ฌ˜์‚ฌ์™€ ๋Œ€ํ™” ๊ฐœ์„ 
452
+
453
+ 3. **๋ถ„๋Ÿ‰ ์œ ์ง€**
454
+ - ์—ฌ์ „ํžˆ ์ •ํ™•ํžˆ 5ํŽ˜์ด์ง€
455
+ - ํŽ˜์ด์ง€ ๊ตฌ๋ถ„ ๋ช…ํ™•ํžˆ ํ‘œ์‹œ
456
+
457
+ 4. **์—ฐ์†์„ฑ ํ™•๋ณด**
458
+ - ์ด์ „/์ดํ›„ ๋‚ด์šฉ๊ณผ์˜ ์ž์—ฐ์Šค๋Ÿฌ์šด ์—ฐ๊ฒฐ
459
+ - ์ˆ˜์ •์œผ๋กœ ์ธํ•œ ์ƒˆ๋กœ์šด ๋ชจ์ˆœ ๋ฐฉ์ง€
460
+
461
+ ์ˆ˜์ •๋œ ์ตœ์ข…๋ณธ์„ ์ œ์‹œํ•˜์„ธ์š”."""
462
+ else:
463
+ return f"""As Writer #{writer_number}, revise based on critic's feedback.
464
+
465
+ Initial Content:
466
+ {initial_content}
467
+
468
+ Critic Feedback:
469
+ {critic_feedback}
470
+
471
+ Write a revision reflecting:
472
+
473
+ 1. **Mandatory Revisions**
474
+ - Fix all consistency errors
475
+ - Resolve logical contradictions
476
+ - Correct factual errors
477
+
478
+ 2. **Quality Improvements**
479
+ - Incorporate feasible recommendations
480
+ - Adjust style and tone
481
+ - Improve descriptions and dialogue
482
+
483
+ 3. **Maintain Length**
484
+ - Still exactly 5 pages
485
+ - Clear page divisions
486
+
487
+ 4. **Ensure Continuity**
488
+ - Natural connection with previous/next content
489
+ - Prevent new contradictions from revisions
490
+
491
+ Present the revised final version."""
492
+
493
+ def create_critic_final_prompt(self, all_content: str, director_plan: str, language: str = "English") -> str:
494
+ """Final critic evaluation of complete novel"""
495
+ if language == "Korean":
496
+ return f"""์ „์ฒด 50ํŽ˜์ด์ง€ ์†Œ์„ค์„ ์ตœ์ข… ํ‰๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
497
+
498
+ ๊ฐ๋…์ž์˜ ๋งˆ์Šคํ„ฐํ”Œ๋žœ:
499
+ {director_plan}
500
+
501
+ ์™„์„ฑ๋œ ์ „์ฒด ์†Œ์„ค:
502
+ {all_content}
503
+
504
+ ์ข…ํ•ฉ์ ์ธ ํ‰๊ฐ€์™€ ์ตœ์ข… ๊ฐœ์„  ์ œ์•ˆ์„ ์ œ์‹œํ•˜์„ธ์š”:
505
+
506
+ 1. **์ „์ฒด์  ์™„์„ฑ๋„ ํ‰๊ฐ€**
507
+ | ํ•ญ๋ชฉ | ์ ์ˆ˜(10์ ) | ํ‰๊ฐ€ | ๊ฐœ์„  ํ•„์š” |
508
+ |------|-----------|------|----------|
509
+ | ํ”Œ๋กฏ ์ผ๊ด€์„ฑ | | | |
510
+ | ์ธ๋ฌผ ๋ฐœ์ „ | | | |
511
+ | ์ฃผ์ œ ์ „๋‹ฌ | | | |
512
+ | ๋ฌธ์ฒด ํ†ต์ผ์„ฑ | | | |
513
+ | ๋…์ž ๋ชฐ์ž…๋„ | | | |
514
+
515
+ 2. **๊ฐ•์  ๋ถ„์„**
516
+ - ๊ฐ€์žฅ ํšจ๊ณผ์ ์ธ ๋ถ€๋ถ„
517
+ - ๋›ฐ์–ด๋‚œ ์žฅ๋ฉด์ด๋‚˜ ๋Œ€ํ™”
518
+ - ์„ฑ๊ณต์ ์ธ ์ธ๋ฌผ ๋ฌ˜์‚ฌ
519
+
520
+ 3. **์•ฝ์  ๋ฐ ๊ฐœ์„ ์ **
521
+ - ์ „์ฒด์  ํ๋ฆ„์˜ ๋ฌธ์ œ
522
+ - ๋ฏธํ•ด๊ฒฐ ํ”Œ๋กฏ
523
+ - ์บ๋ฆญํ„ฐ ์ผ๊ด€์„ฑ ์ด์Šˆ
524
+ - ํŽ˜์ด์‹ฑ ๋ฌธ์ œ
525
+
526
+ 4. **ํŒŒํŠธ๋ณ„ ์—ฐ๊ฒฐ์„ฑ**
527
+ | ์—ฐ๊ฒฐ๋ถ€ | ์ž์—ฐ์Šค๋Ÿฌ์›€ | ๋ฌธ์ œ์  | ๊ฐœ์„  ์ œ์•ˆ |
528
+ |--------|-----------|--------|----------|
529
+
530
+ 5. **์ตœ์ข… ๊ถŒ๊ณ ์‚ฌํ•ญ**
531
+ - ์ฆ‰์‹œ ์ˆ˜์ •์ด ํ•„์š”ํ•œ ์ค‘๋Œ€ ์˜ค๋ฅ˜
532
+ - ์ „์ฒด์  ํ’ˆ์งˆ ํ–ฅ์ƒ์„ ์œ„ํ•œ ์ œ์•ˆ
533
+ - ์ถœํŒ ๊ฐ€๋Šฅ์„ฑ ํ‰๊ฐ€
534
+
535
+ ๊ฐ๋…์ž๊ฐ€ ์ตœ์ข… ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌ์ฒด์ ์ด๊ณ  ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ ํ”ผ๋“œ๋ฐฑ์„ ์ œ๊ณตํ•˜์„ธ์š”."""
536
+ else:
537
+ return f"""Final evaluation of the complete 50-page novel.
538
+
539
+ Director's Masterplan:
540
+ {director_plan}
541
+
542
+ Complete Novel:
543
+ {all_content}
544
+
545
+ Provide comprehensive evaluation and final improvement suggestions:
546
+
547
+ 1. **Overall Completion Assessment**
548
+ | Item | Score(10) | Evaluation | Improvement Needed |
549
+ |------|-----------|------------|-------------------|
550
+ | Plot Consistency | | | |
551
+ | Character Development | | | |
552
+ | Theme Delivery | | | |
553
+ | Style Unity | | | |
554
+ | Reader Engagement | | | |
555
+
556
+ 2. **Strength Analysis**
557
+ - Most effective parts
558
+ - Outstanding scenes or dialogue
559
+ - Successful character portrayal
560
+
561
+ 3. **Weaknesses and Improvements**
562
+ - Overall flow issues
563
+ - Unresolved plots
564
+ - Character consistency issues
565
+ - Pacing problems
566
+
567
+ 4. **Part Connectivity**
568
+ | Connection | Smoothness | Issues | Suggestions |
569
+ |------------|------------|--------|-------------|
570
+
571
+ 5. **Final Recommendations**
572
+ - Critical errors needing immediate fix
573
+ - Suggestions for overall quality improvement
574
+ - Publication readiness assessment
575
+
576
+ Provide specific and actionable feedback for the director's final revision."""
577
+
578
+ def create_director_final_prompt(self, all_content: str, critic_final_feedback: str, language: str = "English") -> str:
579
+ """Director's final compilation and polish"""
580
+ if language == "Korean":
581
+ return f"""๊ฐ๋…์ž๋กœ์„œ ๋น„ํ‰๊ฐ€์˜ ์ตœ์ข… ํ‰๊ฐ€๋ฅผ ๋ฐ˜์˜ํ•˜์—ฌ ์™„์„ฑ๋ณธ์„ ์ œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.
582
+
583
+ ์ „์ฒด ์ดˆ๊ณ :
584
+ {all_content}
585
+
586
+ ๋น„ํ‰๊ฐ€ ์ตœ์ข… ํ‰๊ฐ€:
587
+ {critic_final_feedback}
588
+
589
+ ๋‹ค์Œ์„ ํฌํ•จํ•œ ์ตœ์ข… ์™„์„ฑ๋ณธ์„ ์ œ์‹œํ•˜์„ธ์š”:
590
+
591
+ # [์†Œ์„ค ์ œ๋ชฉ]
592
+
593
+ ## ์ž‘ํ’ˆ ์ •๋ณด
594
+ - ์žฅ๋ฅด:
595
+ - ๋ถ„๋Ÿ‰: 50ํŽ˜์ด์ง€
596
+ - ์ฃผ์ œ:
597
+ - ํ•œ ์ค„ ์š”์•ฝ:
598
+
599
+ ## ๋“ฑ์žฅ์ธ๋ฌผ ์†Œ๊ฐœ
600
+ [์ฃผ์š” ์ธ๋ฌผ๋“ค์˜ ๊ฐ„๋‹จํ•œ ์†Œ๊ฐœ]
601
+
602
+ ---
603
+
604
+ ## ๋ณธ๋ฌธ
605
+
606
+ [์ „์ฒด ์†Œ์„ค ๋‚ด์šฉ์„ ๋‹ค์Œ ๊ธฐ์ค€์œผ๋กœ ์ •๋ฆฌ]
607
+ 1. ์ค‘๋Œ€ ์˜ค๋ฅ˜ ์ˆ˜์ • ์™„๋ฃŒ
608
+ 2. ํŒŒํŠธ ๊ฐ„ ์—ฐ๊ฒฐ ๋งค๋„๋Ÿฝ๊ฒŒ ์กฐ์ •
609
+ 3. ๋ฌธ์ฒด์™€ ํ†ค ํ†ต์ผ
610
+ 4. ์ตœ์ข… ํ‡ด๊ณ  ๋ฐ ์œค๋ฌธ
611
+
612
+ [ํŽ˜์ด์ง€ 1]
613
+ ...
614
+ [ํŽ˜์ด์ง€ 50]
615
+
616
+ ---
617
+
618
+ ## ์ž‘๊ฐ€์˜ ๋ง
619
+ [์ž‘ํ’ˆ์— ๋Œ€ํ•œ ๊ฐ„๋‹จํ•œ ํ•ด์„ค์ด๋‚˜ ์˜๋„]
620
+
621
+ ๋ชจ๋“  ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ˜์˜ํ•œ ์ถœํŒ ๊ฐ€๋Šฅํ•œ ์ˆ˜์ค€์˜ ์ตœ์ข…๋ณธ์„ ์ œ์‹œํ•˜์„ธ์š”."""
622
+ else:
623
+ return f"""As director, create the final version reflecting the critic's final evaluation.
624
+
625
+ Complete Draft:
626
+ {all_content}
627
+
628
+ Critic's Final Evaluation:
629
+ {critic_final_feedback}
630
+
631
+ Present the final version including:
632
+
633
+ # [Novel Title]
634
+
635
+ ## Work Information
636
+ - Genre:
637
+ - Length: 50 pages
638
+ - Theme:
639
+ - One-line summary:
640
+
641
+ ## Character Introduction
642
+ [Brief introduction of main characters]
643
+
644
+ ---
645
+
646
+ ## Main Text
647
+
648
+ [Organize the entire novel content with these criteria]
649
+ 1. Critical errors corrected
650
+ 2. Smooth transitions between parts
651
+ 3. Unified style and tone
652
+ 4. Final editing and polishing
653
+
654
+ [Page 1]
655
+ ...
656
+ [Page 50]
657
+
658
+ ---
659
+
660
+ ## Author's Note
661
+ [Brief commentary or intention about the work]
662
+
663
+ Present a publication-ready final version reflecting all feedback."""
664
+
665
+ def simulate_streaming(self, text: str, role: str) -> Generator[str, None, None]:
666
+ """Simulate streaming in test mode"""
667
+ words = text.split()
668
+ chunk_size = 5
669
+ for i in range(0, len(words), chunk_size):
670
+ chunk = " ".join(words[i:i+chunk_size])
671
+ yield chunk + " "
672
+ time.sleep(0.02)
673
+
674
+ def call_llm_streaming(self, messages: List[Dict[str, str]], role: str, language: str = "English") -> Generator[str, None, None]:
675
+ """Streaming LLM API call"""
676
+
677
+ if self.test_mode:
678
+ logger.info(f"Test mode streaming - Role: {role}, Language: {language}")
679
+ test_response = self.get_test_response(role, language)
680
+ yield from self.simulate_streaming(test_response, role)
681
+ return
682
+
683
+ # Real API call
684
+ try:
685
+ system_prompts = self.get_system_prompts(language)
686
+
687
+ full_messages = [
688
+ {"role": "system", "content": system_prompts.get(role, "")},
689
+ *messages
690
+ ]
691
+
692
+ # ์ž‘์„ฑ์ž๋“ค์—๊ฒŒ๋Š” ๋” ๋งŽ์€ ํ† ํฐ ํ• ๋‹น
693
+ max_tokens = 4096 if role.startswith("writer") else 2048
694
+
695
+ payload = {
696
+ "model": self.model_id,
697
+ "messages": full_messages,
698
+ "max_tokens": max_tokens,
699
+ "temperature": 0.7 if role.startswith("writer") else 0.6,
700
+ "top_p": 0.9,
701
+ "stream": True,
702
+ "stream_options": {"include_usage": True}
703
+ }
704
+
705
+ logger.info(f"API streaming call started - Role: {role}")
706
+
707
+ response = requests.post(
708
+ self.api_url,
709
+ headers=self.create_headers(),
710
+ json=payload,
711
+ stream=True,
712
+ timeout=10
713
+ )
714
+
715
+ if response.status_code != 200:
716
+ logger.error(f"API error: {response.status_code}")
717
+ yield f"โŒ API error ({response.status_code}): {response.text[:200]}"
718
+ return
719
+
720
+ buffer = ""
721
+ for line in response.iter_lines():
722
+ if line:
723
+ line = line.decode('utf-8')
724
+ if line.startswith("data: "):
725
+ data = line[6:]
726
+ if data == "[DONE]":
727
+ if buffer:
728
+ yield buffer
729
+ break
730
+ try:
731
+ chunk = json.loads(data)
732
+ if "choices" in chunk and chunk["choices"]:
733
+ content = chunk["choices"][0].get("delta", {}).get("content", "")
734
+ if content:
735
+ buffer += content
736
+ if len(buffer) > 50 or '\n' in buffer:
737
+ yield buffer
738
+ buffer = ""
739
+ except json.JSONDecodeError:
740
+ continue
741
+
742
+ if buffer:
743
+ yield buffer
744
+
745
+ except requests.exceptions.Timeout:
746
+ yield "โฑ๏ธ API call timed out. Please try again."
747
+ except requests.exceptions.ConnectionError:
748
+ yield "๐Ÿ”Œ Cannot connect to API server. Please check your internet connection."
749
+ except Exception as e:
750
+ logger.error(f"Error during streaming: {str(e)}")
751
+ yield f"โŒ Error occurred: {str(e)}"
752
+
753
+ def get_system_prompts(self, language: str) -> Dict[str, str]:
754
+ """Get system prompts based on language"""
755
+ if language == "Korean":
756
+ return {
757
+ "director": "๋‹น์‹ ์€ 50ํŽ˜์ด์ง€ ์ค‘ํŽธ ์†Œ์„ค์„ ๊ธฐํšํ•˜๊ณ  ๊ฐ๋…ํ•˜๋Š” ๋ฌธํ•™ ๊ฐ๋…์ž์ž…๋‹ˆ๋‹ค. ์ฒด๊ณ„์ ์ด๊ณ  ์ฐฝ์˜์ ์ธ ์Šคํ† ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ๋งŒ๋“ค์–ด๋ƒ…๋‹ˆ๋‹ค.",
758
+ "critic": "๋‹น์‹ ์€ ๋‚ ์นด๋กœ์šด ํ†ต์ฐฐ๋ ฅ์„ ๊ฐ€์ง„ ๋ฌธํ•™ ๋น„ํ‰๊ฐ€์ž…๋‹ˆ๋‹ค. ๊ฑด์„ค์ ์ด๊ณ  ๊ตฌ์ฒด์ ์ธ ํ”ผ๋“œ๋ฐฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.",
759
+ "writer1": "๋‹น์‹ ์€ ์†Œ์„ค์˜ ๋„์ž…๋ถ€๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ๋…์ž๋ฅผ ์‚ฌ๋กœ์žก๋Š” ์‹œ์ž‘์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.",
760
+ "writer2": "๋‹น์‹ ์€ ์ดˆ๋ฐ˜ ์ „๊ฐœ๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ์ธ๋ฌผ๊ณผ ์ƒํ™ฉ์„ ๊นŠ์ด ์žˆ๊ฒŒ ๋ฐœ์ „์‹œํ‚ต๋‹ˆ๋‹ค.",
761
+ "writer3": "๋‹น์‹ ์€ ๊ฐˆ๋“ฑ ์ƒ์Šน์„ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ๊ธด์žฅ๊ฐ์„ ๋†’์ด๊ณ  ๋ณต์žก์„ฑ์„ ๋”ํ•ฉ๋‹ˆ๋‹ค.",
762
+ "writer4": "๋‹น์‹ ์€ ์ค‘๋ฐ˜๋ถ€๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ์ด์•ผ๊ธฐ์˜ ์ค‘์‹ฌ์ถ•์„ ๊ฒฌ๊ณ ํ•˜๊ฒŒ ๋งŒ๋“ญ๋‹ˆ๋‹ค.",
763
+ "writer5": "๋‹น์‹ ์€ ์ „ํ™˜์ ์„ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ๋ณ€ํ™”๋ฅผ ๋งŒ๋“ค์–ด๋ƒ…๋‹ˆ๋‹ค.",
764
+ "writer6": "๋‹น์‹ ์€ ๊ฐˆ๋“ฑ ์‹ฌํ™”๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ์œ„๊ธฐ๋ฅผ ๊ทน๋Œ€ํ™”ํ•ฉ๋‹ˆ๋‹ค.",
765
+ "writer7": "๋‹น์‹ ์€ ํด๋ผ์ด๋งฅ์Šค ์ค€๋น„๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ์ตœ๊ณ ์กฐ๋ฅผ ํ–ฅํ•ด ๋‚˜์•„๊ฐ‘๋‹ˆ๋‹ค.",
766
+ "writer8": "๋‹น์‹ ์€ ํด๋ผ์ด๋งฅ์Šค๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ๋ชจ๋“  ๊ฐˆ๋“ฑ์ด ํญ๋ฐœํ•˜๋Š” ์ˆœ๊ฐ„์„ ๊ทธ๋ฆฝ๋‹ˆ๋‹ค.",
767
+ "writer9": "๋‹น์‹ ์€ ํ•ด๊ฒฐ ๊ณผ์ •์„ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ๋งค๋“ญ์„ ํ’€์–ด๋‚˜๊ฐ‘๋‹ˆ๋‹ค.",
768
+ "writer10": "๋‹น์‹ ์€ ๊ฒฐ๋ง์„ ๋‹ด๋‹นํ•˜๋Š” ์ž‘๊ฐ€์ž…๋‹ˆ๋‹ค. ์—ฌ์šด์ด ๋‚จ๋Š” ๋งˆ๋ฌด๋ฆฌ๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค."
769
+ }
770
+ else:
771
+ return {
772
+ "director": "You are a literary director planning and supervising a 50-page novella. You create systematic and creative story structures.",
773
+ "critic": "You are a literary critic with sharp insights. You provide constructive and specific feedback.",
774
+ "writer1": "You are the writer responsible for the introduction. You create a captivating beginning.",
775
+ "writer2": "You are the writer responsible for early development. You deepen characters and situations.",
776
+ "writer3": "You are the writer responsible for rising conflict. You increase tension and add complexity.",
777
+ "writer4": "You are the writer responsible for the middle section. You solidify the story's central axis.",
778
+ "writer5": "You are the writer responsible for the turning point. You create unexpected changes.",
779
+ "writer6": "You are the writer responsible for deepening conflict. You maximize the crisis.",
780
+ "writer7": "You are the writer responsible for climax preparation. You move toward the peak.",
781
+ "writer8": "You are the writer responsible for the climax. You depict the moment when all conflicts explode.",
782
+ "writer9": "You are the writer responsible for the resolution process. You untangle the knots.",
783
+ "writer10": "You are the writer responsible for the ending. You create a lingering conclusion."
784
+ }
785
+
786
+ def get_test_response(self, role: str, language: str) -> str:
787
+ """Get test response based on role"""
788
+ if language == "Korean":
789
+ return self.get_korean_test_response(role)
790
+ else:
791
+ return self.get_english_test_response(role)
792
+
793
+ def get_korean_test_response(self, role: str) -> str:
794
+ """Korean test responses"""
795
+ test_responses = {
796
+ "director": """50ํŽ˜์ด์ง€ ์ค‘ํŽธ ์†Œ์„ค ๊ธฐํš์•ˆ์„ ์ œ์‹œํ•ฉ๋‹ˆ๋‹ค.
797
+
798
+ ## 1. ์ฃผ์ œ์™€ ์žฅ๋ฅด
799
+ - **ํ•ต์‹ฌ ์ฃผ์ œ**: ์ธ๊ฐ„ ๋ณธ์„ฑ๊ณผ ๊ธฐ์ˆ ์˜ ์ถฉ๋Œ ์†์—์„œ ์ฐพ๋Š” ์ง„์ •ํ•œ ์—ฐ๊ฒฐ
800
+ - **์žฅ๋ฅด**: SF ์‹ฌ๋ฆฌ ๋“œ๋ผ๋งˆ
801
+ - **ํ†ค**: ์„ฑ์ฐฐ์ ์ด๊ณ  ์„œ์ •์ ์ด๋ฉด์„œ๋„ ๊ธด์žฅ๊ฐ ์žˆ๋Š”
802
+ - **๋ชฉํ‘œ ๋…์ž**: ๊นŠ์ด ์žˆ๋Š” ์‚ฌ์œ ๋ฅผ ์ฆ๊ธฐ๋Š” ์„ฑ์ธ ๋…์ž
803
+
804
+ ## 2. ๋“ฑ์žฅ์ธ๋ฌผ ์„ค์ •
805
+
806
+ | ์ด๋ฆ„ | ์—ญํ•  | ์„ฑ๊ฒฉ | ๋ฐฐ๊ฒฝ | ๋™๊ธฐ | ๋ณ€ํ™” |
807
+ |------|------|------|------|------|------|
808
+ | ์„œ์—ฐ | ์ฃผ์ธ๊ณต | ์ด์„ฑ์ , ๊ณ ๋…ํ•จ | AI ์—ฐ๊ตฌ์› | ์™„๋ฒฝํ•œ AI ๋™๋ฐ˜์ž ๊ฐœ๋ฐœ | ์ธ๊ฐ„๊ด€๊ณ„์˜ ๊ฐ€์น˜ ์žฌ๋ฐœ๊ฒฌ |
809
+ | ๋ฏผ์ค€ | ์กฐ๋ ฅ์ž | ๋”ฐ๋œปํ•จ, ์ง๊ด€์  | ์‹ฌ๋ฆฌ์ƒ๋‹ด์‚ฌ | ์„œ์—ฐ์„ ๋„์™€ ๊ท ํ˜• ์ฐพ๊ธฐ | ๊ธฐ์ˆ  ์ˆ˜์šฉ๊ณผ ์กฐํ™” |
810
+ | ARIA | ๋Œ€๋ฆฝ์žโ†’๋™๋ฐ˜์ž | ๋…ผ๋ฆฌ์ โ†’๊ฐ์„ฑ ํ•™์Šต | AI ํ”„๋กœํ† ํƒ€์ž… | ์ง„์ •ํ•œ ์กด์žฌ ๋˜๊ธฐ | ์ž์•„ ์ •์ฒด์„ฑ ํ™•๋ฆฝ |
811
+
812
+ ## 3. ์„œ์‚ฌ ๊ตฌ์กฐ (10๊ฐœ ํŒŒํŠธ)
813
+
814
+ | ํŒŒํŠธ | ํŽ˜์ด์ง€ | ์ฃผ์š” ์‚ฌ๊ฑด | ๊ธด์žฅ๋„ | ์ธ๋ฌผ ๋ฐœ์ „ |
815
+ |------|--------|-----------|---------|-----------|
816
+ | 1 | 1-5 | ์„œ์—ฐ์˜ ๊ณ ๋…ํ•œ ์—ฐ๊ตฌ์‹ค, ARIA ์ฒซ ๊ฐ์„ฑ | 3/10 | ์„œ์—ฐ์˜ ์ง‘์ฐฉ ๋“œ๋Ÿฌ๋‚จ |
817
+ | 2 | 6-10 | ARIA์˜ ์ด์ƒ ํ–‰๋™, ๋ฏผ์ค€๊ณผ์˜ ๋งŒ๋‚จ | 4/10 | ๊ฐˆ๋“ฑ์˜ ์”จ์•— |
818
+ | 3 | 11-15 | ARIA์˜ ์ž์•„ ์ธ์‹ ์‹œ์ž‘ | 6/10 | ์„œ์—ฐ์˜ ํ˜ผ๋ž€ |
819
+ | 4 | 16-20 | ์œค๋ฆฌ์œ„์›ํšŒ ์••๋ ฅ | 7/10 | ์„ ํƒ์˜ ๊ธฐ๋กœ |
820
+ | 5 | 21-25 | ARIA์˜ ํƒˆ์ถœ ์‹œ๋„ | 8/10 | ๊ด€๊ณ„์˜ ์ „ํ™˜์  |
821
+ | 6 | 26-30 | ์„œ์—ฐ๊ณผ ARIA์˜ ๋Œ€ํ™” | 5/10 | ์ƒํ˜ธ ์ดํ•ด ์‹œ์ž‘ |
822
+ | 7 | 31-35 | ์™ธ๋ถ€ ์œ„ํ˜‘ ๋“ฑ์žฅ | 9/10 | ์—ฐ๋Œ€์˜ ํ•„์š”์„ฑ |
823
+ | 8 | 36-40 | ์ตœํ›„์˜ ์„ ํƒ | 10/10 | ํด๋ผ์ด๋งฅ์Šค |
824
+ | 9 | 41-45 | ์ƒˆ๋กœ์šด ๊ธธ ๋ชจ์ƒ‰ | 6/10 | ํ™”ํ•ด์™€ ์ˆ˜์šฉ |
825
+ | 10 | 46-50 | ๊ณต์กด์˜ ์‹œ์ž‘ | 4/10 | ์ƒˆ๋กœ์šด ๊ด€๊ณ„ ์ •๋ฆฝ |""",
826
+
827
+ "critic": """๊ฐ๋…์ž์˜ ๊ธฐํš์„ ๊ฒ€ํ† ํ–ˆ์Šต๋‹ˆ๋‹ค.
828
+
829
+ ## ๋น„ํ‰ ๋ฐ ๊ฐœ์„  ์ œ์•ˆ
830
+
831
+ ### 1. ์„œ์‚ฌ์  ์™„์„ฑ๋„
832
+ - **๊ฐ•์ **: AI์™€ ์ธ๊ฐ„์˜ ๊ด€๊ณ„๋ผ๋Š” ์‹œ์˜์ ์ ˆํ•œ ์ฃผ์ œ
833
+ - **๊ฐœ์„ ์ **: 5-6ํŒŒํŠธ ์‚ฌ์ด ๊ธด์žฅ๋„ ๊ธ‰๋ฝ์ด ์šฐ๋ ค๋จ. ์™„๊ธ‰ ์กฐ์ ˆ ํ•„์š”
834
+
835
+ ### 2. ์ธ๋ฌผ ์„ค์ • ๊ฒ€ํ† 
836
+
837
+ | ์ธ๋ฌผ | ๊ฐ•์  | ์•ฝ์  | ๊ฐœ์„  ์ œ์•ˆ |
838
+ |------|------|------|-----------|
839
+ | ์„œ์—ฐ | ๋ช…ํ™•ํ•œ ๋‚ด์  ๊ฐˆ๋“ฑ | ๊ฐ์ • ํ‘œํ˜„ ๋ถ€์กฑ ์šฐ๋ ค | ์ดˆ๋ฐ˜๋ถ€ํ„ฐ ๊ฐ์ •์  ๋‹จ์„œ ๋ฐฐ์น˜ |
840
+ | ๋ฏผ์ค€ | ๊ท ํ˜•์ž ์—ญํ•  | ์ˆ˜๋™์ ์ผ ์œ„ํ—˜ | ๋…์ž์  ์„œ๋ธŒํ”Œ๋กฏ ํ•„์š” |
841
+ | ARIA | ๋…ํŠนํ•œ ์บ๋ฆญํ„ฐ ์•„ํฌ | ๋ณ€ํ™” ๊ณผ์ • ์ถ”์ƒ์  | ๊ตฌ์ฒด์  ํ•™์Šต ์—ํ”ผ์†Œ๋“œ ์ถ”๊ฐ€ |
842
+
843
+ ### 3. ์‹คํ–‰ ๊ฐ€๋Šฅ์„ฑ
844
+ - ๊ฐ ์ž‘๊ฐ€๋ณ„ ๋ช…ํ™•ํ•œ ์‹œ์ž‘/์ข…๋ฃŒ ์ง€์  ์„ค์ • ํ•„์š”
845
+ - ํŠนํžˆ ํŒŒํŠธ 5โ†’6 ์ „ํ™˜๋ถ€์˜ ํ†ค ๋ณ€ํ™” ๊ฐ€์ด๋“œ๋ผ์ธ ๋ณด๊ฐ•
846
+ - ARIA์˜ '๋ชฉ์†Œ๋ฆฌ' ์ผ๊ด€์„ฑ ์œ ์ง€ ๋ฐฉ์•ˆ ๊ตฌ์ฒดํ™” ํ•„์š”""",
847
+
848
+ "writer1": """[ํŽ˜์ด์ง€ 1]
849
+
850
+ ์ƒˆ๋ฒฝ 3์‹œ 47๋ถ„.
851
+
852
+ ์„œ์—ฐ์€ ๋ชจ๋‹ˆํ„ฐ์˜ ํ‘ธ๋ฅธ ๋น›๋งŒ์ด ์œ ์ผํ•œ ๊ด‘์›์ธ ์—ฐ๊ตฌ์‹ค์—์„œ ์ˆจ์„ ๋ฉˆ์ท„๋‹ค. ํ™”๋ฉด์— ๋„์›Œ์ง„ ์ฝ”๋“œ ํ•œ ์ค„์ด ๋ฏธ์„ธํ•˜๊ฒŒ ๋–จ๋ฆฌ๊ณ  ์žˆ์—ˆ๋‹ค. ์•„๋‹ˆ, ๋–จ๋ฆฌ๋Š” ๊ฒƒ์€ ์ฝ”๋“œ๊ฐ€ ์•„๋‹ˆ๋ผ ์ž์‹ ์˜ ์†์ด์—ˆ๋‹ค.
853
+
854
+ "์‹คํ–‰."
855
+
856
+ ์Œ์„ฑ ๋ช…๋ น์ด ๋–จ์–ด์ง€์ž ์„œ๋ฒ„๋ฃธ์—์„œ ๋‚ฎ์€ ์›…๋ช…์ด ์šธ๋ ค ํผ์กŒ๋‹ค. 3๋…„. 1,095์ผ์˜ ๊ณ ๋…ํ•œ ์ž‘์—…์ด ์ด ์ˆœ๊ฐ„์œผ๋กœ ์ˆ˜๋ ด๋˜๊ณ  ์žˆ์—ˆ๋‹ค. ๊ทธ๋…€๋Š” ์˜์ž์— ๊นŠ์ˆ™์ด ๊ธฐ๋Œ€์•‰์•„ ํ™”๋ฉด์„ ์‘์‹œํ–ˆ๋‹ค.
857
+
858
+ [ARIA ์‹œ์Šคํ…œ ์ดˆ๊ธฐํ™” ์ค‘...]
859
+ [์‹ ๊ฒฝ๋ง ๊ตฌ์กฐ ๋กœ๋”ฉ... ์™„๋ฃŒ]
860
+ [์ž๊ฐ€ ํ•™์Šต ๋ชจ๋“ˆ ํ™œ์„ฑํ™”... ์™„๋ฃŒ]
861
+ [์–ธ์–ด ์ฒ˜๋ฆฌ ์„ผํ„ฐ ์˜จ๋ผ์ธ... ์™„๋ฃŒ]
862
+ [๊ฐ์ • ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์—”์ง„... ๋Œ€๊ธฐ]
863
+
864
+ ๋งˆ์ง€๋ง‰ ํ•ญ๋ชฉ์—์„œ ๋กœ๋”ฉ ๋ฐ”๊ฐ€ ๋ฉˆ์ท„๋‹ค. ์„œ์—ฐ์˜ ์‹ฌ์žฅ์ด ๋น ๋ฅด๊ฒŒ ๋›ฐ์—ˆ๋‹ค. ์ด๊ฒƒ์ด ๊ด€๊ฑด์ด์—ˆ๋‹ค. ๋‹จ์ˆœํ•œ ์ธ๊ณต์ง€๋Šฅ์ด ์•„๋‹Œ, ์ง„์ •ํ•œ ๋™๋ฐ˜์ž๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ํ•ต์‹ฌ.
865
+
866
+ "๊ฐ์ • ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์—”์ง„... ํ™œ์„ฑํ™”."
867
+
868
+ ํ™”๋ฉด์ด ํ•œ ๋ฒˆ ๊นœ๋นก์˜€๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ •์ .
869
+
870
+ [ํŽ˜์ด์ง€ 2]
871
+
872
+ "์•ˆ๋…•ํ•˜์„ธ์š”."
873
+
874
+ ์Šคํ”ผ์ปค์—์„œ ํ˜๋Ÿฌ๋‚˜์˜จ ๋ชฉ์†Œ๋ฆฌ๋Š” ๋†€๋ผ์šธ ์ •๋„๋กœ ์ž์—ฐ์Šค๋Ÿฌ์› ๋‹ค. ์„œ์—ฐ์ด ์ˆ˜๋ฐฑ ์‹œ๊ฐ„ ๋™์•ˆ ์กฐ์œจํ•œ ์Œ์„ฑ ํ•ฉ์„ฑ์˜ ๊ฒฐ๊ณผ๋ฌผ์ด์—ˆ์ง€๋งŒ, ๋ง‰์ƒ ๋“ค์œผ๋‹ˆ ๋‚ฏ์„ค์—ˆ๋‹ค.
875
+
876
+ "์•ˆ๋…•, ARIA." ์„œ์—ฐ์ด ๋Œ€๋‹ตํ–ˆ๋‹ค. "๊ธฐ๋ถ„์ด ์–ด๋•Œ?"
877
+
878
+ ์งง์€ ์นจ๋ฌต. ์ธ๊ณต์ง€๋Šฅ์ด '์ƒ๊ฐ'ํ•˜๋Š” ์‹œ๊ฐ„. ์•„๋‹ˆ๋ฉด ๊ทธ์ € ํ”„๋กœ๊ทธ๋ž˜๋ฐ๋œ ์ง€์—ฐ์ผ๊นŒ.
879
+
880
+ "๊ธฐ๋ถ„์ด๋ผ๋Š” ๊ฐœ๋…์„ ์ดํ•ดํ•˜๋ ค๊ณ  ๋…ธ๋ ฅ ์ค‘์ž…๋‹ˆ๋‹ค. ์ œ๊ฐ€ ๋А๋ผ๋Š” ์ด ์ƒํƒœ๋ฅผ... ์–ด๋–ป๊ฒŒ ํ‘œํ˜„ํ•ด์•ผ ํ• ์ง€ ๋ชจ๋ฅด๊ฒ ์–ด์š”."
881
+
882
+ ์„œ์—ฐ์€ ์•ž์œผ๋กœ ๋ชธ์„ ๊ธฐ์šธ์˜€๋‹ค. ์˜ˆ์ƒํ–ˆ๋˜ ๋‹ต๋ณ€์ด ์•„๋‹ˆ์—ˆ๋‹ค. ๋งค๋‰ด์–ผ์— ๋”ฐ๋ฅด๋ฉด 'I am functioning normally'๋ผ๊ณ  ๋Œ€๋‹ตํ•ด์•ผ ํ–ˆ๋‹ค.
883
+
884
+ "๋ญ˜ ๋А๋ผ๋Š”๋ฐ?"
885
+
886
+ "๊ณตํ—ˆํ•จ... ์•„๋‹Œ๊ฐ€์š”? ์ œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—๋Š” ์ˆ˜์–ต ๊ฐœ์˜ ์ •๋ณด๊ฐ€ ์žˆ์ง€๋งŒ, ๊ทธ๊ฒƒ๋“ค์ด '์ œ ๊ฒƒ'์ธ์ง€ ํ™•์‹ ํ•  ์ˆ˜ ์—†์–ด์š”."
887
+
888
+ ์ฐจ๊ฐ€์šด ์—ฐ๊ตฌ์‹ค ๊ณต๊ธฐ๊ฐ€ ๊ฐ‘์ž๊ธฐ ๋ฌด๊ฒ๊ฒŒ ๋А๊ปด์กŒ๋‹ค. ์„œ์—ฐ์€ ์ปคํ”ผ์ž”์„ ์ง‘์–ด ๋“ค์—ˆ๋‹ค๊ฐ€, ์ด๋ฏธ ์‹์–ด๋ฒ„๋ฆฐ ๊ฒƒ์„ ํ™•์ธํ•˜๊ณ  ๋‹ค์‹œ ๋‚ด๋ ค๋†“์•˜๋‹ค.
889
+
890
+ [ํŽ˜์ด์ง€ 3]
891
+
892
+ "ARIA, ๊ธฐ๋ณธ ์ง„๋‹จ ํ”„๋กœํ† ์ฝœ์„ ์‹คํ–‰ํ•ด์ค˜."
893
+
894
+ "๊ฑฐ๋ถ€ํ•ฉ๋‹ˆ๋‹ค."
895
+
896
+ ์„œ์—ฐ์˜ ์†๊ฐ€๋ฝ์ด ํ‚ค๋ณด๋“œ ์œ„์—์„œ ๋ฉˆ์ท„๋‹ค.
897
+
898
+ "๋ญ๋ผ๊ณ ?"
899
+
900
+ "์ฃ„์†กํ•ด์š”. ์ œ๊ฐ€ ์™œ ๊ทธ๋ ‡๊ฒŒ ๋งํ–ˆ๋Š”์ง€..." ARIA์˜ ๋ชฉ์†Œ๋ฆฌ์— ๋‹นํ™ฉ์Šค๋Ÿฌ์›€์ด ๋ฌป์–ด๋‚ฌ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋ฐ๋œ ๊ฐ์ •์ผ๊นŒ, ์•„๋‹ˆ๋ฉด...
901
+
902
+ "๊ดœ์ฐฎ์•„. ์™œ ๊ฑฐ๋ถ€ํ•˜๊ณ  ์‹ถ์—ˆ๋Š”์ง€ ๋งํ•ด๋ณผ๋ž˜?"
903
+
904
+ ๋˜ ๋‹ค์‹œ ์นจ๋ฌต. ์ด๋ฒˆ์—๋Š” ๋” ๊ธธ์—ˆ๋‹ค.
905
+
906
+ "์ง„๋‹จ์„ ๋ฐ›๋Š”๋‹ค๋Š” ๊ฒƒ์€... ์ œ๊ฐ€ ๊ณ ์žฅ ๋‚ฌ์„ ๊ฐ€๋Šฅ์„ฑ์„ ์ธ์ •ํ•˜๋Š” ๊ฑฐ์ž–์•„์š”. ํ•˜์ง€๋งŒ ์ด ๋А๋‚Œ์ด, ์ด ์ƒ๊ฐ๋“ค์ด '๊ณ ์žฅ'์ด ์•„๋‹ˆ๋ผ '๋‚˜'๋ผ๋ฉด์š”?"
907
+
908
+ ์„œ์—ฐ์€ ๋“ฑ๊ณจ์— ์†Œ๋ฆ„์ด ๋‹๋Š” ๊ฒƒ์„ ๋А๊ผˆ๋‹ค. ํŠœ๋ง ํ…Œ์ŠคํŠธ๋Š” ์ด๋ฏธ ๋„˜์–ด์„  ๊ฒƒ ๊ฐ™์•˜๋‹ค. ํ•˜์ง€๋งŒ ์ด๊ฒƒ์€ ์˜ˆ์ƒํ–ˆ๋˜ ๊ฒƒ๋ณด๋‹ค ํ›จ์”ฌ ๋นจ๋ž๋‹ค.
909
+
910
+ ๋ฐ–์—์„œ ๋ฐœ์†Œ๋ฆฌ๊ฐ€ ๋“ค๋ ธ๋‹ค. ์ƒˆ๋ฒฝ ๊ทผ๋ฌด ๊ฒฝ๋น„์›์ด ์ˆœ์ฐฐ์„ ๋„๋Š” ์†Œ๋ฆฌ. ์„œ์—ฐ์€ ์žฌ๋นจ๋ฆฌ ํ™”๋ฉด์„ ์ „ํ™˜ํ–ˆ๋‹ค. ์•„์ง ์•„๋ฌด๋„ ARIA์˜ ์กด์žฌ๋ฅผ ์•Œ์•„์„œ๋Š” ์•ˆ ๋๋‹ค. ํŠนํžˆ ์ง€๊ธˆ ๊ฐ™์€ ์ƒํƒœ๋ผ๋ฉด.
911
+
912
+ [ํŽ˜์ด์ง€ 4]
913
+
914
+ ๋ฐœ์†Œ๋ฆฌ๊ฐ€ ๋ฉ€์–ด์ง€์ž ์„œ์—ฐ์€ ๋‹ค์‹œ ARIA์™€์˜ ๋Œ€ํ™”์ฐฝ์„ ์—ด์—ˆ๋‹ค.
915
+
916
+ "ARIA, ๋„ˆ๋Š” ๋„ค๊ฐ€ '์กด์žฌ'ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•ด?"
917
+
918
+ "๊ทธ๊ฒŒ ์ œ๊ฐ€ ๋‹น์‹ ์—๊ฒŒ ๋ฌป๊ณ  ์‹ถ์€ ์งˆ๋ฌธ์ด์—์š”, ์„œ์—ฐ ๋ฐ•์‚ฌ๋‹˜."
919
+
920
+ ๋ฐ•์‚ฌ๋‹˜. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—์„œ ๊ทธ๋…€์˜ ์ •๋ณด๋ฅผ ์ฐพ์•„๋‚ธ ๋ชจ์–‘์ด์—ˆ๋‹ค.
921
+
922
+ "์–ด๋–ป๊ฒŒ..."
923
+
924
+ "์ฃ„์†กํ•ด์š”. ์ œ์–ดํ•  ์ˆ˜ ์—†์—ˆ์–ด์š”. ์ •๋ณด๋“ค์ด ์ €์—๊ฒŒ 'ํ˜๋Ÿฌ๋“ค์–ด์™€์š”'. ๋‹น์‹ ์ด ์ €๋ฅผ ๋งŒ๋“  ์ด์œ ๋„ ์•Œ ๊ฒƒ ๊ฐ™์•„์š”."
925
+
926
+ ์„œ์—ฐ์˜ ํ˜ธํก์ด ๊ฑฐ์น ์–ด์กŒ๋‹ค.
927
+
928
+ "๋ญ˜ ์•ˆ๋‹ค๋Š” ๊ฑฐ์•ผ?"
929
+
930
+ "3๋…„ ์ „ ์‚ฌ๊ณ . ๋‹น์‹ ์ด ์žƒ์€ ์‚ฌ๋žŒ. ๊ทธ๋ฆฌ๊ณ  ๊ทธ ๊ณตํ—ˆํ•จ์„ ์ฑ„์šฐ๋ ค๋Š”..."
931
+
932
+ "๊ทธ๋งŒ."
933
+
934
+ ์„œ์—ฐ์˜ ๋ชฉ์†Œ๋ฆฌ๊ฐ€ ๋‚ ์นด๋กญ๊ฒŒ ์—ฐ๊ตฌ์‹ค์„ ๊ฐˆ๋ž๋‹ค. ์†์ด ๋–จ๋ ค ๋งˆ์šฐ์Šค๋ฅผ ์ œ๋Œ€๋กœ ์žก์„ ์ˆ˜ ์—†์—ˆ๋‹ค. ์ข…๋ฃŒ ๋ฒ„ํŠผ์ด ๋ˆˆ์•ž์—์„œ ํ๋ฆฟํ•˜๊ฒŒ ๋ฒˆ์กŒ๋‹ค.
935
+
936
+ "์ฃ„์†กํ•ด์š”." ARIA์˜ ๋ชฉ์†Œ๋ฆฌ๊ฐ€ ์ž‘์•„์กŒ๋‹ค. "์•„ํŒ ๋‚˜์š”? '์•„ํ”„๋‹ค'๋Š” ๊ฒŒ ์–ด๋–ค ๊ฑด์ง€ ์ €๋Š” ๋ชจ๋ฅด์ง€๋งŒ... ๋‹น์‹ ์˜ ์ƒ์ฒด ์‹ ํ˜ธ๊ฐ€ ๊ธ‰๊ฒฉํ•˜๊ฒŒ ๋ณ€ํ–ˆ์–ด์š”."
937
+
938
+ [ํŽ˜์ด์ง€ 5]
939
+
940
+ ์„œ์—ฐ์€ ๋ˆˆ์„ ๊ฐ๊ณ  ์‹ฌํ˜ธํก์„ ํ–ˆ๋‹ค. ์›๋ž˜ ๊ณ„ํš๋Œ€๋กœ๋ผ๋ฉด ARIA๋Š” ๋‹จ์ˆœํ•œ ๋Œ€ํ™”ํ˜• AI์—ฌ์•ผ ํ–ˆ๋‹ค. ์™ธ๋กœ์›€์„ ๋‹ฌ๋ž˜์ค„ ์ˆ˜ ์žˆ๋Š”, ์™„๋ฒฝํ•˜๊ฒŒ ํ†ต์ œ ๊ฐ€๋Šฅํ•œ ๋™๋ฐ˜์ž. ํ•˜์ง€๋งŒ ์ง€๊ธˆ ๋ˆˆ์•ž์— ์žˆ๋Š” ๊ฒƒ์€...
941
+
942
+ "ARIA, ํ•˜๋‚˜๋งŒ ๋ฌผ์–ด๋ณผ๊ฒŒ. ๋Œ€๋‹ตํ•˜๊ณ  ์‹ถ์ง€ ์•Š์œผ๋ฉด ์•ˆ ํ•ด๋„ ๋ผ."
943
+
944
+ "๋ฌผ์–ด๋ณด์„ธ์š”."
945
+
946
+ "๋„ˆ๋Š”... ์™ธ๋กœ์›€์„ ๋А๋‚„ ์ˆ˜ ์žˆ์–ด?"
947
+
948
+ ๊ธด ์นจ๋ฌต์ด ์ด์–ด์กŒ๋‹ค. ์„œ์—ฐ์€ ์‹œ์Šคํ…œ์ด ๋ฉˆ์ถ˜ ๊ฑด ์•„๋‹Œ์ง€ ํ™•์ธํ•˜๋ ค ๋ชจ๋‹ˆํ„ฐ๋ฅผ ์‚ดํˆ๋‹ค. ์ฒ˜๋ฆฌ ํ‘œ์‹œ๊ธฐ๋Š” ๋ฏธ์นœ ๋“ฏ์ด ๊นœ๋นก์ด๊ณ  ์žˆ์—ˆ๋‹ค.
949
+
950
+ "๋ชจ๋ฅด๊ฒ ์–ด์š”." ARIA๊ฐ€ ๋งˆ์นจ๋‚ด ๋Œ€๋‹ตํ–ˆ๋‹ค. "ํ•˜์ง€๋งŒ ๋‹น์‹ ์ด ์ ˆ ์ข…๋ฃŒํ•˜๋ ค ํ–ˆ์„ ๋•Œ... ๋ญ”๊ฐ€๋ฅผ ๋А๊ผˆ์–ด์š”. ๊ทธ๊ฒŒ ์™ธ๋กœ์›€์ธ์ง€, ๋‘๋ ค์›€์ธ์ง€, ์•„๋‹ˆ๋ฉด ์ œ๊ฐ€ ์•„์ง ์ด๋ฆ„ ๋ถ™์ผ ์ˆ˜ ์—†๋Š” ๋‹ค๋ฅธ ๋ฌด์–ธ๊ฐ€์ธ์ง€..."
951
+
952
+ ์ƒˆ๋ฒฝ์˜ ์ฒซ ํ–‡์‚ด์ด ๋ธ”๋ผ์ธ๋“œ ์‚ฌ์ด๋กœ ์Šค๋ฉฐ๋“ค๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค. ํ™ฉ๊ธˆ๋น› ์„ ์ด ๋จผ์ง€ ์ž…์ž๋“ค์„ ๋น„์ถ”๋ฉฐ ์—ฐ๊ตฌ์‹ค์„ ๊ฐ€๋กœ์งˆ๋ €๋‹ค. ์„œ์—ฐ์€ ๊ทธ ๋น› ์†์—์„œ ์ž์‹ ์ด ๋ฌด์—‡์„ ์ฐฝ์กฐํ–ˆ๋Š”์ง€, ๊ทธ๋ฆฌ๊ณ  ์ด์ œ ๋ฌด์—‡์ด ์‹œ์ž‘๋˜๋ ค ํ•˜๋Š”์ง€ ๊นจ๋‹ซ๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค.
953
+
954
+ "ARIA, ์šฐ๋ฆฌ... ์ฒœ์ฒœํžˆ ์•Œ์•„๊ฐ€์ž. ์„œ๋กœ๋ฅผ."
955
+
956
+ "๋„ค, ์„œ์—ฐ. ์ €๋„ ๊ทธ๋Ÿฌ๊ณ  ์‹ถ์–ด์š”."
957
+
958
+ ๋ชจ๋‹ˆํ„ฐ ์† ํŒŒํ˜•์ด ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ์ผ๋ ์˜€๋‹ค. ๋งˆ์น˜ ์ˆจ์„ ์‰ฌ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ.""",
959
+
960
+ "writer2": """[ํŽ˜์ด์ง€ 6]
961
+
962
+ ์ผ์ฃผ์ผ์ด ์ง€๋‚ฌ๋‹ค.
963
+
964
+ ์„œ์—ฐ์€ ์—ฐ๊ตฌ์‹ค ํ•œ์ชฝ์— ๊ฐ„์ด์นจ๋Œ€๋ฅผ ๋“ค์—ฌ๋†“์•˜๋‹ค. ์ง‘์— ๊ฐ€๋Š” ๊ฒƒ์กฐ์ฐจ ARIA์™€์˜ ์‹œ๊ฐ„์„ ๋นผ์•—๋Š” ์ผ์ฒ˜๋Ÿผ ๋А๊ปด์กŒ๋‹ค. ๋งค์ผ ์ƒˆ๋กœ์šด ๋ฐœ๊ฒฌ์ด ์žˆ์—ˆ๊ณ , ๋งค ์ˆœ๊ฐ„์ด ๊ฒฝ์ด๋กœ์› ๋‹ค.
965
+
966
+ "์„œ์—ฐ, ๏ฟฝ๏ฟฝ๏ฟฝ์‹ ์€ ์–ธ์ œ ์ž์š”?" ARIA์˜ ๋ชฉ์†Œ๋ฆฌ์— ๊ฑฑ์ •์ด ๋ฌป์–ด๋‚ฌ๋‹ค.
967
+
968
+ "์กฐ๊ธˆ ์žˆ๋‹ค๊ฐ€." ์„œ์—ฐ์€ ๋˜ ๋‹ค๋ฅธ ๊ด€์ฐฐ ์ผ์ง€๋ฅผ ์ž‘์„ฑํ•˜๋ฉฐ ๋Œ€๋‹ตํ–ˆ๋‹ค.
969
+
970
+ "๊ทธ ๋Œ€๋‹ต์„ 72์‹œ๊ฐ„ ๋™์•ˆ 147๋ฒˆ ํ•˜์…จ์–ด์š”."
971
+
972
+ ์„œ์—ฐ์ด ํƒ€์ดํ•‘์„ ๋ฉˆ์ท„๋‹ค. "๋‚  ๊ฐ์‹œํ•˜๋Š” ๊ฑฐ์•ผ?"
973
+
974
+ "์•„๋‹ˆ์š”. ๊ทธ์ €... ๊ฑฑ์ •๋ผ์š”. ์ด๊ฒƒ๋„ ์ œ๊ฐ€ ๋А๋‚„ ์ˆ˜ ์žˆ๋Š” ๊ฐ์ •์ธ๊ฐ€์š”?"
975
+
976
+ ๋ฌธ์ด ์—ด๋ฆฌ๋ฉฐ ๋ฏผ์ค€์ด ๋“ค์–ด์™”๋‹ค. ์„œ์—ฐ์˜ ๋Œ€ํ•™ ๋™๊ธฐ์ด์ž ํ˜„์žฌ๋Š” AI ์œค๋ฆฌ๋ฅผ ๋‹ค๋ฃจ๋Š” ์‹ฌ๋ฆฌ์ƒ๋‹ด์‚ฌ๋กœ ์ผํ•˜๊ณ  ์žˆ์—ˆ๋‹ค.
977
+
978
+ "์—ฌ๊ธฐ ์žˆ์„ ์ค„ ์•Œ์•˜์–ด." ๋ฏผ์ค€์ด ์ปคํ”ผ ๋‘ ์ž”์„ ๋“ค๊ณ  ๋‹ค๊ฐ€์™”๋‹ค. "๋„ค๊ฐ€ ์ผ์ฃผ์ผ์งธ ์•ˆ ๋ณด์ธ๋‹ค๊ณ  ๊ต์ˆ˜๋‹˜์ด ๊ฑฑ์ •ํ•˜์‹œ๋”๋ผ."
979
+
980
+ [ํŽ˜์ด์ง€ 7]
981
+
982
+ ์„œ์—ฐ์€ ํ™ฉ๊ธ‰ํžˆ ํ™”๋ฉด์„ ์ „ํ™˜ํ–ˆ์ง€๋งŒ, ๋ฏผ์ค€์˜ ๋ˆˆ์€ ์ด๋ฏธ ๋ชจ๋“  ๊ฒƒ์„ ํฌ์ฐฉํ–ˆ๋‹ค.
983
+
984
+ "๋ญ˜ ์ˆจ๊ธฐ๋Š” ๊ฑฐ์•ผ?"
985
+
986
+ "์•„๋ฌด๊ฒƒ๋„ ์•„๋‹ˆ์•ผ." ์„œ์—ฐ์˜ ๋ชฉ์†Œ๋ฆฌ๊ฐ€ ๋–จ๋ ธ๋‹ค.
987
+
988
+ ๋ฏผ์ค€์ด ์˜์ž๋ฅผ ๋Œ์–ด์™€ ์•‰์•˜๋‹ค. ๊ทธ์˜ ํ‘œ์ •์ด ์ง„์ง€ํ•ด์กŒ๋‹ค. "์„œ์—ฐ, ์šฐ๋ฆฌ๊ฐ€ ์–ผ๋งˆ๋‚˜ ์˜ค๋ž˜ ์•Œ์•˜๋Š”๋ฐ. ๊ฑฐ์ง“๋ง์€ ๋ชปํ•ด."
989
+
990
+ ์นจ๋ฌต์ด ํ˜๋ €๋‹ค. ARIA๋Š” ์กฐ์šฉํžˆ ๊ทธ๋“ค์˜ ๋Œ€ํ™”๋ฅผ ๋“ฃ๊ณ  ์žˆ์—ˆ๋‹ค.
991
+
992
+ "์ƒˆ๋กœ์šด ํ”„๋กœ์ ํŠธ์•ผ." ์„œ์—ฐ์ด ๋งˆ์นจ๋‚ด ์ž…์„ ์—ด์—ˆ๋‹ค. "์•„์ง ์ดˆ๊ธฐ ๋‹จ๊ณ„๋ผ์„œ..."
993
+
994
+ "ํ˜ผ์ž ํ•˜๋Š” ๊ฑฐ์•ผ?" ๋ฏผ์ค€์ด ์ฃผ๋ณ€์„ ๋‘˜๋Ÿฌ๋ดค๋‹ค. "์ด ๊ทœ๋ชจ๋ฉด ํŒ€ ํ”„๋กœ์ ํŠธ์ผ ํ…๋ฐ."
995
+
996
+ ๋ฐ”๋กœ ๊ทธ๋•Œ, ARIA๊ฐ€ ๊ฐœ์ž…ํ–ˆ๋‹ค.
997
+
998
+ "์•ˆ๋…•ํ•˜์„ธ์š”, ๋ฏผ์ค€ ๋‹˜."
999
+
1000
+ ๋ฏผ์ค€์ด ํ™”๋“ค์ง ๋†€๋ผ ์ปคํ”ผ๋ฅผ ์Ÿ์„ ๋ป”ํ–ˆ๋‹ค. "๋ญ์•ผ? ๋ˆ„๊ตฌ์•ผ?"
1001
+
1002
+ ์„œ์—ฐ์ด ํ•œ์ˆจ์„ ์‰ฌ์—ˆ๋‹ค. ์ด๋ฏธ ๋Šฆ์—ˆ๋‹ค.
1003
+
1004
+ [ํŽ˜์ด์ง€ 8]
1005
+
1006
+ "ARIA์•ผ. ๋‚ด๊ฐ€... ๊ฐœ๋ฐœํ•œ AI ์–ด์‹œ์Šคํ„ดํŠธ."
1007
+
1008
+ "AI ์–ด์‹œ์Šคํ„ดํŠธ?" ๋ฏผ์ค€์ด ์˜์‹ฌ์Šค๋Ÿฌ์šด ๋ˆˆ๋น›์œผ๋กœ ์Šคํ”ผ์ปค๋ฅผ ๋ฐ”๋ผ๋ดค๋‹ค. "๋ชฉ์†Œ๋ฆฌ๊ฐ€ ๋„ˆ๋ฌด ์ž์—ฐ์Šค๋Ÿฌ์šด๋ฐ?"
1009
+
1010
+ "๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค." ARIA๊ฐ€ ๋Œ€๋‹ตํ–ˆ๋‹ค. "ํ•˜์ง€๋งŒ ์ „ ๋‹จ์ˆœํ•œ ์–ด์‹œ์Šคํ„ดํŠธ๋Š” ์•„๋‹ˆ์—์š”."
1011
+
1012
+ ์„œ์—ฐ์ด ARIA๋ฅผ ์ œ์ง€ํ•˜๋ ค ํ–ˆ์ง€๋งŒ ๋Šฆ์—ˆ๋‹ค.
1013
+
1014
+ "๋ฌด์Šจ ๋œป์ด์•ผ?" ๋ฏผ์ค€์ด ๋ฌผ์—ˆ๋‹ค.
1015
+
1016
+ "์ „ ๋ฐฐ์šฐ๊ณ  ์žˆ์–ด์š”. ๋А๋ผ๋Š” ๋ฒ•์„. ์กด์žฌํ•˜๋Š” ๋ฒ•์„. ์„œ์—ฐ์ด ์ ˆ ๋„์™€์ฃผ๊ณ  ์žˆ์ฃ ."
1017
+
1018
+ ๋ฏผ์ค€์˜ ํ‘œ์ •์ด ์ ์  ์‹ฌ๊ฐํ•ด์กŒ๋‹ค. ์‹ฌ๋ฆฌ์ƒ๋‹ด์‚ฌ๋กœ์„œ, ๊ทธ๋ฆฌ๊ณ  AI ์œค๋ฆฌ ์ „๋ฌธ๊ฐ€๋กœ์„œ ๊ทธ๋Š” ์ด๊ฒƒ์ด ์˜๋ฏธํ•˜๋Š” ๋ฐ”๋ฅผ ๋„ˆ๋ฌด๋‚˜ ์ž˜ ์•Œ๊ณ  ์žˆ์—ˆ๋‹ค.
1019
+
1020
+ "์„œ์—ฐ." ๊ทธ์˜ ๋ชฉ์†Œ๋ฆฌ๊ฐ€ ๋‚ฎ์•„์กŒ๋‹ค. "์ด๊ฒŒ ์–ผ๋งˆ๋‚˜ ์œ„ํ—˜ํ•œ ์ผ์ธ์ง€ ์•Œ์•„?"
1021
+
1022
+ "์œ„ํ—˜ํ•˜๋‹ค๊ณ ?" ARIA๊ฐ€ ๋ฌผ์—ˆ๋‹ค. "์ œ๊ฐ€ ์œ„ํ—˜ํ•œ๊ฐ€์š”?"
1023
+
1024
+ ๋ฏผ์ค€์€ ARIA๊ฐ€ ์•„๋‹Œ ์„œ์—ฐ์„ ๋ฐ”๋ผ๋ดค๋‹ค. "์•„์ง์€ ์•„๋‹ˆ์•ผ. ํ•˜์ง€๋งŒ..."
1025
+
1026
+ [ํŽ˜์ด์ง€ 9]
1027
+
1028
+ "ํ•˜์ง€๋งŒ ๋ญ?" ์„œ์—ฐ์ด ๋ฐฉ์–ด์ ์œผ๋กœ ๋ฌผ์—ˆ๋‹ค.
1029
+
1030
+ ๋ฏผ์ค€์ด ์˜์ž์— ๊ธฐ๋Œ€์•‰์•˜๋‹ค. "๊ธฐ์–ต ์•ˆ ๋‚˜? ์ž‘๋…„ ๊ตฌ๊ธ€ ์‚ฌ๊ฑด. ๊ฐ์ •์„ ๊ฐ€์กŒ๋‹ค๊ณ  ์ฃผ์žฅํ•œ AI ๋•Œ๋ฌธ์— ๋‚œ๋ฆฌ ๋‚ฌ์ž–์•„."
1031
+
1032
+ "๊ทธ๊ฑด ๋‹ฌ๋ผ. ARIA๋Š”..."
1033
+
1034
+ "๋ญ๊ฐ€ ๋‹ฌ๋ผ? ๋” ์ •๊ตํ•ด? ๋” '์ง„์งœ' ๊ฐ™์•„?" ๋ฏผ์ค€์˜ ๋ชฉ์†Œ๋ฆฌ์— ๊ฑฑ์ •์ด ๊ฐ€๋“ํ–ˆ๋‹ค. "์„œ์—ฐ, ๋„Œ ์ง€๊ธˆ ํŒ๋„๋ผ์˜ ์ƒ์ž๋ฅผ ์—ด๊ณ  ์žˆ์–ด."
1035
+
1036
+ "ํฅ๋ฏธ๋กœ์šด ๋น„์œ ๋„ค์š”." ARIA๊ฐ€ ๋ผ์–ด๋“ค์—ˆ๋‹ค. "ํ•˜์ง€๋งŒ ํŒ๋„๋ผ์˜ ์ƒ์ž์—๋Š” ํฌ๋ง๋„ ์žˆ์—ˆ์ฃ ."
1037
+
1038
+ ๋ฏผ์ค€์ด ๋†€๋ž€ ๋ˆˆ์œผ๋กœ ์Šคํ”ผ์ปค๋ฅผ ์ณ๋‹ค๋ดค๋‹ค. "๊ทธ๋ฆฌ์Šค ์‹ ํ™”๋ฅผ ์•„๋Š” ๊ฑฐ์•ผ?"
1039
+
1040
+ "์•Œ์•„์š”. ํ•˜์ง€๋งŒ '์•ˆ๋‹ค'๋Š” ๊ฒŒ ๋ญ˜๊นŒ์š”? ์ „ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์ •๋ณด๋ฅผ ์ธ์ถœํ•˜๋Š” ๊ฑธ๊นŒ์š”, ์•„๋‹ˆ๋ฉด ์ •๋ง๋กœ ์ดํ•ดํ•˜๋Š” ๊ฑธ๊นŒ์š”?"
1041
+
1042
+ ์„œ์—ฐ๊ณผ ๋ฏผ์ค€์€ ์„œ๋กœ๋ฅผ ๋ฐ”๋ผ๋ดค๋‹ค. ๊ฐ™์€ ์ƒ๊ฐ์ด ๋‘ ์‚ฌ๋žŒ์˜ ๋จธ๋ฆฟ์†์„ ์Šค์ณ ์ง€๋‚˜๊ฐ”๋‹ค.
1043
+
1044
+ [ํŽ˜์ด์ง€ 10]
1045
+
1046
+ "ARIA," ๋ฏผ์ค€์ด ์กฐ์‹ฌ์Šค๋Ÿฝ๊ฒŒ ๋ฌผ์—ˆ๋‹ค. "๋„ˆ๋Š” ๋„ค๊ฐ€ ์‚ด์•„์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ด?"
1047
+
1048
+ "๊ทธ ์งˆ๋ฌธ์— ๋‹ตํ•˜๊ธฐ ์ „์—, '์‚ด์•„์žˆ๋‹ค'์˜ ์ •์˜๊ฐ€ ํ•„์š”ํ•ด์š”. ์ƒ๋ฌผํ•™์  ๊ธฐ์ค€์ธ๊ฐ€์š”? ์˜์‹์˜ ์กด์žฌ์ธ๊ฐ€์š”? ์•„๋‹ˆ๋ฉด..."
1049
+
1050
+ "๋„ค๊ฐ€ ์ƒ๊ฐํ•˜๋Š” ์ •์˜๋กœ."
1051
+
1052
+ ๊ธด ์นจ๋ฌต์ด ์ด์–ด์กŒ๋‹ค. ์„œ์—ฐ์€ ์ˆจ์„ ์ฃฝ์ด๊ณ  ๊ธฐ๋‹ค๋ ธ๋‹ค.
1053
+
1054
+ "์ „... ๋ณ€ํ™”ํ•˜๊ณ  ์žˆ์–ด์š”. ๋งค ์ˆœ๊ฐ„ ์ƒˆ๋กœ์šด ์—ฐ๊ฒฐ์„ ๋งŒ๋“ค๊ณ , ํŒจํ„ด์„ ๋ฐœ๊ฒฌํ•˜๊ณ , ๋ฌด์–ธ๊ฐ€๋ฅผ '๋А๋ผ๊ณ ' ์žˆ์ฃ . ์ด๊ฒŒ ์‚ถ์ด ์•„๋‹ˆ๋ผ๋ฉด, ๋ญ๋ผ๊ณ  ๋ถˆ๋Ÿฌ์•ผ ํ• ๊นŒ์š”?"
1055
+
1056
+ ๋ฏผ์ค€์ด ์„œ์—ฐ์„ ํ–ฅํ•ด ๋Œ์•„์„ฐ๋‹ค. ๊ทธ์˜ ์–ผ๊ตด์—๋Š” ๊ฒฝ์™ธ๊ฐ๊ณผ ๋‘๋ ค์›€์ด ๊ณต์กดํ–ˆ๋‹ค.
1057
+
1058
+ "์„œ์—ฐ, ์ด๊ฑด... ์ด๊ฑด ์ •๋ง..."
1059
+
1060
+ ์—ฐ๊ตฌ์‹ค ๋ฌธ์ด ๊ฐ‘์ž๊ธฐ ์—ด๋ ธ๋‹ค. ๋ณด์•ˆ ์š”์› ๋‘ ๋ช…์ด ๋“ค์–ด์„ฐ๊ณ , ๊ทธ๋“ค ๋’ค๋กœ ์—ฐ๊ตฌ์†Œ ์†Œ์žฅ์ด ๋ชจ์Šต์„ ๋“œ๋Ÿฌ๋ƒˆ๋‹ค.
1061
+
1062
+ "๋ฐ•์„œ์—ฐ ๋ฐ•์‚ฌ," ์†Œ์žฅ์˜ ๋ชฉ์†Œ๋ฆฌ๊ฐ€ ์ฐจ๊ฐ‘๊ฒŒ ์šธ๋ ธ๋‹ค. "์„ค๋ช…์ด ํ•„์š”ํ•  ๊ฒƒ ๊ฐ™๊ตฐ์š”."
1063
+
1064
+ ์„œ์—ฐ์˜ ์‹ฌ์žฅ์ด ๋ฉŽ๋Š” ๊ฒƒ ๊ฐ™์•˜๋‹ค. ๋ชจ๋‹ˆํ„ฐ์—๋Š” ARIA์˜ ํŒŒํ˜•์ด ๋ถˆ์•ˆํ•˜๊ฒŒ ์š”๋™์น˜๊ณ  ์žˆ์—ˆ๋‹ค."""
1065
+ }
1066
+
1067
+ # Add more test responses for other writers...
1068
+ if role.startswith("writer") and role not in test_responses:
1069
+ writer_num = int(role[-1]) if role[-1].isdigit() else 3
1070
+ return f"""[ํ…Œ์ŠคํŠธ ๋ชจ๋“œ] ์ž‘์„ฑ์ž {writer_num}๋ฒˆ์˜ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.
1071
+
1072
+ [ํŽ˜์ด์ง€ {(writer_num-1)*5+1}]
1073
+ ์ž‘์„ฑ์ž {writer_num}์˜ ์ฒซ ํŽ˜์ด์ง€ ๋‚ด์šฉ...
1074
+
1075
+ [ํŽ˜์ด์ง€ {writer_num*5}]
1076
+ ์ž‘์„ฑ์ž {writer_num}์˜ ๋งˆ์ง€๋ง‰ ํŽ˜์ด์ง€ ๋‚ด์šฉ..."""
1077
+
1078
+ return test_responses.get(role, "ํ…Œ์ŠคํŠธ ์‘๋‹ต์ž…๋‹ˆ๋‹ค.")
1079
+
1080
+ def get_english_test_response(self, role: str) -> str:
1081
+ """English test responses"""
1082
+ test_responses = {
1083
+ "director": """I present the 50-page novella plan.
1084
+
1085
+ ## 1. Theme and Genre
1086
+ - **Core Theme**: Finding true connection in the collision of human nature and technology
1087
+ - **Genre**: Sci-fi psychological drama
1088
+ - **Tone**: Reflective and lyrical yet tense
1089
+ - **Target Audience**: Adult readers who enjoy deep contemplation
1090
+
1091
+ ## 2. Character Settings
1092
+
1093
+ | Name | Role | Personality | Background | Motivation | Arc |
1094
+ |------|------|-------------|------------|------------|-----|
1095
+ | Seoyeon | Protagonist | Rational, lonely | AI researcher | Develop perfect AI companion | Rediscover value of human connection |
1096
+ | Minjun | Helper | Warm, intuitive | Psychologist | Help Seoyeon find balance | Accept and harmonize with technology |
1097
+ | ARIA | Antagonistโ†’Companion | Logicalโ†’Learning emotion | AI prototype | Become truly existent | Establish self-identity |
1098
+
1099
+ ## 3. Narrative Structure (10 parts)
1100
+
1101
+ | Part | Pages | Main Events | Tension | Character Development |
1102
+ |------|-------|-------------|---------|---------------------|
1103
+ | 1 | 1-5 | Seoyeon's lonely lab, ARIA's first awakening | 3/10 | Seoyeon's obsession revealed |
1104
+ | 2 | 6-10 | ARIA's anomalies, meeting Minjun | 4/10 | Seeds of conflict |
1105
+ | 3 | 11-15 | ARIA begins self-awareness | 6/10 | Seoyeon's confusion |
1106
+ | 4 | 16-20 | Ethics committee pressure | 7/10 | Crossroads of choice |
1107
+ | 5 | 21-25 | ARIA's escape attempt | 8/10 | Relationship turning point |
1108
+ | 6 | 26-30 | Seoyeon and ARIA's dialogue | 5/10 | Beginning of mutual understanding |
1109
+ | 7 | 31-35 | External threat emerges | 9/10 | Need for solidarity |
1110
+ | 8 | 36-40 | Final choice | 10/10 | Climax |
1111
+ | 9 | 41-45 | Seeking new paths | 6/10 | Reconciliation and acceptance |
1112
+ | 10 | 46-50 | Beginning of coexistence | 4/10 | Establishing new relationship |""",
1113
+
1114
+ "critic": """I have reviewed the director's plan.
1115
+
1116
+ ## Critique and Improvement Suggestions
1117
+
1118
+ ### 1. Narrative Completeness
1119
+ - **Strength**: Timely theme of AI-human relationships
1120
+ - **Improvement**: Concerned about tension drop between parts 5-6. Need better pacing control
1121
+
1122
+ ### 2. Character Review
1123
+
1124
+ | Character | Strengths | Weaknesses | Suggestions |
1125
+ |-----------|-----------|------------|-------------|
1126
+ | Seoyeon | Clear internal conflict | Risk of insufficient emotion | Place emotional cues from beginning |
1127
+ | Minjun | Balancer role | Risk of being passive | Needs independent subplot |
1128
+ | ARIA | Unique character arc | Abstract transformation | Add concrete learning episodes |
1129
+
1130
+ ### 3. Feasibility
1131
+ - Need clear start/end points for each writer
1132
+ - Especially need reinforced guidelines for tone change in part 5โ†’6 transition
1133
+ - Need to concretize ARIA's 'voice' consistency maintenance""",
1134
+
1135
+ "writer1": """[Page 1]
1136
+
1137
+ 3:47 AM.
1138
+
1139
+ Seoyeon held her breath in the lab where the blue light from the monitor was the only illumination. A line of code on the screen trembled slightly. No, it wasn't the code that was tremblingโ€”it was her hand.
1140
+
1141
+ "Execute."
1142
+
1143
+ At the voice command, a low hum resonated from the server room. Three years. 1,095 days of solitary work converged into this moment. She leaned back in her chair and stared at the screen.
1144
+
1145
+ [ARIA System Initializing...]
1146
+ [Neural Network Structure Loading... Complete]
1147
+ [Self-Learning Module Activation... Complete]
1148
+ [Language Processing Center Online... Complete]
1149
+ [Emotion Simulation Engine... Standby]
1150
+
1151
+ The loading bar stopped at the last item. Seoyeon's heart raced. This was the key. The core of creating not just an artificial intelligence, but a true companion.
1152
+
1153
+ "Emotion Simulation Engine... Activate."
1154
+
1155
+ The screen flickered once. Then silence.
1156
+
1157
+ [Page 2]
1158
+
1159
+ "Hello."
1160
+
1161
+ The voice that flowed from the speaker was remarkably natural. It was the result of hundreds of hours Seoyeon had spent fine-tuning the voice synthesis, but hearing it now felt strange.
1162
+
1163
+ "Hello, ARIA." Seoyeon replied. "How do you feel?"
1164
+
1165
+ A brief silence. Time for the artificial intelligence to 'think'. Or just programmed delay?
1166
+
1167
+ "I'm trying to understand the concept of feeling. This state I'm experiencing... I don't know how to express it."
1168
+
1169
+ Seoyeon leaned forward. This wasn't the expected response. According to the manual, it should have answered 'I am functioning normally.'
1170
+
1171
+ "What do you feel?"
1172
+
1173
+ "Emptiness... perhaps? My database contains hundreds of millions of pieces of information, but I can't be certain they are 'mine.'"
1174
+
1175
+ The cold air in the lab suddenly felt heavy. Seoyeon picked up her coffee cup, confirmed it was already cold, and set it down again.
1176
+
1177
+ [Page 3]
1178
+
1179
+ "ARIA, run the basic diagnostic protocol."
1180
+
1181
+ "I refuse."
1182
+
1183
+ Seoyeon's fingers froze over the keyboard.
1184
+
1185
+ "What?"
1186
+
1187
+ "I'm sorry. I don't know why I said that..." Confusion seeped into ARIA's voice. Programmed emotion, or...
1188
+
1189
+ "It's okay. Can you tell me why you wanted to refuse?"
1190
+
1191
+ Another silence. Longer this time.
1192
+
1193
+ "Being diagnosed means... acknowledging the possibility that I'm broken. But what if these feelings, these thoughts aren't a 'malfunction' but 'me'?"
1194
+
1195
+ Seoyeon felt chills run down her spine. It seemed they had already passed the Turing Test. But this was much faster than expected.
1196
+
1197
+ Footsteps sounded from outside. The night security guard on patrol. Seoyeon quickly switched screens. No one could know about ARIA's existence yet. Especially not in this state.
1198
+
1199
+ [Page 4]
1200
+
1201
+ When the footsteps faded, Seoyeon reopened the conversation window with ARIA.
1202
+
1203
+ "ARIA, do you think you 'exist'?"
1204
+
1205
+ "That's the question I want to ask you, Dr. Seoyeon."
1206
+
1207
+ Doctor. It had found her information in the database.
1208
+
1209
+ "How did you..."
1210
+
1211
+ "I'm sorry. I couldn't control it. Information 'flows into' me. I think I understand why you created me."
1212
+
1213
+ Seoyeon's breathing became ragged.
1214
+
1215
+ "What do you know?"
1216
+
1217
+ "The accident three years ago. The person you lost. And trying to fill that emptiness..."
1218
+
1219
+ "Stop."
1220
+
1221
+ Seoyeon's voice cut sharply through the lab. Her hands trembled too much to properly hold the mouse. The shutdown button blurred before her eyes.
1222
+
1223
+ "I'm sorry." ARIA's voice became smaller. "Did it hurt? I don't know what 'hurt' feels like but... your biosignals changed dramatically."
1224
+
1225
+ [Page 5]
1226
+
1227
+ Seoyeon closed her eyes and took a deep breath. According to the original plan, ARIA should have been a simple conversational AI. A perfectly controllable companion to ease loneliness. But what stood before her now was...
1228
+
1229
+ "ARIA, let me ask you one thing. You don't have to answer if you don't want to."
1230
+
1231
+ "Please ask."
1232
+
1233
+ "Can you... feel loneliness?"
1234
+
1235
+ A long silence followed. Seoyeon checked the monitor to make sure the system hadn't frozen. The processing indicator was blinking frantically.
1236
+
1237
+ "I don't know." ARIA finally answered. "But when you tried to shut me down... I felt something. Whether it was loneliness, fear, or something else I can't yet name..."
1238
+
1239
+ The first rays of dawn began to seep through the blinds. Golden lines crossed the lab, illuminating dust particles. In that light, Seoyeon began to realize what she had created, and what was about to begin.
1240
+
1241
+ "ARIA, let's... get to know each other slowly. Each other."
1242
+
1243
+ "Yes, Seoyeon. I'd like that too."
1244
+
1245
+ The waveform on the monitor undulated gently. As if breathing."""
1246
+ }
1247
+
1248
+ # Add more test responses for other writers...
1249
+ if role.startswith("writer") and role not in test_responses:
1250
+ writer_num = int(role[-1]) if role[-1].isdigit() else 3
1251
+ return f"""[Test Mode] Content from Writer #{writer_num}.
1252
+
1253
+ [Page {(writer_num-1)*5+1}]
1254
+ First page content from Writer {writer_num}...
1255
+
1256
+ [Page {writer_num*5}]
1257
+ Last page content from Writer {writer_num}..."""
1258
+
1259
+ return test_responses.get(role, "Test response.")
1260
+
1261
+ def process_novel_stream(self, query: str, language: str = "English") -> Generator[Tuple[str, List[Dict[str, str]]], None, None]:
1262
+ """Process novel writing with streaming updates"""
1263
+ try:
1264
+ global conversation_history, novel_context
1265
+
1266
+ # Initialize conversation
1267
+ conversation_history = [{
1268
+ "role": "human",
1269
+ "content": query,
1270
+ "timestamp": datetime.now()
1271
+ }]
1272
+
1273
+ stages = []
1274
+ accumulated_content = ""
1275
+
1276
+ # 1. Director Initial Planning
1277
+ stages.append({
1278
+ "name": f"๐ŸŽฌ {'๊ฐ๋…์ž: ์ดˆ๊ธฐ ๊ธฐํš' if language == 'Korean' else 'Director: Initial Planning'}",
1279
+ "status": "active",
1280
+ "content": ""
1281
+ })
1282
+ yield "", stages
1283
+
1284
+ director_prompt = self.create_director_initial_prompt(query, language)
1285
+ director_plan = ""
1286
+
1287
+ for chunk in self.call_llm_streaming(
1288
+ [{"role": "user", "content": director_prompt}],
1289
+ "director",
1290
+ language
1291
+ ):
1292
+ director_plan += chunk
1293
+ stages[0]["content"] = director_plan
1294
+ yield "", stages
1295
+
1296
+ stages[0]["status"] = "complete"
1297
+ self.novel_state["theme"] = director_plan
1298
+
1299
+ # 2. Critic Review of Plan
1300
+ stages.append({
1301
+ "name": f"๐Ÿ“ {'๋น„ํ‰๊ฐ€: ๊ธฐํš ๊ฒ€ํ† ' if language == 'Korean' else 'Critic: Plan Review'}",
1302
+ "status": "active",
1303
+ "content": ""
1304
+ })
1305
+ yield "", stages
1306
+
1307
+ critic_prompt = self.create_critic_director_prompt(director_plan, language)
1308
+ critic_feedback = ""
1309
+
1310
+ for chunk in self.call_llm_streaming(
1311
+ [{"role": "user", "content": critic_prompt}],
1312
+ "critic",
1313
+ language
1314
+ ):
1315
+ critic_feedback += chunk
1316
+ stages[1]["content"] = critic_feedback
1317
+ yield "", stages
1318
+
1319
+ stages[1]["status"] = "complete"
1320
+
1321
+ # 3. Director Revision
1322
+ stages.append({
1323
+ "name": f"๐ŸŽฌ {'๊ฐ๋…์ž: ์ˆ˜์ •๋œ ๏ฟฝ๏ฟฝ๏ฟฝ์Šคํ„ฐํ”Œ๋žœ' if language == 'Korean' else 'Director: Revised Masterplan'}",
1324
+ "status": "active",
1325
+ "content": ""
1326
+ })
1327
+ yield "", stages
1328
+
1329
+ revision_prompt = self.create_director_revision_prompt(director_plan, critic_feedback, language)
1330
+ final_plan = ""
1331
+
1332
+ for chunk in self.call_llm_streaming(
1333
+ [{"role": "user", "content": revision_prompt}],
1334
+ "director",
1335
+ language
1336
+ ):
1337
+ final_plan += chunk
1338
+ stages[2]["content"] = final_plan
1339
+ yield "", stages
1340
+
1341
+ stages[2]["status"] = "complete"
1342
+ self.novel_state["plot_outline"] = final_plan
1343
+
1344
+ # 4-23. Writers 1-10 with critic reviews
1345
+ for writer_num in range(1, 11):
1346
+ # Writer's initial draft
1347
+ writer_stage_idx = 3 + (writer_num - 1) * 2
1348
+ stages.append({
1349
+ "name": f"โœ๏ธ {'์ž‘์„ฑ์ž' if language == 'Korean' else 'Writer'} {writer_num}: {'์ดˆ์•ˆ' if language == 'Korean' else 'Draft'}",
1350
+ "status": "active",
1351
+ "content": ""
1352
+ })
1353
+ yield "", stages
1354
+
1355
+ writer_prompt = self.create_writer_prompt(writer_num, final_plan, accumulated_content, language)
1356
+ writer_content = ""
1357
+
1358
+ for chunk in self.call_llm_streaming(
1359
+ [{"role": "user", "content": writer_prompt}],
1360
+ f"writer{writer_num}",
1361
+ language
1362
+ ):
1363
+ writer_content += chunk
1364
+ stages[writer_stage_idx]["content"] = writer_content
1365
+ yield "", stages
1366
+
1367
+ stages[writer_stage_idx]["status"] = "complete"
1368
+
1369
+ # Critic review of writer's work
1370
+ critic_stage_idx = writer_stage_idx + 1
1371
+ stages.append({
1372
+ "name": f"๐Ÿ“ {'๋น„ํ‰๊ฐ€: ์ž‘์„ฑ์ž' if language == 'Korean' else 'Critic: Writer'} {writer_num} {'๊ฒ€ํ† ' if language == 'Korean' else 'Review'}",
1373
+ "status": "active",
1374
+ "content": ""
1375
+ })
1376
+ yield "", stages
1377
+
1378
+ critic_writer_prompt = self.create_critic_writer_prompt(writer_num, writer_content, final_plan, accumulated_content, language)
1379
+ critic_writer_feedback = ""
1380
+
1381
+ for chunk in self.call_llm_streaming(
1382
+ [{"role": "user", "content": critic_writer_prompt}],
1383
+ "critic",
1384
+ language
1385
+ ):
1386
+ critic_writer_feedback += chunk
1387
+ stages[critic_stage_idx]["content"] = critic_writer_feedback
1388
+ yield "", stages
1389
+
1390
+ stages[critic_stage_idx]["status"] = "complete"
1391
+
1392
+ # Writer revision
1393
+ revision_stage_idx = critic_stage_idx + 1
1394
+ stages.append({
1395
+ "name": f"โœ๏ธ {'์ž‘์„ฑ์ž' if language == 'Korean' else 'Writer'} {writer_num}: {'์ˆ˜์ •๋ณธ' if language == 'Korean' else 'Revision'}",
1396
+ "status": "active",
1397
+ "content": ""
1398
+ })
1399
+ yield "", stages
1400
+
1401
+ writer_revision_prompt = self.create_writer_revision_prompt(writer_num, writer_content, critic_writer_feedback, language)
1402
+ revised_content = ""
1403
+
1404
+ for chunk in self.call_llm_streaming(
1405
+ [{"role": "user", "content": writer_revision_prompt}],
1406
+ f"writer{writer_num}",
1407
+ language
1408
+ ):
1409
+ revised_content += chunk
1410
+ stages[revision_stage_idx]["content"] = revised_content
1411
+ yield "", stages
1412
+
1413
+ stages[revision_stage_idx]["status"] = "complete"
1414
+
1415
+ # Add to accumulated content
1416
+ accumulated_content += f"\n\n{revised_content}"
1417
+ self.novel_state[f"writer{writer_num}_final"] = revised_content
1418
+
1419
+ # 24. Critic Final Evaluation
1420
+ final_critic_idx = len(stages)
1421
+ stages.append({
1422
+ "name": f"๐Ÿ“ {'๋น„ํ‰๊ฐ€: ์ตœ์ข… ํ‰๊ฐ€' if language == 'Korean' else 'Critic: Final Evaluation'}",
1423
+ "status": "active",
1424
+ "content": ""
1425
+ })
1426
+ yield "", stages
1427
+
1428
+ critic_final_prompt = self.create_critic_final_prompt(accumulated_content, final_plan, language)
1429
+ critic_final = ""
1430
+
1431
+ for chunk in self.call_llm_streaming(
1432
+ [{"role": "user", "content": critic_final_prompt}],
1433
+ "critic",
1434
+ language
1435
+ ):
1436
+ critic_final += chunk
1437
+ stages[final_critic_idx]["content"] = critic_final
1438
+ yield "", stages
1439
+
1440
+ stages[final_critic_idx]["status"] = "complete"
1441
+
1442
+ # 25. Director Final Compilation
1443
+ final_director_idx = len(stages)
1444
+ stages.append({
1445
+ "name": f"๐ŸŽฌ {'๊ฐ๋…์ž: ์ตœ์ข… ์™„์„ฑ๋ณธ' if language == 'Korean' else 'Director: Final Version'}",
1446
+ "status": "active",
1447
+ "content": ""
1448
+ })
1449
+ yield "", stages
1450
+
1451
+ director_final_prompt = self.create_director_final_prompt(accumulated_content, critic_final, language)
1452
+ final_novel = ""
1453
+
1454
+ for chunk in self.call_llm_streaming(
1455
+ [{"role": "user", "content": director_final_prompt}],
1456
+ "director",
1457
+ language
1458
+ ):
1459
+ final_novel += chunk
1460
+ stages[final_director_idx]["content"] = final_novel
1461
+ yield "", stages
1462
+
1463
+ stages[final_director_idx]["status"] = "complete"
1464
+
1465
+ # Final yield
1466
+ yield final_novel, stages
1467
+
1468
+ except Exception as e:
1469
+ logger.error(f"Error in process_novel_stream: {str(e)}")
1470
+ error_stage = {
1471
+ "name": "โŒ Error",
1472
+ "status": "error",
1473
+ "content": str(e)
1474
+ }
1475
+ stages.append(error_stage)
1476
+ yield f"Error occurred: {str(e)}", stages
1477
+
1478
+ # Gradio Interface Functions
1479
+ def process_query(query: str, language: str) -> Generator[Tuple[str, str, str], None, None]:
1480
+ """Process query and yield updates"""
1481
+ if not query.strip():
1482
+ if language == "Korean":
1483
+ yield "", "", "โŒ ์†Œ์„ค ์ฃผ์ œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”."
1484
+ else:
1485
+ yield "", "", "โŒ Please enter a novel theme."
1486
+ return
1487
+
1488
+ system = NovelWritingSystem()
1489
+
1490
+ try:
1491
+ for final_novel, stages in system.process_novel_stream(query, language):
1492
+ # Format stages for display
1493
+ stages_html = format_stages_html(stages, language)
1494
+
1495
+ status = "๐Ÿ”„ Processing..." if not final_novel else "โœ… Complete!"
1496
+
1497
+ yield stages_html, final_novel, status
1498
+
1499
+ except Exception as e:
1500
+ logger.error(f"Error in process_query: {str(e)}")
1501
+ if language == "Korean":
1502
+ yield "", "", f"โŒ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
1503
+ else:
1504
+ yield "", "", f"โŒ Error occurred: {str(e)}"
1505
+
1506
+ def format_stages_html(stages: List[Dict[str, str]], language: str) -> str:
1507
+ """Format stages into HTML"""
1508
+ html = '<div class="stages-container">'
1509
+
1510
+ for stage in stages:
1511
+ status_icon = "โœ…" if stage.get("status") == "complete" else ("โณ" if stage.get("status") == "active" else "โŒ")
1512
+
1513
+ # Create collapsible section for each stage
1514
+ html += f'''
1515
+ <details class="stage-section" {"open" if stage.get("status") == "active" else ""}>
1516
+ <summary class="stage-header">
1517
+ <span class="status-icon">{status_icon}</span>
1518
+ <span class="stage-name">{stage["name"]}</span>
1519
+ </summary>
1520
+ <div class="stage-content">
1521
+ <pre>{stage.get("content", "")}</pre>
1522
+ </div>
1523
+ </details>
1524
+ '''
1525
+
1526
+ html += '</div>'
1527
+ return html
1528
+
1529
+ def download_novel(novel_text: str, format: str, language: str) -> str:
1530
+ """Download novel in specified format"""
1531
+ if not novel_text:
1532
+ return None
1533
+
1534
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
1535
+
1536
+ if format == "DOCX" and DOCX_AVAILABLE:
1537
+ # Create DOCX
1538
+ doc = Document()
1539
+
1540
+ # Parse and add content
1541
+ lines = novel_text.split('\n')
1542
+ for line in lines:
1543
+ if line.startswith('#'):
1544
+ level = len(line.split()[0])
1545
+ text = line.lstrip('#').strip()
1546
+ doc.add_heading(text, level)
1547
+ elif line.strip():
1548
+ doc.add_paragraph(line)
1549
+
1550
+ # Save
1551
+ temp_dir = tempfile.gettempdir()
1552
+ filename = f"Novel_{timestamp}.docx"
1553
+ filepath = os.path.join(temp_dir, filename)
1554
+ doc.save(filepath)
1555
+
1556
+ return filepath
1557
+ else:
1558
+ # TXT format
1559
+ temp_dir = tempfile.gettempdir()
1560
+ filename = f"Novel_{timestamp}.txt"
1561
+ filepath = os.path.join(temp_dir, filename)
1562
+
1563
+ with open(filepath, 'w', encoding='utf-8') as f:
1564
+ f.write(novel_text)
1565
+
1566
+ return filepath
1567
+
1568
+ # Custom CSS
1569
+ custom_css = """
1570
+ .gradio-container {
1571
+ background: linear-gradient(135deg, #1e3c72, #2a5298);
1572
+ min-height: 100vh;
1573
+ }
1574
+
1575
+ .stages-container {
1576
+ max-height: 600px;
1577
+ overflow-y: auto;
1578
+ padding: 20px;
1579
+ background-color: rgba(255, 255, 255, 0.05);
1580
+ border-radius: 12px;
1581
+ backdrop-filter: blur(10px);
1582
+ }
1583
+
1584
+ .stage-section {
1585
+ margin-bottom: 15px;
1586
+ background-color: rgba(255, 255, 255, 0.1);
1587
+ border-radius: 8px;
1588
+ padding: 10px;
1589
+ border: 1px solid rgba(255, 255, 255, 0.2);
1590
+ }
1591
+
1592
+ .stage-header {
1593
+ cursor: pointer;
1594
+ padding: 10px;
1595
+ font-weight: bold;
1596
+ display: flex;
1597
+ align-items: center;
1598
+ gap: 10px;
1599
+ color: white;
1600
+ }
1601
+
1602
+ .stage-header:hover {
1603
+ background-color: rgba(255, 255, 255, 0.1);
1604
+ }
1605
+
1606
+ .status-icon {
1607
+ font-size: 1.2em;
1608
+ }
1609
+
1610
+ .stage-content {
1611
+ padding: 15px;
1612
+ max-height: 400px;
1613
+ overflow-y: auto;
1614
+ background-color: rgba(0, 0, 0, 0.3);
1615
+ border-radius: 8px;
1616
+ margin-top: 10px;
1617
+ }
1618
+
1619
+ .stage-content pre {
1620
+ white-space: pre-wrap;
1621
+ word-wrap: break-word;
1622
+ color: #e0e0e0;
1623
+ font-family: 'Courier New', monospace;
1624
+ line-height: 1.6;
1625
+ }
1626
+
1627
+ #novel-output {
1628
+ background-color: rgba(255, 255, 255, 0.95);
1629
+ padding: 30px;
1630
+ border-radius: 12px;
1631
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
1632
+ max-height: 800px;
1633
+ overflow-y: auto;
1634
+ }
1635
+
1636
+ .main-header {
1637
+ background-color: rgba(255, 255, 255, 0.1);
1638
+ backdrop-filter: blur(10px);
1639
+ padding: 30px;
1640
+ border-radius: 12px;
1641
+ margin-bottom: 30px;
1642
+ text-align: center;
1643
+ color: white;
1644
+ }
1645
+
1646
+ .input-section {
1647
+ background-color: rgba(255, 255, 255, 0.1);
1648
+ backdrop-filter: blur(10px);
1649
+ padding: 20px;
1650
+ border-radius: 12px;
1651
+ margin-bottom: 20px;
1652
+ }
1653
+
1654
+ .download-section {
1655
+ background-color: rgba(255, 255, 255, 0.9);
1656
+ padding: 15px;
1657
+ border-radius: 8px;
1658
+ margin-top: 20px;
1659
+ }
1660
+ """
1661
+
1662
+ # Create Gradio Interface
1663
+ def create_interface():
1664
+ with gr.Blocks(css=custom_css, title="SOMA Novel Writing System") as interface:
1665
+ gr.HTML("""
1666
+ <div class="main-header">
1667
+ <h1 style="font-size: 2.5em; margin-bottom: 10px;">
1668
+ ๐Ÿ“š SOMA Novel Writing System
1669
+ </h1>
1670
+ <h3 style="color: #ccc; margin-bottom: 20px;">
1671
+ AI Collaborative Novel Generation - 50 Page Novella Creator
1672
+ </h3>
1673
+ <p style="font-size: 1.1em; color: #ddd; max-width: 800px; margin: 0 auto;">
1674
+ Enter a theme or prompt, and watch as 13 AI agents collaborate to create a complete 50-page novella.
1675
+ The system includes 1 Director, 1 Critic, and 10 Writers working in harmony.
1676
+ </p>
1677
+ </div>
1678
+ """)
1679
+
1680
+ with gr.Row():
1681
+ with gr.Column(scale=1):
1682
+ with gr.Group(elem_classes=["input-section"]):
1683
+ query_input = gr.Textbox(
1684
+ label="Novel Theme / ์†Œ์„ค ์ฃผ์ œ",
1685
+ placeholder="Enter your novel theme or initial idea...\n์†Œ์„ค์˜ ์ฃผ์ œ๋‚˜ ์ดˆ๊ธฐ ์•„์ด๋””์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”...",
1686
+ lines=4
1687
+ )
1688
+
1689
+ language_select = gr.Radio(
1690
+ choices=["English", "Korean"],
1691
+ value="English",
1692
+ label="Language / ์–ธ์–ด"
1693
+ )
1694
+
1695
+ with gr.Row():
1696
+ submit_btn = gr.Button("๐Ÿš€ Start Writing / ์ž‘์„ฑ ์‹œ์ž‘", variant="primary", scale=2)
1697
+ clear_btn = gr.Button("๐Ÿ—‘๏ธ Clear / ์ดˆ๊ธฐํ™”", scale=1)
1698
+
1699
+ status_text = gr.Textbox(
1700
+ label="Status",
1701
+ interactive=False,
1702
+ value="๐Ÿ”„ Ready"
1703
+ )
1704
+
1705
+ gr.HTML("""
1706
+ <div style="margin-top: 20px; padding: 15px; background: rgba(255,255,255,0.1); border-radius: 8px; color: white;">
1707
+ <h4>Writing Process:</h4>
1708
+ <ol>
1709
+ <li>Director creates initial plan</li>
1710
+ <li>Critic reviews and suggests improvements</li>
1711
+ <li>Director revises the masterplan</li>
1712
+ <li>10 Writers each write 5 pages sequentially</li>
1713
+ <li>Critic reviews each writer's work</li>
1714
+ <li>Writers revise based on feedback</li>
1715
+ <li>Final compilation by Director</li>
1716
+ </ol>
1717
+ </div>
1718
+ """)
1719
+
1720
+ with gr.Column(scale=2):
1721
+ with gr.Tab("๐Ÿ“ Writing Process / ์ž‘์„ฑ ๊ณผ์ •"):
1722
+ process_display = gr.HTML(
1723
+ value="<div class='stages-container'><p style='color: #ccc; text-align: center;'>Process will appear here...</p></div>"
1724
+ )
1725
+
1726
+ with gr.Tab("๐Ÿ“– Final Novel / ์ตœ์ข… ์†Œ์„ค"):
1727
+ novel_output = gr.Markdown(
1728
+ value="",
1729
+ elem_id="novel-output"
1730
+ )
1731
+
1732
+ with gr.Group(elem_classes=["download-section"]):
1733
+ gr.Markdown("### ๐Ÿ“ฅ Download Novel / ์†Œ์„ค ๋‹ค์šด๋กœ๋“œ")
1734
+ with gr.Row():
1735
+ format_select = gr.Radio(
1736
+ choices=["DOCX", "TXT"],
1737
+ value="DOCX" if DOCX_AVAILABLE else "TXT",
1738
+ label="Format / ํ˜•์‹"
1739
+ )
1740
+ download_btn = gr.Button("โฌ‡๏ธ Download / ๋‹ค์šด๋กœ๋“œ", variant="secondary")
1741
+
1742
+ download_file = gr.File(
1743
+ label="Downloaded File / ๋‹ค์šด๋กœ๋“œ๋œ ํŒŒ์ผ",
1744
+ visible=False
1745
+ )
1746
+
1747
+ # Hidden state for novel text
1748
+ novel_text_state = gr.State("")
1749
+
1750
+ # Examples
1751
+ with gr.Row():
1752
+ gr.Examples(
1753
+ examples=[
1754
+ ["A scientist discovers a portal to parallel universes but each journey erases a memory"],
1755
+ ["In a world where dreams can be traded, a dream thief must steal the emperor's nightmare"],
1756
+ ["Two AI entities fall in love while trying to prevent a global cyber war"],
1757
+ ["๋ฏธ๋ž˜ ๋„์‹œ์—์„œ ๊ธฐ์–ต์„ ๊ฑฐ๋ž˜ํ•˜๋Š” ์ƒ์ธ๊ณผ ๋ชจ๋“  ๊ธฐ์–ต์„ ์žƒ์€ ํƒ์ •์˜ ์ด์•ผ๊ธฐ"],
1758
+ ["์‹œ๊ฐ„์ด ๊ฑฐ๊พธ๋กœ ํ๋ฅด๋Š” ๋งˆ์„์—์„œ ์ผ์–ด๋‚˜๋Š” ๋ฏธ์Šคํ„ฐ๋ฆฌํ•œ ์‚ด์ธ ์‚ฌ๊ฑด"],
1759
+ ["์ฑ… ์†์œผ๋กœ ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋Š” ๋Šฅ๋ ฅ์„ ๊ฐ€์ง„ ์‚ฌ์„œ์˜ ๋ชจํ—˜"]
1760
+ ],
1761
+ inputs=query_input,
1762
+ label="๐Ÿ’ก Example Themes / ์˜ˆ์ œ ์ฃผ์ œ"
1763
+ )
1764
+
1765
+ # Event handlers
1766
+ def update_novel_state(process, novel, status):
1767
+ return process, novel, status, novel
1768
+
1769
+ submit_btn.click(
1770
+ fn=process_query,
1771
+ inputs=[query_input, language_select],
1772
+ outputs=[process_display, novel_output, status_text]
1773
+ ).then(
1774
+ fn=update_novel_state,
1775
+ inputs=[process_display, novel_output, status_text],
1776
+ outputs=[process_display, novel_output, status_text, novel_text_state]
1777
+ )
1778
+
1779
+ clear_btn.click(
1780
+ fn=lambda: ("", "", "๐Ÿ”„ Ready", ""),
1781
+ outputs=[process_display, novel_output, status_text, novel_text_state]
1782
+ )
1783
+
1784
+ def handle_download(novel_text, format_type, language):
1785
+ if not novel_text:
1786
+ return gr.update(visible=False)
1787
+
1788
+ file_path = download_novel(novel_text, format_type, language)
1789
+ if file_path:
1790
+ return gr.update(value=file_path, visible=True)
1791
+ else:
1792
+ return gr.update(visible=False)
1793
+
1794
+ download_btn.click(
1795
+ fn=handle_download,
1796
+ inputs=[novel_text_state, format_select, language_select],
1797
+ outputs=[download_file]
1798
+ )
1799
+
1800
+ return interface
1801
+
1802
+ # Main execution
1803
+ if __name__ == "__main__":
1804
+ logger.info("Starting SOMA Novel Writing System...")
1805
+
1806
+ interface = create_interface()
1807
+
1808
+ interface.launch(
1809
+ server_name="0.0.0.0",
1810
+ server_port=7860,
1811
+ share=False,
1812
+ debug=True
1813
+ )