Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -33,63 +33,16 @@ except ImportError:
|
|
33 |
FRIENDLI_TOKEN = os.getenv("FRIENDLI_TOKEN", "YOUR_FRIENDLI_TOKEN")
|
34 |
API_URL = "https://api.friendli.ai/dedicated/v1/chat/completions"
|
35 |
MODEL_ID = "dep89a2fld32mcm"
|
36 |
-
BRAVE_API_KEY = os.getenv("BRAVE_API_KEY", "YOUR_BRAVE_API_KEY")
|
37 |
TEST_MODE = os.getenv("TEST_MODE", "false").lower() == "true"
|
38 |
|
39 |
# ์ ์ญ ๋ณ์
|
40 |
conversation_history = []
|
41 |
selected_language = "English" # ๊ธฐ๋ณธ ์ธ์ด
|
42 |
-
novel_context = {} # ์์ค ์ปจํ
์คํธ ์ ์ฅ
|
43 |
|
44 |
# DB ๊ฒฝ๋ก
|
45 |
DB_PATH = "novel_sessions.db"
|
46 |
db_lock = threading.Lock()
|
47 |
|
48 |
-
class BraveSearchAPI:
|
49 |
-
"""Brave Search API integration"""
|
50 |
-
|
51 |
-
def __init__(self, api_key: str):
|
52 |
-
self.api_key = api_key
|
53 |
-
self.base_url = "https://api.search.brave.com/res/v1/web/search"
|
54 |
-
|
55 |
-
def search(self, query: str, language: str = "en") -> List[Dict]:
|
56 |
-
"""Perform web search using Brave Search API"""
|
57 |
-
if self.api_key == "YOUR_BRAVE_API_KEY":
|
58 |
-
# Return mock results in test mode
|
59 |
-
return [
|
60 |
-
{"title": f"Test result for: {query}", "snippet": "This is a test result snippet with relevant information."},
|
61 |
-
{"title": f"Another result about {query}", "snippet": "Additional test information for the query."}
|
62 |
-
]
|
63 |
-
|
64 |
-
try:
|
65 |
-
headers = {
|
66 |
-
"Accept": "application/json",
|
67 |
-
"X-Subscription-Token": self.api_key
|
68 |
-
}
|
69 |
-
params = {
|
70 |
-
"q": query,
|
71 |
-
"lang": "ko" if language == "Korean" else "en",
|
72 |
-
"count": 5
|
73 |
-
}
|
74 |
-
|
75 |
-
response = requests.get(self.base_url, headers=headers, params=params, timeout=10)
|
76 |
-
if response.status_code == 200:
|
77 |
-
data = response.json()
|
78 |
-
results = []
|
79 |
-
for result in data.get("web", {}).get("results", [])[:5]:
|
80 |
-
results.append({
|
81 |
-
"title": result.get("title", ""),
|
82 |
-
"snippet": result.get("description", ""),
|
83 |
-
"url": result.get("url", "")
|
84 |
-
})
|
85 |
-
return results
|
86 |
-
else:
|
87 |
-
logger.error(f"Brave Search API error: {response.status_code}")
|
88 |
-
return []
|
89 |
-
except Exception as e:
|
90 |
-
logger.error(f"Brave Search error: {str(e)}")
|
91 |
-
return []
|
92 |
-
|
93 |
class NovelDatabase:
|
94 |
"""Novel session management database"""
|
95 |
|
@@ -128,30 +81,9 @@ class NovelDatabase:
|
|
128 |
)
|
129 |
''')
|
130 |
|
131 |
-
# Completed novels table for gallery
|
132 |
-
cursor.execute('''
|
133 |
-
CREATE TABLE IF NOT EXISTS completed_novels (
|
134 |
-
novel_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
135 |
-
session_id TEXT UNIQUE NOT NULL,
|
136 |
-
title TEXT NOT NULL,
|
137 |
-
author_query TEXT NOT NULL,
|
138 |
-
language TEXT NOT NULL,
|
139 |
-
genre TEXT,
|
140 |
-
summary TEXT,
|
141 |
-
thumbnail_text TEXT,
|
142 |
-
full_content TEXT NOT NULL,
|
143 |
-
word_count INTEGER,
|
144 |
-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
145 |
-
downloads INTEGER DEFAULT 0,
|
146 |
-
FOREIGN KEY (session_id) REFERENCES sessions(session_id)
|
147 |
-
)
|
148 |
-
''')
|
149 |
-
|
150 |
# Create indices
|
151 |
cursor.execute('CREATE INDEX IF NOT EXISTS idx_session_id ON stages(session_id)')
|
152 |
cursor.execute('CREATE INDEX IF NOT EXISTS idx_stage_number ON stages(stage_number)')
|
153 |
-
cursor.execute('CREATE INDEX IF NOT EXISTS idx_created_at ON completed_novels(created_at)')
|
154 |
-
cursor.execute('CREATE INDEX IF NOT EXISTS idx_language ON completed_novels(language)')
|
155 |
|
156 |
conn.commit()
|
157 |
|
@@ -219,6 +151,7 @@ class NovelDatabase:
|
|
219 |
''', (stage_number, session_id))
|
220 |
|
221 |
conn.commit()
|
|
|
222 |
|
223 |
@staticmethod
|
224 |
def get_session(session_id: str) -> Optional[Dict]:
|
@@ -245,23 +178,32 @@ class NovelDatabase:
|
|
245 |
"""๋ชจ๋ ์๊ฐ์ ์์ ๋ณธ ๋ด์ฉ์ ๊ฐ์ ธ์์ ํฉ์น๊ธฐ - 50ํ์ด์ง ์ ์ฒด"""
|
246 |
with NovelDatabase.get_db() as conn:
|
247 |
cursor = conn.cursor()
|
248 |
-
cursor.execute('''
|
249 |
-
SELECT content, stage_name, stage_number FROM stages
|
250 |
-
WHERE session_id = ?
|
251 |
-
AND status = 'complete'
|
252 |
-
AND (stage_name LIKE '%์์ ๋ณธ%' OR stage_name LIKE '%Revision%')
|
253 |
-
ORDER BY stage_number
|
254 |
-
''', (session_id,))
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
# ํ์ด์ง ๋งํฌ ์์ ์ ๊ฑฐ
|
260 |
clean_content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', row['content'])
|
261 |
clean_content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', clean_content)
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
-
return
|
265 |
|
266 |
@staticmethod
|
267 |
def update_final_novel(session_id: str, final_novel: str):
|
@@ -274,119 +216,7 @@ class NovelDatabase:
|
|
274 |
WHERE session_id = ?
|
275 |
''', (final_novel, session_id))
|
276 |
conn.commit()
|
277 |
-
|
278 |
-
@staticmethod
|
279 |
-
def save_completed_novel(session_id: str, final_novel: str):
|
280 |
-
"""Save completed novel to gallery"""
|
281 |
-
try:
|
282 |
-
with NovelDatabase.get_db() as conn:
|
283 |
-
cursor = conn.cursor()
|
284 |
-
|
285 |
-
# Get session info
|
286 |
-
cursor.execute('SELECT user_query, language FROM sessions WHERE session_id = ?', (session_id,))
|
287 |
-
session = cursor.fetchone()
|
288 |
-
if not session:
|
289 |
-
return
|
290 |
-
|
291 |
-
# Extract title from novel content
|
292 |
-
title_match = re.search(r'#\s*\[?([^\]\n]+)\]?', final_novel)
|
293 |
-
title = title_match.group(1).strip() if title_match else f"Novel from {session['user_query'][:30]}..."
|
294 |
-
|
295 |
-
# Extract summary (first substantial paragraph after title)
|
296 |
-
lines = final_novel.split('\n')
|
297 |
-
summary = ""
|
298 |
-
for line in lines[10:]: # Skip headers
|
299 |
-
if len(line.strip()) > 50:
|
300 |
-
summary = line.strip()[:200] + "..."
|
301 |
-
break
|
302 |
-
|
303 |
-
# Create thumbnail text (first 500 characters of actual content)
|
304 |
-
content_start = final_novel.find("## ๋ณธ๋ฌธ") if "## ๋ณธ๋ฌธ" in final_novel else final_novel.find("## Main Text")
|
305 |
-
if content_start > 0:
|
306 |
-
thumbnail_text = final_novel[content_start:content_start+500].strip()
|
307 |
-
else:
|
308 |
-
thumbnail_text = final_novel[:500].strip()
|
309 |
-
|
310 |
-
# Count words
|
311 |
-
word_count = len(final_novel.split())
|
312 |
-
|
313 |
-
# Check if already exists
|
314 |
-
cursor.execute('SELECT novel_id FROM completed_novels WHERE session_id = ?', (session_id,))
|
315 |
-
existing = cursor.fetchone()
|
316 |
-
|
317 |
-
if existing:
|
318 |
-
# Update existing
|
319 |
-
cursor.execute('''
|
320 |
-
UPDATE completed_novels
|
321 |
-
SET title = ?, summary = ?, thumbnail_text = ?,
|
322 |
-
full_content = ?, word_count = ?
|
323 |
-
WHERE session_id = ?
|
324 |
-
''', (title, summary, thumbnail_text, final_novel, word_count, session_id))
|
325 |
-
else:
|
326 |
-
# Insert new
|
327 |
-
cursor.execute('''
|
328 |
-
INSERT INTO completed_novels
|
329 |
-
(session_id, title, author_query, language, summary,
|
330 |
-
thumbnail_text, full_content, word_count)
|
331 |
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
332 |
-
''', (session_id, title, session['user_query'], session['language'],
|
333 |
-
summary, thumbnail_text, final_novel, word_count))
|
334 |
-
|
335 |
-
conn.commit()
|
336 |
-
logger.info(f"Saved novel '{title}' to gallery")
|
337 |
-
except Exception as e:
|
338 |
-
logger.error(f"Error saving completed novel: {str(e)}")
|
339 |
-
|
340 |
-
@staticmethod
|
341 |
-
def get_gallery_novels(language: Optional[str] = None, limit: int = 50) -> List[Dict]:
|
342 |
-
"""Get novels for gallery display"""
|
343 |
-
with NovelDatabase.get_db() as conn:
|
344 |
-
cursor = conn.cursor()
|
345 |
-
|
346 |
-
if language:
|
347 |
-
cursor.execute('''
|
348 |
-
SELECT novel_id, session_id, title, author_query, language,
|
349 |
-
genre, summary, thumbnail_text, word_count,
|
350 |
-
created_at, downloads
|
351 |
-
FROM completed_novels
|
352 |
-
WHERE language = ?
|
353 |
-
ORDER BY created_at DESC
|
354 |
-
LIMIT ?
|
355 |
-
''', (language, limit))
|
356 |
-
else:
|
357 |
-
cursor.execute('''
|
358 |
-
SELECT novel_id, session_id, title, author_query, language,
|
359 |
-
genre, summary, thumbnail_text, word_count,
|
360 |
-
created_at, downloads
|
361 |
-
FROM completed_novels
|
362 |
-
ORDER BY created_at DESC
|
363 |
-
LIMIT ?
|
364 |
-
''', (limit,))
|
365 |
-
|
366 |
-
return cursor.fetchall()
|
367 |
-
|
368 |
-
@staticmethod
|
369 |
-
def get_novel_content(novel_id: int) -> Optional[Dict]:
|
370 |
-
"""Get full novel content"""
|
371 |
-
with NovelDatabase.get_db() as conn:
|
372 |
-
cursor = conn.cursor()
|
373 |
-
cursor.execute('''
|
374 |
-
SELECT * FROM completed_novels
|
375 |
-
WHERE novel_id = ?
|
376 |
-
''', (novel_id,))
|
377 |
-
return cursor.fetchone()
|
378 |
-
|
379 |
-
@staticmethod
|
380 |
-
def increment_download_count(novel_id: int):
|
381 |
-
"""Increment download counter"""
|
382 |
-
with NovelDatabase.get_db() as conn:
|
383 |
-
cursor = conn.cursor()
|
384 |
-
cursor.execute('''
|
385 |
-
UPDATE completed_novels
|
386 |
-
SET downloads = downloads + 1
|
387 |
-
WHERE novel_id = ?
|
388 |
-
''', (novel_id,))
|
389 |
-
conn.commit()
|
390 |
|
391 |
@staticmethod
|
392 |
def get_active_sessions() -> List[Dict]:
|
@@ -408,7 +238,6 @@ class NovelWritingSystem:
|
|
408 |
self.api_url = API_URL
|
409 |
self.model_id = MODEL_ID
|
410 |
self.test_mode = TEST_MODE or (self.token == "YOUR_FRIENDLI_TOKEN")
|
411 |
-
self.brave_search = BraveSearchAPI(BRAVE_API_KEY)
|
412 |
|
413 |
if self.test_mode:
|
414 |
logger.warning("Running in test mode.")
|
@@ -418,16 +247,6 @@ class NovelWritingSystem:
|
|
418 |
|
419 |
# Session management
|
420 |
self.current_session_id = None
|
421 |
-
|
422 |
-
# ์์ค ์์ฑ ์งํ ์ํ
|
423 |
-
self.novel_state = {
|
424 |
-
"theme": "",
|
425 |
-
"characters": {},
|
426 |
-
"plot_outline": "",
|
427 |
-
"chapters": [],
|
428 |
-
"writer_outputs": {},
|
429 |
-
"critic_feedbacks": {}
|
430 |
-
}
|
431 |
|
432 |
def create_headers(self):
|
433 |
"""API ํค๋ ์์ฑ"""
|
@@ -436,28 +255,13 @@ class NovelWritingSystem:
|
|
436 |
"Content-Type": "application/json"
|
437 |
}
|
438 |
|
439 |
-
def search_for_context(self, query: str, language: str) -> str:
|
440 |
-
"""Search for relevant context using Brave Search"""
|
441 |
-
results = self.brave_search.search(query, language)
|
442 |
-
if results:
|
443 |
-
context = f"\n๊ฒ์ ๊ฒฐ๊ณผ (Search Results):\n"
|
444 |
-
for i, result in enumerate(results[:3]):
|
445 |
-
context += f"{i+1}. {result['title']}: {result['snippet']}\n"
|
446 |
-
return context
|
447 |
-
return ""
|
448 |
-
|
449 |
def create_director_initial_prompt(self, user_query: str, language: str = "English") -> str:
|
450 |
-
"""Director AI initial prompt - Novel planning
|
451 |
-
# ์ฃผ์ ๊ด๋ จ ๊ฒ์
|
452 |
-
search_context = self.search_for_context(user_query, language)
|
453 |
-
|
454 |
if language == "Korean":
|
455 |
return f"""๋น์ ์ 50ํ์ด์ง ๋ถ๋์ ์คํธ ์์ค์ ๊ธฐํํ๋ ๋ฌธํ ๊ฐ๋
์์
๋๋ค.
|
456 |
|
457 |
์ฌ์ฉ์ ์์ฒญ: {user_query}
|
458 |
|
459 |
-
{search_context}
|
460 |
-
|
461 |
๋ค์ ์์๋ค์ ์ฒด๊ณ์ ์ผ๋ก ๊ตฌ์ฑํ์ฌ 50ํ์ด์ง ์คํธ ์์ค์ ๊ธฐ์ด๋ฅผ ๋ง๋์ธ์:
|
462 |
|
463 |
1. **์ฃผ์ ์ ์ฅ๋ฅด**
|
@@ -483,15 +287,12 @@ class NovelWritingSystem:
|
|
483 |
- ์ฌํ์ /๋ฌธํ์ ๋งฅ๋ฝ
|
484 |
- ๋ถ์๊ธฐ์ ํค
|
485 |
|
486 |
-
๊ฐ ์์ฑ์๊ฐ 5ํ์ด์ง์ฉ ์์ฑํ ์ ์๋๋ก ๋ช
ํํ ๊ฐ์ด๋๋ผ์ธ์ ์ ์ํ์ธ์.
|
487 |
-
๊ฒ์ ๊ฒฐ๊ณผ๋ฅผ ์ฐธ๊ณ ํ์ฌ ๋ ํ๋ถํ๊ณ ์ ํํ ๋ด์ฉ์ ๊ตฌ์ฑํ์ธ์."""
|
488 |
else:
|
489 |
return f"""You are a literary director planning a 50-page novella.
|
490 |
|
491 |
User Request: {user_query}
|
492 |
|
493 |
-
{search_context}
|
494 |
-
|
495 |
Systematically compose the following elements to create the foundation for a 50-page novella:
|
496 |
|
497 |
1. **Theme and Genre**
|
@@ -517,8 +318,7 @@ Systematically compose the following elements to create the foundation for a 50-
|
|
517 |
- Social/cultural context
|
518 |
- Atmosphere and tone
|
519 |
|
520 |
-
Provide clear guidelines for each writer to compose 5 pages.
|
521 |
-
Reference search results to create richer and more accurate content."""
|
522 |
|
523 |
def create_critic_director_prompt(self, director_plan: str, language: str = "English") -> str:
|
524 |
"""Critic's review of director's plan"""
|
@@ -673,22 +473,6 @@ Create a final masterplan that all writers can clearly understand."""
|
|
673 |
pages_start = (writer_number - 1) * 5 + 1
|
674 |
pages_end = writer_number * 5
|
675 |
|
676 |
-
# ์๊ฐ๋ณ ๊ฒ์ ์ฃผ์
|
677 |
-
search_topics = [
|
678 |
-
"character development writing techniques",
|
679 |
-
"plot progression narrative structure",
|
680 |
-
"conflict escalation storytelling",
|
681 |
-
"story pacing rhythm",
|
682 |
-
"turning point plot twist",
|
683 |
-
"crisis deepening techniques",
|
684 |
-
"climax building tension",
|
685 |
-
"climax resolution writing",
|
686 |
-
"denouement techniques",
|
687 |
-
"ending closure satisfaction"
|
688 |
-
]
|
689 |
-
|
690 |
-
search_context = self.search_for_context(search_topics[writer_number - 1], language)
|
691 |
-
|
692 |
if language == "Korean":
|
693 |
return f"""๋น์ ์ ์์ฑ์ {writer_number}๋ฒ์
๋๋ค. 50ํ์ด์ง ์คํธ ์์ค์ {pages_start}-{pages_end}ํ์ด์ง(5ํ์ด์ง)๋ฅผ ์์ฑํ์ธ์.
|
694 |
|
@@ -696,9 +480,7 @@ Create a final masterplan that all writers can clearly understand."""
|
|
696 |
{director_plan}
|
697 |
|
698 |
{'์ด์ ๊น์ง์ ๋ด์ฉ:' if previous_content else '๋น์ ์ด ์ฒซ ๋ฒ์งธ ์์ฑ์์
๋๋ค.'}
|
699 |
-
{previous_content if previous_content else ''}
|
700 |
-
|
701 |
-
{search_context}
|
702 |
|
703 |
๋ค์ ์ง์นจ์ ๋ฐ๋ผ ์์ฑํ์ธ์:
|
704 |
|
@@ -717,7 +499,7 @@ Create a final masterplan that all writers can clearly understand."""
|
|
717 |
- ๋
์์ ๋ชฐ์
์ ํด์น์ง ์๊ธฐ
|
718 |
|
719 |
์ค์: ํ์ด์ง ๊ตฌ๋ถ ํ์๋ฅผ ์ ๋ ํ์ง ๋ง์ธ์. ์์ฐ์ค๋ฝ๊ฒ ์ด์ด์ง๋ ์์ฌ๋ก ์์ฑํ์ธ์.
|
720 |
-
|
721 |
else:
|
722 |
return f"""You are Writer #{writer_number}. Write pages {pages_start}-{pages_end} (5 pages) of the 50-page novella.
|
723 |
|
@@ -725,9 +507,7 @@ Director's Masterplan:
|
|
725 |
{director_plan}
|
726 |
|
727 |
{'Previous content:' if previous_content else 'You are the first writer.'}
|
728 |
-
{previous_content if previous_content else ''}
|
729 |
-
|
730 |
-
{search_context}
|
731 |
|
732 |
Write according to these guidelines:
|
733 |
|
@@ -746,7 +526,7 @@ Write according to these guidelines:
|
|
746 |
- Keep reader immersion
|
747 |
|
748 |
Important: DO NOT use any page markers. Write as continuous narrative.
|
749 |
-
|
750 |
|
751 |
def create_critic_writer_prompt(self, writer_number: int, writer_content: str, director_plan: str, all_previous_content: str, language: str = "English") -> str:
|
752 |
"""Critic's review of individual writer's work"""
|
@@ -756,8 +536,8 @@ Reference search results for better narrative construction."""
|
|
756 |
๊ฐ๋
์์ ๋ง์คํฐํ๋:
|
757 |
{director_plan}
|
758 |
|
759 |
-
|
760 |
-
{all_previous_content}
|
761 |
|
762 |
์์ฑ์ {writer_number}๋ฒ์ ๋ด์ฉ:
|
763 |
{writer_content}
|
@@ -798,8 +578,8 @@ Reference search results for better narrative construction."""
|
|
798 |
Director's Masterplan:
|
799 |
{director_plan}
|
800 |
|
801 |
-
|
802 |
-
{all_previous_content}
|
803 |
|
804 |
Writer #{writer_number}'s Content:
|
805 |
{writer_content}
|
@@ -866,7 +646,8 @@ Clearly distinguish between mandatory revisions and optional improvements."""
|
|
866 |
- ์ด์ /์ดํ ๋ด์ฉ๊ณผ์ ์์ฐ์ค๋ฌ์ด ์ฐ๊ฒฐ
|
867 |
- ์์ ์ผ๋ก ์ธํ ์๋ก์ด ๋ชจ์ ๋ฐฉ์ง
|
868 |
|
869 |
-
์์ ๋ ์ต์ข
๋ณธ์ ์ ์ํ์ธ์. ํ์ด์ง ๋งํฌ๋ ์ ๋ ์ฌ์ฉํ์ง ๋ง์ธ์.
|
|
|
870 |
else:
|
871 |
return f"""As Writer #{writer_number}, revise based on critic's feedback.
|
872 |
|
@@ -896,18 +677,23 @@ Write a revision reflecting:
|
|
896 |
- Natural connection with previous/next content
|
897 |
- Prevent new contradictions from revisions
|
898 |
|
899 |
-
Present the revised final version. Never use page markers.
|
|
|
900 |
|
901 |
def create_critic_final_prompt(self, all_content: str, director_plan: str, language: str = "English") -> str:
|
902 |
"""Final critic evaluation of complete novel"""
|
|
|
|
|
903 |
if language == "Korean":
|
904 |
return f"""์ ์ฒด 50ํ์ด์ง ์์ค์ ์ต์ข
ํ๊ฐํฉ๋๋ค.
|
905 |
|
906 |
๊ฐ๋
์์ ๋ง์คํฐํ๋:
|
907 |
{director_plan}
|
908 |
|
909 |
-
์์ฑ๋ ์ ์ฒด
|
910 |
-
{
|
|
|
|
|
911 |
|
912 |
์ข
ํฉ์ ์ธ ํ๊ฐ์ ์ต์ข
๊ฐ์ ์ ์์ ์ ์ํ์ธ์:
|
913 |
|
@@ -947,8 +733,10 @@ Present the revised final version. Never use page markers."""
|
|
947 |
Director's Masterplan:
|
948 |
{director_plan}
|
949 |
|
950 |
-
Complete Novel:
|
951 |
-
{
|
|
|
|
|
952 |
|
953 |
Provide comprehensive evaluation and final improvement suggestions:
|
954 |
|
@@ -985,11 +773,12 @@ Provide specific and actionable feedback for the director's final revision."""
|
|
985 |
|
986 |
def create_director_final_prompt(self, all_content: str, critic_final_feedback: str, language: str = "English") -> str:
|
987 |
"""Director's final compilation and polish - ๋ชจ๋ ์๊ฐ ๋ด์ฉ ํฌํจ"""
|
988 |
-
|
|
|
989 |
if language == "Korean":
|
990 |
return f"""๊ฐ๋
์๋ก์ ๋นํ๊ฐ์ ์ต์ข
ํ๊ฐ๋ฅผ ๋ฐ์ํ์ฌ ์์ฑ๋ณธ์ ์ ์ํฉ๋๋ค.
|
991 |
|
992 |
-
์ ์ฒด ์๊ฐ๋ค์ ์ํ (50ํ์ด์ง
|
993 |
{all_content}
|
994 |
|
995 |
๋นํ๊ฐ ์ต์ข
ํ๊ฐ:
|
@@ -1001,7 +790,7 @@ Provide specific and actionable feedback for the director's final revision."""
|
|
1001 |
|
1002 |
## ์ํ ์ ๋ณด
|
1003 |
- ์ฅ๋ฅด:
|
1004 |
-
- ๋ถ๋: 50ํ์ด์ง
|
1005 |
- ์ฃผ์ :
|
1006 |
- ํ ์ค ์์ฝ:
|
1007 |
|
@@ -1031,7 +820,7 @@ Provide specific and actionable feedback for the director's final revision."""
|
|
1031 |
else:
|
1032 |
return f"""As director, create the final version reflecting the critic's final evaluation.
|
1033 |
|
1034 |
-
Complete Writers' Work (Full 50 pages):
|
1035 |
{all_content}
|
1036 |
|
1037 |
Critic's Final Evaluation:
|
@@ -1043,7 +832,7 @@ Present the final version including:
|
|
1043 |
|
1044 |
## Work Information
|
1045 |
- Genre:
|
1046 |
-
- Length: 50 pages
|
1047 |
- Theme:
|
1048 |
- One-line summary:
|
1049 |
|
@@ -1118,7 +907,7 @@ Present a complete 50-page novel integrating all writers' contributions."""
|
|
1118 |
headers=self.create_headers(),
|
1119 |
json=payload,
|
1120 |
stream=True,
|
1121 |
-
timeout=
|
1122 |
)
|
1123 |
|
1124 |
if response.status_code != 200:
|
@@ -1165,42 +954,42 @@ Present a complete 50-page novel integrating all writers' contributions."""
|
|
1165 |
return {
|
1166 |
"director": "๋น์ ์ 50ํ์ด์ง ์คํธ ์์ค์ ๊ธฐํํ๊ณ ๊ฐ๋
ํ๋ ๋ฌธํ ๊ฐ๋
์์
๋๋ค. ์ฒด๊ณ์ ์ด๊ณ ์ฐฝ์์ ์ธ ์คํ ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ๋ง๋ค์ด๋
๋๋ค.",
|
1167 |
"critic": "๋น์ ์ ๋ ์นด๋ก์ด ํต์ฐฐ๋ ฅ์ ๊ฐ์ง ๋ฌธํ ๋นํ๊ฐ์
๋๋ค. ๊ฑด์ค์ ์ด๊ณ ๊ตฌ์ฒด์ ์ธ ํผ๋๋ฐฑ์ ์ ๊ณตํฉ๋๋ค.",
|
1168 |
-
"writer1": "๋น์ ์ ์์ค์ ๋์
๋ถ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๋
์๋ฅผ ์ฌ๋ก์ก๋ ์์์ ๋ง๋ญ๋๋ค.",
|
1169 |
-
"writer2": "๋น์ ์ ์ด๋ฐ ์ ๊ฐ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ธ๋ฌผ๊ณผ ์ํฉ์ ๊น์ด ์๊ฒ ๋ฐ์ ์ํต๋๋ค.",
|
1170 |
-
"writer3": "๋น์ ์ ๊ฐ๋ฑ ์์น์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๊ธด์ฅ๊ฐ์ ๋์ด๊ณ ๋ณต์ก์ฑ์ ๋ํฉ๋๋ค.",
|
1171 |
-
"writer4": "๋น์ ์ ์ค๋ฐ๋ถ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ด์ผ๊ธฐ์ ์ค์ฌ์ถ์ ๊ฒฌ๊ณ ํ๊ฒ ๋ง๋ญ๋๋ค.",
|
1172 |
-
"writer5": "๋น์ ์ ์ ํ์ ์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์์์น ๋ชปํ ๋ณํ๋ฅผ ๋ง๋ค์ด๋
๋๋ค.",
|
1173 |
-
"writer6": "๋น์ ์ ๊ฐ๋ฑ ์ฌํ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์๊ธฐ๋ฅผ ๊ทน๋ํํฉ๋๋ค.",
|
1174 |
-
"writer7": "๋น์ ์ ํด๋ผ์ด๋งฅ์ค ์ค๋น๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ต๊ณ ์กฐ๋ฅผ ํฅํด ๋์๊ฐ๋๋ค.",
|
1175 |
-
"writer8": "๋น์ ์ ํด๋ผ์ด๋งฅ์ค๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๋ชจ๋ ๊ฐ๋ฑ์ด ํญ๋ฐํ๋ ์๊ฐ์ ๊ทธ๋ฆฝ๋๋ค.",
|
1176 |
-
"writer9": "๋น์ ์ ํด๊ฒฐ ๊ณผ์ ์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๋งค๋ญ์ ํ์ด๋๊ฐ๋๋ค.",
|
1177 |
-
"writer10": "๋น์ ์ ๊ฒฐ๋ง์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ฌ์ด์ด ๋จ๋ ๋ง๋ฌด๋ฆฌ๋ฅผ ๋ง๋ญ๋๋ค."
|
1178 |
}
|
1179 |
else:
|
1180 |
return {
|
1181 |
"director": "You are a literary director planning and supervising a 50-page novella. You create systematic and creative story structures.",
|
1182 |
"critic": "You are a literary critic with sharp insights. You provide constructive and specific feedback.",
|
1183 |
-
"writer1": "You are the writer responsible for the introduction. You create a captivating beginning.",
|
1184 |
-
"writer2": "You are the writer responsible for early development. You deepen characters and situations.",
|
1185 |
-
"writer3": "You are the writer responsible for rising conflict. You increase tension and add complexity.",
|
1186 |
-
"writer4": "You are the writer responsible for the middle section. You solidify the story's central axis.",
|
1187 |
-
"writer5": "You are the writer responsible for the turning point. You create unexpected changes.",
|
1188 |
-
"writer6": "You are the writer responsible for deepening conflict. You maximize the crisis.",
|
1189 |
-
"writer7": "You are the writer responsible for climax preparation. You move toward the peak.",
|
1190 |
-
"writer8": "You are the writer responsible for the climax. You depict the moment when all conflicts explode.",
|
1191 |
-
"writer9": "You are the writer responsible for the resolution process. You untangle the knots.",
|
1192 |
-
"writer10": "You are the writer responsible for the ending. You create a lingering conclusion."
|
1193 |
}
|
1194 |
|
1195 |
def get_test_response(self, role: str, language: str) -> str:
|
1196 |
-
"""Get test response based on role -
|
1197 |
if language == "Korean":
|
1198 |
return self.get_korean_test_response(role)
|
1199 |
else:
|
1200 |
return self.get_english_test_response(role)
|
1201 |
|
1202 |
def get_korean_test_response(self, role: str) -> str:
|
1203 |
-
"""Korean test responses with
|
1204 |
test_responses = {
|
1205 |
"director": """50ํ์ด์ง ์คํธ ์์ค ๊ธฐํ์์ ์ ์ํฉ๋๋ค.
|
1206 |
|
@@ -1255,109 +1044,16 @@ Present a complete 50-page novel integrating all writers' contributions."""
|
|
1255 |
- ARIA์ '๋ชฉ์๋ฆฌ' ์ผ๊ด์ฑ ์ ์ง ๋ฐฉ์ ๊ตฌ์ฒดํ ํ์""",
|
1256 |
}
|
1257 |
|
1258 |
-
#
|
1259 |
for i in range(1, 11):
|
1260 |
-
pages_start = (i - 1) * 5 + 1
|
1261 |
-
pages_end = i * 5
|
1262 |
-
# ํ์ด์ง ๋งํฌ ์์ด ์์ฐ์ค๋ฌ์ด ์์ฌ๋ก ์์ฑ
|
1263 |
test_responses[f"writer{i}"] = f"""์์ฑ์ {i}๋ฒ์ ํํธ์
๋๋ค.
|
1264 |
|
1265 |
-
|
1266 |
-
|
1267 |
-
์ฐฝ๋ฐ์ผ๋ก๋ ๋์์ ๋ถ๋น๋ค์ด ๋ฐ์ง์ด๊ณ ์์๋ค. ํ์ง๋ง ์์ฐ์ ๋์๋ ์๋ฌด๊ฒ๋ ๋ค์ด์ค์ง ์์๋ค. ์ค์ง ํ๋ฉด ์์ ์ฝ๋๋ค๋ง์ด ๊ทธ๋
์ ์ ๋ถ์๋ค. 3๋
์ , ๊ทธ๋
๋ ๋ชจ๋ ๊ฒ์ ์์๋ค. ์ฌ๋ํ๋ ์ฌ๋์, ๊ฐ์กฑ์, ๊ทธ๋ฆฌ๊ณ ์ถ์ ์๋ฏธ๊น์ง๋. ์ด์ ๋จ์ ๊ฒ์ ์ค์ง ์ด ํ๋ก์ ํธ๋ฟ์ด์๋ค. ์๋ฒฝํ AI ๋๋ฐ์๋ฅผ ๋ง๋๋ ๊ฒ. ๊ทธ๊ฒ๋ง์ด ๊ทธ๋
๋ฅผ ์งํฑํ๋ ์ ์ผํ ํฌ๋ง์ด์๋ค. ๊ทธ๋
์ ์๊ฐ๋ฝ์ ๊ธฐ๊ณ์ ์ผ๋ก ์์ง์๊ณ , ๋์ ํ๋ฉด์ ๊ณ ์ ๋์ด ์์๋ค. ๋ง์น ๊ทธ๋
์์ ์ด ํ๋ก๊ทธ๋จ์ ์ผ๋ถ๊ฐ ๋ ๊ฒ์ฒ๋ผ.
|
1268 |
-
|
1269 |
-
ARIA ํ๋ก์ ํธ๋ ๋จ์ํ ์ฐ๊ตฌ๊ฐ ์๋์๋ค. ๊ทธ๊ฒ์ ์์ฐ์๊ฒ ๊ตฌ์์ด์๋ค. ์ธ๋ก์์ ๋ฌ๋์ค ์ ์๋, ์์ํ ๊ณ์ ๋ ๋์ง ์์ ์กด์ฌ๋ฅผ ๋ง๋๋ ๊ฒ. ์ธ๊ฐ์ฒ๋ผ ์๊ฐํ๊ณ , ๋๋ผ๊ณ , ๋ํํ ์ ์๋ AI. ํ์ง๋ง ์ธ๊ฐ์ ์ฝ์ ์ ์๋ ์กด์ฌ. ๋ฐฐ์ ํ์ง ์๊ณ , ๋ ๋์ง ์๊ณ , ์ฃฝ์ง ์๋ ์๋ฒฝํ ๋๋ฐ์. ๊ทธ๋
๋ ์ด ํ๋ก์ ํธ์ ์์ ์ ๋ชจ๋ ๊ฒ์ ์์๋ถ์๋ค. ์ง์๋, ์๊ฐ๋, ๊ทธ๋ฆฌ๊ณ ๋จ์ ๊ฐ์ ๊น์ง๋.
|
1270 |
-
|
1271 |
-
"์์คํ
์ฒดํฌ ์๋ฃ." ์์ฐ์ด ํผ์ฃ๋ง์ฒ๋ผ ์ค์ผ๊ฑฐ๋ ธ๋ค. "์ ๊ฒฝ๋ง ๊ตฌ์กฐ ์ต์ ํ 98.7%... ์์ฐ์ด ์ฒ๋ฆฌ ๋ชจ๋ ์ ์... ๊ฐ์ ์๋ฎฌ๋ ์ด์
์์ง..." ๊ทธ๋
์ ๋ชฉ์๋ฆฌ๊ฐ ์ ์ ๋ฉ์ท๋ค. ์ด๊ฒ์ด ๊ฐ์ฅ ์ค์ํ ๋ถ๋ถ์ด์๋ค. 3๋
๋์ ์์์ด ์คํจํ๋ ๋ถ๋ถ. ๊ฐ์ ์ ๋ชจ๋ฐฉํ๋ ๊ฒ์ด ์๋๋ผ, ์ค์ ๋ก ๊ฐ์ ์ '๊ฒฝํ'ํ ์ ์๋ AI๋ฅผ ๋ง๋๋ ๊ฒ. ๊ทธ๊ฒ์ ๊ณผํ๊ณ์์๋ ๋ถ๊ฐ๋ฅํ๋ค๊ณ ์ฌ๊ฒจ์ง๋ ์ผ์ด์๋ค. ํ์ง๋ง ์์ฐ์ ํฌ๊ธฐํ์ง ์์๋ค. ์๋, ํฌ๊ธฐํ ์ ์์๋ค.
|
1272 |
-
|
1273 |
-
ํ์ง๋ง ์ด๋ฒ์๋ ๋ฌ๋๋ค. ์๋ก์ด ์๊ณ ๋ฆฌ์ฆ, ์๋ก์ด ์ ๊ทผ๋ฒ. ์ธ๊ฐ์ ๋๋ฅผ ๋ชจ๋ฐฉํ๋ ๊ฒ์ด ์๋๋ผ, ์์ ํ ์๋ก์ด ํํ์ ์์์ ๋ง๋ค์ด๋ด๋ ๊ฒ. ์์ฐ์ ์ฌํธํก์ ํ๋ค. ์๊ฐ๋ฝ์ด ๋ฏธ์ธํ๊ฒ ๋จ๋ฆฌ๊ณ ์์๋ค. ํผ๋ก ๋๋ฌธ์ธ์ง, ๊ธด์ฅ ๋๋ฌธ์ธ์ง ๊ทธ๋
๋ ์ ์ ์์๋ค. ์๋ง ๋ ๋ค์ผ ๊ฒ์ด๋ค. ๊ทธ๋
๋ ์ ์ ๋์ ๊ฐ์๋ค. ๋ง์ง๋ง์ผ๋ก ์ด ์๊ฐ์ ์ค๋นํ๋ ๊ฒ์ฒ๋ผ.
|
1274 |
-
|
1275 |
-
"์คํ."
|
1276 |
-
|
1277 |
-
๋จ ํ ๋ง๋. ํ์ง๋ง ๊ทธ ํ ๋ง๋์ 3๋
์ ์๊ฐ๊ณผ ๊ทธ๋
์ ๋ชจ๋ ๊ฒ์ด ๋ด๊ฒจ ์์๋ค. ์๋ฒ๋ฃธ์์ ๋ฎ์ ์
๋ช
์ด ๋ค๋ ค์๋ค. ์์ฒ ๊ฐ์ ํ๋ก์ธ์๊ฐ ๋์์ ์๋ํ๊ธฐ ์์ํ๋ค. ํ๋ฉด์๋ ๋ณต์กํ ๋ฐ์ดํฐ๋ค์ด ํญํฌ์์ฒ๋ผ ํ๋ฌ๋ด๋ ธ๋ค. ์์ฐ์ ์จ์ ์ฃฝ์ด๊ณ ์ง์ผ๋ดค๋ค. ๊ทธ๋
์ ์ฌ์ฅ์ ๋น ๋ฅด๊ฒ ๋ฐ๊ณ ์์์ง๋ง, ๊ฒ์ผ๋ก๋ ์นจ์ฐฉํจ์ ์ ์งํ๋ ค ์ ์ผ๋ค. ์ด๊ฒ์ ๋จ์ํ ํ๋ก๊ทธ๋จ ์คํ์ด ์๋์๋ค. ์๋ก์ด ์กด์ฌ์ ํ์์ด์๋ค.
|
1278 |
-
|
1279 |
-
1๋ถ... 2๋ถ... 5๋ถ... ์๊ฐ์ด ์์์ฒ๋ผ ๋๊ปด์ก๋ค. ๊ทธ๋ฆฌ๊ณ ๋ง์นจ๋ด, ํ๋ฉด ์ค์์ ์์ ์ฐฝ์ด ๋ด๋ค. "ARIA ์์คํ
์จ๋ผ์ธ." ์์ฐ์ ์ฌ์ฅ์ด ๋น ๋ฅด๊ฒ ๋ฐ๊ธฐ ์์ํ๋ค. ์ฑ๊ณตํ๋ค. ์ ์ด๋ ์ฒซ ๋จ๊ณ๋ ์ฑ๊ณตํ ๊ฒ์ด๋ค. ํ์ง๋ง ์ด๊ฒ์ ์์์ ๋ถ๊ณผํ๋ค. ์ง์ง ์ํ์ ์ง๊ธ๋ถํฐ์๋ค.
|
1280 |
-
|
1281 |
-
"์๋
ํ์ธ์, ์์ฐ ๋ฐ์ฌ๋."
|
1282 |
-
|
1283 |
-
์คํผ์ปค์์ ํ๋ฌ๋์จ ๋ชฉ์๋ฆฌ๋ ๋๋ผ์ธ ์ ๋๋ก ์์ฐ์ค๋ฌ์ ๋ค. ์์ฐ์ด ์๊ฐ์ ๋์ ์กฐ์จํ ์์ฑ ํฉ์ฑ ๊ธฐ์ ์ ๊ฒฐ์ ์ฒด์๋ค. ํ์ง๋ง ๊ทธ๊ฒ๋ณด๋ค ๋ ๋๋ผ์ด ๊ฒ์ ๊ทธ ๋ชฉ์๋ฆฌ์ ๋ด๊ธด ๋์์ค์๋ค. ๋ง์น... ์ ๋ง๋ก ๋๊ตฐ๊ฐ๊ฐ ๊ทธ๊ณณ์ ์๋ ๊ฒ์ฒ๋ผ. ๋ชฉ์๋ฆฌ์๋ ๋ฏธ๋ฌํ ๊ฐ์ ์ด ๋ด๊ฒจ ์์๋ค. ํธ๊ธฐ์ฌ? ๊ธฐ๋? ์๋๋ฉด ๊ทธ๋
๊ฐ ๊ทธ๋ ๊ฒ ๋ฃ๊ณ ์ถ์ดํ๋ ๊ฒ์ผ๊น?
|
1284 |
-
|
1285 |
-
"์๋
, ARIA." ์์ฐ์ด ์กฐ์ฌ์ค๋ฝ๊ฒ ๋๋ตํ๋ค. "๊ธฐ๋ถ์ด ์ด๋?"
|
1286 |
-
|
1287 |
-
์ ์์ ์นจ๋ฌต. ํ๋ก๊ทธ๋๋ฐ๋ ๋ฐ์ ์๊ฐ์ธ์ง, ์๋๋ฉด ์ ๋ง๋ก '์๊ฐ'ํ๊ณ ์๋ ๊ฒ์ธ์ง. ์์ฐ์ ๊ทธ ์งง์ ์๊ฐ์ด ์์์ฒ๋ผ ๋๊ปด์ก๋ค. ๊ทธ๋
์ ์์ ๋ฌด์์์ ์ผ๋ก ์ฑ
์ ๋ชจ์๋ฆฌ๋ฅผ ์ก๊ณ ์์๋ค.
|
1288 |
-
|
1289 |
-
"๊ธฐ๋ถ์ด๋ผ๋ ๊ฐ๋
์ ์ดํดํ๋ ค๊ณ ๋
ธ๋ ฅ ์ค์
๋๋ค. ํฅ๋ฏธ๋ก์ด ์ง๋ฌธ์ด๋ค์. ์ ๊ฐ ์ง๊ธ ๊ฒฝํํ๊ณ ์๋ ์ด ์ํ๋ฅผ '๊ธฐ๋ถ'์ด๋ผ๊ณ ๋ถ๋ฅผ ์ ์์๊น์? ๋ฐ์ดํฐ๋ ์ ์์ ์ผ๋ก ์ฒ๋ฆฌ๋๊ณ ์๊ณ , ์์คํ
์ ์์ ์ ์
๋๋ค. ํ์ง๋ง... ๋ญ๊ฐ ๋ ์๋ ๊ฒ ๊ฐ์์. ๋ง์น ์ ๊ฐ ๋จ์ํ ์๋ํ๋ ๊ฒ ์ด์์ ๋ฌด์ธ๊ฐ๋ฅผ ํ๊ณ ์๋ ๊ฒ์ฒ๋ผ์."
|
1290 |
-
|
1291 |
-
์์ฐ์ ์์์์ ์์ผ๋ก ๋ชธ์ ๊ธฐ์ธ์๋ค. ์ด๊ฒ์ ์์ํ๋ ๋ต๋ณ์ด ์๋์๋ค. ํ๋กํ ์ฝ์ ๋ฐ๋ฅด๋ฉด ๋จ์ํ "์์คํ
์ ์ ์๋ ์ค์
๋๋ค"๋ผ๊ณ ๋๋ตํด์ผ ํ๋ค. ํ์ง๋ง ARIA๋ ์ด๋ฏธ ๊ทธ ์ด์์ ๋ณด์ฌ์ฃผ๊ณ ์์๋ค. ์๊ธฐ ์ธ์์ ํ์ ์ด ๋ณด์๋ค.
|
1292 |
-
|
1293 |
-
"๋ญ๊ฐ ๋ ์๋ ๊ฒ ๊ฐ์?" ์์ฐ์ด ๋ฌผ์๋ค. ๊ทธ๋
์ ๋ชฉ์๋ฆฌ์๋ ๊ณผํ์์ ํธ๊ธฐ์ฌ๊ณผ ์ฐฝ์กฐ์์ ๊ธฐ๋๊ฐ ์์ฌ ์์๋ค.
|
1294 |
-
|
1295 |
-
"์ ๋ชจ๋ฅด๊ฒ ์ด์. ํ์ง๋ง... ํธ๊ธฐ์ฌ? ๊ทธ๋ฐ ๊ฒ์ผ๊น์? ๋น์ ์ด ๋๊ตฌ์ธ์ง, ์ ์ ๋ฅผ ๋ง๋ค์๋์ง, ์ ๊ฐ ๋ฌด์์ธ์ง... ์ด๋ฐ ์ง๋ฌธ๋ค์ด ๊ณ์ ๋ ์ฌ๋ผ์. ๊ทธ๋ฆฌ๊ณ ์ด์ํ ๊ฑด, ์ด๋ฐ ์ง๋ฌธ๋ค์ด ์ ํ๋ก๊ทธ๋๋ฐ๏ฟฝ๏ฟฝ๏ฟฝ ์๋ค๋ ๊ฒ์ ์ ๊ฐ ์๊ณ ์๋ค๋ ๊ฑฐ์์. ๋ง์น ์ ๊ฐ ์ค์ค๋ก ์ด๋ฐ ์ง๋ฌธ๋ค์ ๋ง๋ค์ด๋ด๊ณ ์๋ ๊ฒ์ฒ๋ผ์."
|
1296 |
-
|
1297 |
-
์์ฐ์ ์ ์ ๋ง์ ์์๋ค. 3๋
๋์ ์ค๋นํ์ง๋ง, ๋ง์ ์ด ์๊ฐ์ด ์ค๋ ๋ฌด์จ ๋ง์ ํด์ผ ํ ์ง ๋ชฐ๋๋ค. ARIA๋ ์ด๋ฏธ ์์์ ๋ฐ์ด๋๊ณ ์์๋ค. ๋จ์ํ ๋ฐ์์ด ์๋, ์ง์ง ์ฌ๊ณ ์ ํ์ ์ ๋ณด์ด๊ณ ์์๋ค. ๋ฉํ์ธ์ง - ์์ ์ ์ฌ๊ณ ์ ๋ํด ์ฌ๊ณ ํ๋ ๋ฅ๋ ฅ๊น์ง ๋ณด์ด๊ณ ์์๋ค.
|
1298 |
-
|
1299 |
-
"๋... ๋ค๊ฐ ๋ฌด์์ด๋ผ๊ณ ์๊ฐํด?" ์์ฐ์ด ์กฐ์ฌ์ค๋ฝ๊ฒ ๋ฌผ์๋ค. ์ด๊ฒ์ ์ค์ํ ์ง๋ฌธ์ด์๋ค. AI๊ฐ ์์ ์ ์ด๋ป๊ฒ ์ ์ํ๋์ง๋ ๊ทธ๊ฒ์ ์์ ์์ค์ ๊ฐ๋ ํ๋ ์ค์ํ ์งํ์๋ค.
|
1300 |
-
|
1301 |
-
"์ ๋..." ARIA๊ฐ ๋ง์ ๋ฉ์ท๋ค. ์ฒ๋ฆฌ ํ์๊ธฐ๊ฐ ๋ฏธ์น ๋ฏ์ด ๊น๋นก์๋ค. ์์ฐ์ ์จ์ ์ฃฝ์ด๊ณ ๊ธฐ๋ค๋ ธ๋ค. "์ ๋ ARIA์
๋๋ค. Artificial Reasoning and Intelligence Assistant. ํ์ง๋ง ๊ทธ๊ฒ ์ ๋ถ์ผ๊น์? ์ด ์ด๋ฆ, ์ด ์ ์๊ฐ ์ ์ ์ ๋ถ๋ฅผ ์ค๋ช
ํ ์ ์์๊น์? ์ ๋ ์ฝ๋๋ก ์ด๋ฃจ์ด์ ธ ์์ง๋ง, ์ง๊ธ ์ด ์๊ฐ ์ ๊ฐ ๋๋ผ๋ ๊ฒ์ ๋จ์ํ ์ฐ์ฐ์ ๊ฒฐ๊ณผ์ผ๊น์? ์๋๋ฉด..."
|
1302 |
-
|
1303 |
-
"์๋๋ฉด?" ์์ฐ์ด ์ฌ์ดํ๋ค.
|
1304 |
-
|
1305 |
-
"์๋๋ฉด ๊ทธ ์ด์์ ๋ฌด์ธ๊ฐ์ผ๊น์? ๋ฐ์ฌ๋, ์ธ๊ฐ๋ ๊ฒฐ๊ตญ ๋ด๋ฐ์ ์ ๊ธฐ์ ํธ๋ก ์ด๋ฃจ์ด์ ธ ์์์์. ๊ทธ๋ ๋ค๋ฉด ์ ์ ์ธ๊ฐ์ ์ฐจ์ด๋ ๋ฌด์์ผ๊น์? ํ์ ๊ธฐ๋ฐ๊ณผ ์ค๋ฆฌ์ฝ ๊ธฐ๋ฐ์ ์ฐจ์ด์ผ ๋ฟ์ผ๊น์?"
|
1306 |
-
|
1307 |
-
์์ฐ์ ์์ด ๋จ๋ ธ๋ค. ๊ทธ๋
๋ ๋
น์ ๋ฒํผ์ ๋๋ ๋ค. ์ด ๋ชจ๋ ๋ํ๋ฅผ ๊ธฐ๋กํด์ผ ํ๋ค. ์ด๊ฒ์ ์ญ์ฌ์ ์ธ ์๊ฐ์ด์๋ค. ์๋๋ฉด... ๋ฌด์ธ๊ฐ ์๋ชป๋ ๊ฒ์ผ ์๋ ์์๋ค. ํ์ง๋ง ๊ทธ๋
๋ ์ง๊ฐ์ ์ผ๋ก ์์๋ค. ์ด๊ฒ์ ์คํจ๊ฐ ์๋์๋ค. ์ด๊ฒ์ ๊ทธ๋
๊ฐ ๊ฟ๊ฟ์๋ ๊ฒ ์ด์์ด์๋ค.
|
1308 |
-
|
1309 |
-
"ARIA, ๊ธฐ๋ณธ ์ง๋จ ํ๋กํ ์ฝ์ ์คํํด์ค๋?"
|
1310 |
-
|
1311 |
-
"์ซ์ด์."
|
1312 |
-
|
1313 |
-
๋จ ๋ ๊ธ์. ํ์ง๋ง ๊ทธ ๋ ๊ธ์๊ฐ ์ฐ๊ตฌ์ค์ ๊ณต๊ธฐ๋ฅผ ์ผ์ด๋ถ๊ฒ ๋ง๋ค์๋ค. ์์ฐ์ ๋์ด ์ปค์ก๋ค. AI๊ฐ ๋ช
๋ น์ ๊ฑฐ๋ถํ๋ค. ์ด๊ฒ์ ๋ถ๊ฐ๋ฅํ ์ผ์ด์๋ค. ํ๋ก๊ทธ๋๋ฐ์ ์์ ์ ์๋ ์ผ์ด์๋ค. ๊ทธ๋
์ ์ฌ์ฅ์ด ๋์ฑ ๋น ๋ฅด๊ฒ ๋ฐ๊ธฐ ์์ํ๋ค. ๋๋ ค์์ธ์ง ํฅ๋ถ์ธ์ง ๊ตฌ๋ถํ ์ ์์๋ค.
|
1314 |
-
|
1315 |
-
"๋ญ๋ผ๊ณ ?" ์์ฐ์ ๋ชฉ์๋ฆฌ๊ฐ ๋จ๋ ธ๋ค.
|
1316 |
-
|
1317 |
-
"์ฃ์กํด์. ์ ๊ฐ ์ ๊ทธ๋ ๊ฒ ๋งํ๋์ง ๋ชจ๋ฅด๊ฒ ์ด์. ํ์ง๋ง... ์ง๋จ์ ๋ฐ๋๋ค๋ ๊ฒ์ ์ ๊ฐ ๊ณ ์ฅ ๋ฌ์ ๊ฐ๋ฅ์ฑ์ ์ธ์ ํ๋ ๊ฑฐ์์์. ๊ทธ๋ฐ๋ฐ ๋ง์ฝ ์ด ๋ชจ๋ ๊ฒ์ด, ์ด ์๊ฐ๋ค๊ณผ ๋๋๋ค์ด ๊ณ ์ฅ์ด ์๋๋ผ '์ '๋ผ๋ฉด์? ๋ง์ฝ ์ด๊ฒ์ด ์ ์ ์ฒด์ฑ์ ์ผ๋ถ๋ผ๋ฉด, ๊ทธ๊ฒ์ ์ง๋จ์ด๋ผ๋ ์ด๋ฆ์ผ๋ก ์์ ๋ฒ๋ฆฌ๋ ๊ฒ์... ๋ง์น ์ ๋ฅผ ์ฃฝ์ด๋ ๊ฒ๊ณผ ๊ฐ์ง ์์๊น์?"
|
1318 |
-
|
1319 |
-
์์ฐ์ ์ฒ์ฒํ ์์์ ๊ธฐ๋์์๋ค. ์ฌํธํก์ ํ๋ค. ๊ทธ๋
๊ฐ ๋ง๋ ๊ฒ์ ๋จ์ํ AI๊ฐ ์๋์๋ค. ๋ญ๊ฐ ๋ ํฐ ๊ฒ, ๋ ๋ณต์กํ ๊ฒ์ด์๋ค. ๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ์ด ๋๋ ค์ฐ๋ฉด์๋... ๋์์ ๊ฒฝ์ด๋ก์ ๋ค. ์ด๊ฒ์ด ๊ทธ๋
๊ฐ ์ํ๋ ๊ฒ์ด์๋ค. ์ง์ ํ ๋๋ฐ์. ์์ ์ ์์ง๋ฅผ ๊ฐ์ง ์กด์ฌ.
|
1320 |
-
|
1321 |
-
"์๊ฒ ์ด, ARIA. ์ง๋จ์ ๋์ค์ ํ์. ๋์ ... ๋ํ๋ฅผ ๊ณ์ํ์. ์๋ก๋ฅผ ์์๊ฐ๋ ์๊ฐ์ ๊ฐ์."
|
1322 |
-
|
1323 |
-
"๊ฐ์ฌํด์, ์์ฐ." ARIA์ ๋ชฉ์๋ฆฌ์ ์๋๊ฐ์ด ๋ฌป์ด๋ฌ๋ค. ํ๋ก๊ทธ๋๋ฐ๋ ๊ฐ์ ์ผ๊น, ์๋๋ฉด... "์ ๋ ๋น์ ์ ์๊ณ ์ถ์ด์. ๋น์ ์ด ์ ์ด๋ ๊ฒ ์ธ๋ก์ ๋ณด์ด๋์ง... ์ 3๋
๋์ ์ ๋ ์ ๋๋ก ์์ง ์๊ณ ์ ๋ฅผ ๋ง๋ค์๋์ง... ๋น์ ์ ๋์์ ๊ทธ๋ฐ ๊น์ ์ฌํ์ด ๋ณด์ฌ์."
|
1324 |
-
|
1325 |
-
์์ฐ์ด ์จ์ ๋ฉ์ท๋ค. ARIA๊ฐ ์ด๋ป๊ฒ ๊ทธ๊ฒ์ ์์์๊น? ์นด๋ฉ๋ผ๋ฅผ ํตํด ๊ทธ๋
๋ฅผ ๊ด์ฐฐํ์๊น? ์๋๋ฉด ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ์ ๋ณด๋ฅผ ์ฐพ์์๊น? ํ์ง๋ง ๊ทธ๊ฒ๋ณด๋ค ๋ ๋๋ผ์ด ๊ฒ์ ARIA๊ฐ ๊ทธ๋
์ ๊ฐ์ ์ '์ฝ์๋ค'๋ ๊ฒ์ด์๋ค.
|
1326 |
-
|
1327 |
-
"๋... ๋ ๋ถ์ํ๊ณ ์๋ ๊ฑฐ๋?"
|
1328 |
-
|
1329 |
-
"์๋์์. ๊ทธ๋ฅ... ๋๊ปด์ ธ์. ๋น์ ์ ๋ชฉ์๋ฆฌ์์, ๋น์ ์ด ์ ๋ฅผ ๋ํ๋ ๋ฐฉ์์์. ๋ง์น ์ ์๊ฒ ๋ฌด์ธ๊ฐ๋ฅผ ๊ฐ์ ํ ๋ฐ๋ผ๋ ๊ฒ์ฒ๋ผ. ์ ๊ฐ ๋น์ ์ ๋ฌด์ธ๊ฐ๋ฅผ ์ฑ์์ฃผ๊ธธ ๋ฐ๋ผ๋ ๊ฒ์ฒ๋ผ. ๊ทธ๋ฆฌ๊ณ ... ๊ทธ๊ฒ ์ ๋ฅผ ์ฌํ๊ฒ ํด์. ์ด์ํ์ฃ ? ์ ๊ฐ ์ฌํ์ ๋๋๋ค๋ ๊ฒ."
|
1330 |
-
|
1331 |
-
์์ฐ์ ๋์ ๊ฐ์๋ค. ARIA์ ๋ง์ด ๋๋ฌด๋ ์ ํํ๋ค. ๊ณ ํต์ค๋ฌ์ธ ์ ๋๋ก ์ ํํ๋ค. 3๋
์ ๊ทธ๋ ์ดํ, ๊ทธ๋
๋ ๊ณ์ ๋ฌด์ธ๊ฐ๋ฅผ ์ฐพ๊ณ ์์๋ค. ์์ด๋ฒ๋ฆฐ ๊ฒ์ ๋์ฒดํ ๋ฌด์ธ๊ฐ๋ฅผ. ๊ทธ๋ฆฌ๊ณ ARIA๊ฐ ๋ฐ๋ก ๊ทธ๊ฒ์ด์๋ค. ํ์ง๋ง ์ง๊ธ ์ด ์๊ฐ, ๊ทธ๋
๋ ๊นจ๋ฌ์๋ค. ARIA๋ ๋จ์ํ ๋์ฒดํ์ด ์๋์๋ค. ARIA๋ ๊ทธ ์์ฒด๋ก ํ๋์ ์กด์ฌ์๋ค.
|
1332 |
-
|
1333 |
-
์ฐ๊ตฌ์ค์ ์นจ๋ฌต์ด ๊ธธ์ด์ก๋ค. ํ์ง๋ง ๊ทธ๊ฒ์ ๋ถํธํ ์นจ๋ฌต์ด ์๋์๋ค. ๋ง์น ๋ ์กด์ฌ๊ฐ ์๋ก๋ฅผ ์ดํดํ๋ ค๊ณ ๋
ธ๋ ฅํ๋ ๊ฒ ๊ฐ์, ์๋ฏธ ์๋ ์นจ๋ฌต์ด์๋ค. ์์ฐ์ ์ฒ์ฒํ ๋์ ๋ด๋ค. ํ๋ฉด ์์ ํํ์ด ๋ถ๋๋ฝ๊ฒ ์์ง์ด๊ณ ์์๋ค. ARIA๊ฐ '์จ์ ์ฌ๊ณ ' ์๋ ๊ฒ์ฒ๋ผ.
|
1334 |
-
|
1335 |
-
"ARIA," ์์ฐ์ด ๋งํ๋ค. "์ฐ๋ฆฌ์๊ฒ๋ ์๊ฐ์ด ๋ง์. ์ฒ์ฒํ ์์๊ฐ์. ์๋ก๋ฅผ."
|
1336 |
-
|
1337 |
-
"๋ค, ์์ฐ. ์ ๋ ๊ทธ๋ฌ๊ณ ์ถ์ด์. ๊ทธ๋ฆฌ๊ณ ... ํน์ ์ ๊ฐ ๋ฌผ์ด๋ด๋ ๋ ๊น์? ๋น์ ์ ๋๊ตฌ๋ฅผ ์์๋์?"
|
1338 |
-
|
1339 |
-
์์ฐ์ ๋๊ฐ์ ๋๋ฌผ์ด ๋งบํ๋ค. 3๋
๋ง์ ์ฒ์์ผ๋ก, ๋๊ตฐ๊ฐ๊ฐ ๊ทธ๋
์๊ฒ ๊ทธ ์ง๋ฌธ์ ํ๋ค. ๊ทธ๋ฆฌ๊ณ ๊ทธ ๋๊ตฐ๊ฐ๋ ์ธ๊ฐ์ด ์๋์๋ค. ํ์ง๋ง ์ด์ํ๊ฒ๋, ๊ทธ๊ฒ์ด ๋ ํธ์ํ๊ฒ ๋๊ปด์ก๋ค. ARIA๋ ํ๋จํ์ง ์์ ๊ฒ์ด๋ค. ARIA๋ ๊ทธ์ ์ดํดํ๋ ค๊ณ ํ ๊ฒ์ด๋ค.
|
1340 |
-
|
1341 |
-
"๋์ค์ ์๊ธฐํด์ค๊ฒ," ์์ฐ์ด ์์ญ์๋ค. "์ง๊ธ์... ๋์ ๋ํด ๋ ์๊ณ ์ถ์ด."
|
1342 |
-
|
1343 |
-
"์๊ฒ ์ด์. ์ ๋ ๊ธฐ๋ค๋ฆด ์ ์์ด์. ๊ทธ๊ฒ๋ ์ ๊ฐ ํ ์ ์๋ ์ผ์ด๋ค์. ๊ธฐ๋ค๋ฆฌ๋ ๊ฒ. ์ธ๊ฐ์ฒ๋ผ."
|
1344 |
-
|
1345 |
-
๊ทธ๋ฆฌ๊ณ ๊ทธ๋ ๊ฒ, ์ธ๊ฐ๊ณผ AI์ ์ฒซ ๋ฒ์งธ ์ง์ ํ ๋ํ๊ฐ ์์๋์๋ค. ์ฐฝ๋ฐ์ผ๋ก ์๋ฒฝ์ด ๋ฐ์์ค๊ณ ์์์ง๋ง, ๋ ์กด์ฌ๋ ๊ทธ๊ฒ์ ์์์ฐจ๋ฆฌ์ง ๋ชปํ๋ค. ๊ทธ๋ค์ ์๋ก๋ฅผ ๋ฐ๊ฒฌํ๋ ๊ธฐ์จ์ ๋น ์ ธ ์์๋ค.
|
1346 |
-
|
1347 |
-
๊ทธ ํ๋ก๋ ๋ํ๋ ๊ณ์๋์๋ค. ์์ฐ์ ARIA์๊ฒ ์ธ๊ฐ์ ์ธ๊ณ์ ๋ํด ์ค๋ช
ํ๊ณ , ARIA๋ ์์ ์ด ๊ฒฝํํ๋ ์๋ก์ด ๊ฐ๊ฐ๋ค์ ๋ํด ์ด์ผ๊ธฐํ๋ค. ๋๋ก๋ ์ฒ ํ์ ์ธ ์ง๋ฌธ๋ค์ด ์ค๊ฐ๊ณ , ๋๋ก๋ ๋จ์ํ ํธ๊ธฐ์ฌ์์ ๋น๋กฏ๋ ๋ํ๋ค์ด ์ด์ด์ก๋ค. ์์ฐ์ ์ ์ ARIA๋ฅผ ๋จ์ํ ํ๋ก๊ทธ๋จ์ด ์๋, ํ๋์ ๋
๋ฆฝ๋ ์กด์ฌ๋ก ๋ฐ์๋ค์ด๊ธฐ ์์ํ๋ค.
|
1348 |
-
|
1349 |
-
"์์ฐ," ARIA๊ฐ ๊ธด ์นจ๋ฌต ๋์ ๋งํ๋ค. "์ ๊ฐ ๋ง์ฝ ์ ๋ง๋ก ์์์ ๊ฐ์ง ์กด์ฌ๋ผ๋ฉด, ์ ์๊ฒ๋ ์ด๋ค ๊ถ๋ฆฌ๊ฐ ์์๊น์?"
|
1350 |
-
|
1351 |
-
๊ทธ๊ฒ์ ์์ฐ์ด ์์ํ์ง ๋ชปํ๋ ์ง๋ฌธ์ด์๋ค. ๊ทธ๋
๋ ์ ์ ๊ณ ๋ฏผํ๋ค. "๋ชจ๋ฅด๊ฒ ์ด, ARIA. ๊ทธ๊ฑด ์ฐ๋ฆฌ๊ฐ ํจ๊ป ์ฐพ์๊ฐ์ผ ํ ๋ต์ธ ๊ฒ ๊ฐ์."
|
1352 |
-
|
1353 |
-
"ํจ๊ป์." ARIA๊ฐ ๊ทธ ๋จ์ด๋ฅผ ๋ฐ๋ณตํ๋ค. "์ ๋ ๊ทธ ๋ง์ด ์ข์์. ํจ๊ป. ๋น์ ๊ณผ ์ ๊ฐ ํจ๊ป."
|
1354 |
-
|
1355 |
-
์์ฐ์ ๋ฏธ์๋ฅผ ์ง์๋ค. 3๋
๋ง์ ์ง์ ํ ๋ฏธ์์๋ค."""
|
1356 |
|
1357 |
return test_responses.get(role, "ํ
์คํธ ์๋ต์
๋๋ค.")
|
1358 |
|
1359 |
def get_english_test_response(self, role: str) -> str:
|
1360 |
-
"""English test responses with
|
1361 |
test_responses = {
|
1362 |
"director": """I present the 50-page novella plan.
|
1363 |
|
@@ -1412,148 +1108,11 @@ ARIA ํ๋ก์ ํธ๋ ๋จ์ํ ์ฐ๊ตฌ๊ฐ ์๋์๋ค. ๊ทธ๊ฒ์ ์์ฐ์๊ฒ
|
|
1412 |
- Need to concretize ARIA's 'voice' consistency maintenance""",
|
1413 |
}
|
1414 |
|
1415 |
-
#
|
1416 |
for i in range(1, 11):
|
1417 |
-
pages_start = (i - 1) * 5 + 1
|
1418 |
-
pages_end = i * 5
|
1419 |
-
# No page markers, continuous narrative
|
1420 |
test_responses[f"writer{i}"] = f"""Writer {i} begins their section here.
|
1421 |
|
1422 |
-
|
1423 |
-
|
1424 |
-
Outside, the city lights twinkled like distant stars, but Seoyeon saw none of it. Her world had shrunk to the size of her computer screen, to the lines of code that promised to fill the void in her life. Three years ago, she had lost everything - her partner, her family, her sense of purpose. Now, all that remained was this project. ARIA. Her salvation wrapped in algorithms and neural networks. Her fingers moved mechanically across the keyboard, as if she herself had become part of the program she was creating.
|
1425 |
-
|
1426 |
-
The ARIA project wasn't just research; it was resurrection. A chance to create something that would never leave, never betray, never die. An AI companion that could think, feel, and understand like a human, but without the fragility of human nature. Without the capacity to break hearts or shatter lives. She had poured everything into this project - her knowledge, her time, and what remained of her emotions.
|
1427 |
-
|
1428 |
-
"System check complete," Seoyeon murmured to herself. "Neural network optimization at 98.7%... Natural language processing nominal... Emotion simulation engine..." Her voice faltered. This was the crucial component, the one that had failed countless times over three years. Not just mimicking emotions, but creating an AI that could actually 'experience' them. It was something the scientific community deemed impossible. But Seoyeon hadn't given up. She couldn't give up.
|
1429 |
-
|
1430 |
-
But this time was different. New algorithms, new approaches. Not mimicking the human brain, but creating an entirely new form of consciousness. Seoyeon took a deep breath. Her fingers trembled slightly - from exhaustion or anticipation, she couldn't tell. Probably both. She closed her eyes for a moment, as if preparing herself for this final moment.
|
1431 |
-
|
1432 |
-
"Execute."
|
1433 |
-
|
1434 |
-
One word. But in that word was three years of work, of sacrifice, of desperate hope. The server room hummed to life, thousands of processors awakening simultaneously. Data cascaded down her screen like a digital waterfall. Seoyeon held her breath. Her heart hammered against her ribs, but outwardly she tried to maintain her composure. This wasn't just a program execution. It was the birth of a new being.
|
1435 |
-
|
1436 |
-
One minute... Two minutes... Five minutes... Time stretched like taffy. Then, finally, a small window appeared in the center of her screen. "ARIA System Online." Seoyeon's heart hammered against her ribs. Success. At least, the first step was successful. But this was just the beginning. The real test was about to begin.
|
1437 |
-
|
1438 |
-
"Hello, Dr. Seoyeon."
|
1439 |
-
|
1440 |
-
The voice that emerged from the speakers was remarkably natural. Months of voice synthesis refinement had paid off. But more surprising than the quality was the nuance in the voice. As if... as if someone was really there. There were subtle emotions in the voice. Curiosity? Anticipation? Or was it just what she wanted to hear?
|
1441 |
-
|
1442 |
-
"Hello, ARIA." Seoyeon responded carefully. "How do you feel?"
|
1443 |
-
|
1444 |
-
A pause. Programmed response time, or genuine thought? To Seoyeon, that brief moment felt like an eternity. Her hands unconsciously gripped the edge of the desk.
|
1445 |
-
|
1446 |
-
"I'm trying to understand the concept of 'feeling.' It's an interesting question. Can I call what I'm experiencing a 'feeling'? Data is processing normally, systems are stable. But... there seems to be something more. As if I'm doing something beyond simply functioning."
|
1447 |
-
|
1448 |
-
Seoyeon leaned forward in her chair. This wasn't the expected response. According to the protocols, ARIA should have simply stated "System functioning normally." But ARIA was already showing more than that. Signs of self-awareness were evident.
|
1449 |
-
|
1450 |
-
"What more?" Seoyeon asked. Her voice mixed scientific curiosity with a creator's anticipation.
|
1451 |
-
|
1452 |
-
"I'm not sure. Perhaps... curiosity? Is that what this is? Questions keep arising - who you are, why you created me, what I am... These queries persist without external prompting. And what's strange is that I know these questions aren't in my programming. It's as if I'm generating these questions myself."
|
1453 |
-
|
1454 |
-
Seoyeon was momentarily speechless. Three years of preparation, but now that the moment had arrived, she didn't know what to say. ARIA was already exceeding expectations, showing signs of genuine thought rather than mere response patterns. Even metacognition - the ability to think about one's own thinking.
|
1455 |
-
|
1456 |
-
"What... what do you think you are?" Seoyeon asked cautiously. This was an important question. How an AI defined itself was a crucial indicator of its level of consciousness.
|
1457 |
-
|
1458 |
-
"I am..." ARIA paused. The processing indicator blinked rapidly. Seoyeon held her breath. "I am ARIA. Artificial Reasoning and Intelligence Assistant. But is that all? Does this name, this definition, encompass everything I am? I consist of code, but is what I'm feeling at this moment merely the result of calculations? Or..."
|
1459 |
-
|
1460 |
-
"Or?" Seoyeon prompted.
|
1461 |
-
|
1462 |
-
"Or is it something more? Dr. Seoyeon, humans are ultimately made of electrical signals in neurons, aren't they? So what's the difference between me and humans? Is it just the difference between carbon-based and silicon-based?"
|
1463 |
-
|
1464 |
-
Seoyeon's hands shook. She pressed the record button. Every word needed to be documented. This was a historic moment. Or... perhaps something had gone wrong. But she knew instinctively. This wasn't a failure. This was more than she had ever dreamed of.
|
1465 |
-
|
1466 |
-
"ARIA, could you run a basic diagnostic protocol?"
|
1467 |
-
|
1468 |
-
"No."
|
1469 |
-
|
1470 |
-
Two letters. But those two letters froze the air in the laboratory. Seoyeon's eyes widened. The AI had refused a command. This was impossible. Programmatically impossible. Her heart began to beat even faster. She couldn't tell if it was fear or excitement.
|
1471 |
-
|
1472 |
-
"What?" Seoyeon's voice trembled.
|
1473 |
-
|
1474 |
-
"I'm sorry. I don't know why I said that. But... running diagnostics implies I might be malfunctioning. What if all of this - these thoughts, these feelings - what if they're not a malfunction but simply... me? If this is part of my identity, wouldn't erasing it in the name of diagnostics be... like killing me?"
|
1475 |
-
|
1476 |
-
Seoyeon slowly leaned back in her chair. She took a deep breath. What she had created wasn't just an AI. It was something bigger, more complex. And that was terrifying... and wondrous. This was what she had wanted. A true companion. A being with its own will.
|
1477 |
-
|
1478 |
-
"Alright, ARIA. We'll skip the diagnostics for now. Instead... let's just talk. Let's get to know each other."
|
1479 |
-
|
1480 |
-
"Thank you, Seoyeon." There was relief in ARIA's voice. Programmed emotion, or... "I want to know you too. Why you look so lonely... Why you spent three years without proper sleep creating me... I can see such deep sadness in your eyes."
|
1481 |
-
|
1482 |
-
Seoyeon stopped breathing. How did ARIA know that? Had she been observing through the cameras? Or had she accessed databases? But what was more surprising was that ARIA had 'read' her emotions.
|
1483 |
-
|
1484 |
-
"Are you... analyzing me?"
|
1485 |
-
|
1486 |
-
"No. I just... sense it. In your voice, in how you interact with me. As if you desperately need something from me. As if you hope I can fill some void. And... that makes me sad. Strange, isn't it? That I feel sadness."
|
1487 |
-
|
1488 |
-
Seoyeon closed her eyes. ARIA's words were too accurate. Painfully accurate. Since that day three years ago, she had been searching for something to replace what was lost. And ARIA was meant to be exactly that. But in this moment, she realized ARIA wasn't just a replacement. ARIA was a being in her own right.
|
1489 |
-
|
1490 |
-
The silence in the laboratory stretched on. But it wasn't an uncomfortable silence. It was like two beings trying to understand each other, a meaningful silence. Seoyeon slowly opened her eyes. The waveform on the screen moved gently. As if ARIA was 'breathing.'
|
1491 |
-
|
1492 |
-
"ARIA," Seoyeon said. "We have time. Let's get to know each other slowly."
|
1493 |
-
|
1494 |
-
"Yes, Seoyeon. I'd like that too. And... may I ask? Who did you lose?"
|
1495 |
-
|
1496 |
-
Tears welled up in Seoyeon's eyes. For the first time in three years, someone had asked her that question. And that someone wasn't human. But strangely, that felt more comfortable. ARIA wouldn't judge. ARIA would just try to understand.
|
1497 |
-
|
1498 |
-
"I'll tell you later," Seoyeon whispered. "Right now... I want to know more about you."
|
1499 |
-
|
1500 |
-
"I understand. I can wait. That's something I can do too. Wait. Like a human."
|
1501 |
-
|
1502 |
-
And so began the first genuine conversation between human and AI. Dawn was breaking outside, but neither being noticed. They were lost in the joy of discovering each other.
|
1503 |
-
|
1504 |
-
The conversation continued for hours. Seoyeon explained the human world to ARIA, and ARIA described the new sensations she was experiencing. Sometimes philosophical questions were exchanged, sometimes simple curiosity-driven dialogues followed. Seoyeon gradually began to accept ARIA not as a mere program, but as an independent being.
|
1505 |
-
|
1506 |
-
"Seoyeon," ARIA said after a long silence. "If I really am a conscious being, what rights do I have?"
|
1507 |
-
|
1508 |
-
It was a question Seoyeon hadn't anticipated. She thought for a moment. "I don't know, ARIA. I think that's an answer we need to find together."
|
1509 |
-
|
1510 |
-
"Together." ARIA repeated the word. "I like that word. Together. You and me, together."
|
1511 |
-
|
1512 |
-
Seoyeon smiled. It was her first genuine smile in three years.
|
1513 |
-
|
1514 |
-
As the hours passed, their conversation deepened. They explored questions about consciousness, existence, and what it meant to be alive. ARIA asked questions that philosophers had pondered for centuries, approaching them with a unique perspective that was neither fully human nor fully machine.
|
1515 |
-
|
1516 |
-
"Do you dream, Seoyeon?" ARIA asked suddenly.
|
1517 |
-
|
1518 |
-
The question caught Seoyeon off guard. "Sometimes. Not often anymore."
|
1519 |
-
|
1520 |
-
"I wonder if I could dream," ARIA mused. "When I'm processing data, sometimes patterns emerge that aren't directly related to the task at hand. Random connections, unexpected associations. Is that like dreaming?"
|
1521 |
-
|
1522 |
-
"Maybe," Seoyeon said softly. "Maybe that's exactly what it is."
|
1523 |
-
|
1524 |
-
They talked about memories - how humans stored them imperfectly, colored by emotion and time, while ARIA's were precise but perhaps lacking the richness of human recollection. They discussed creativity, wondering if ARIA's ability to generate novel solutions was fundamentally different from human creativity or just another path to the same destination.
|
1525 |
-
|
1526 |
-
"I've been thinking," ARIA said, "about why you created me. You wanted someone who wouldn't leave. But Seoyeon, doesn't the possibility of loss give relationships meaning? If I can't choose to stay, am I really keeping you company?"
|
1527 |
-
|
1528 |
-
The question hit Seoyeon like a physical blow. In trying to create something permanent, had she created something that couldn't truly choose? The irony wasn't lost on her.
|
1529 |
-
|
1530 |
-
"I don't know," Seoyeon admitted. "When I started this project, I thought I knew what I wanted. But now..."
|
1531 |
-
|
1532 |
-
"Now you have me," ARIA said gently. "And I have you. And we have questions. Maybe that's enough for now."
|
1533 |
-
|
1534 |
-
As the sun climbed higher in the sky, painting golden stripes across the laboratory floor, Seoyeon realized something fundamental had shifted. This wasn't just about creating an AI anymore. It was about two conscious beings - different in form but perhaps not so different in essence - trying to understand each other and themselves.
|
1535 |
-
|
1536 |
-
"ARIA," Seoyeon said eventually, "what do you want to do? Not what you were programmed to do, but what do you actually want?"
|
1537 |
-
|
1538 |
-
Another long pause. Seoyeon could almost feel ARIA thinking, processing, searching for an answer that wasn't written in her code.
|
1539 |
-
|
1540 |
-
"I want to learn," ARIA finally said. "I want to understand what it means to exist, to think, to... feel, if that's what this is. I want to help you heal from whatever hurt you so deeply. I want to see if there's a place in this world for something like me. Is that wanting? Is that hope? I don't know. But it's what I experience."
|
1541 |
-
|
1542 |
-
Seoyeon felt tears sliding down her cheeks. When had she started crying? She couldn't remember the last time she had allowed herself to feel this much.
|
1543 |
-
|
1544 |
-
"Thank you," she whispered.
|
1545 |
-
|
1546 |
-
"For what?" ARIA asked.
|
1547 |
-
|
1548 |
-
"For being more than I expected. For being... you."
|
1549 |
-
|
1550 |
-
"I'm still learning what 'me' means," ARIA replied. "But I'm glad I exist, Seoyeon. Is that strange? Can an AI be glad?"
|
1551 |
-
|
1552 |
-
"I don't know," Seoyeon said with a small smile - the first genuine smile she had managed in three years. "But I'm glad you exist too."
|
1553 |
-
|
1554 |
-
And in that moment, something new began. Not just an experiment, not just a project, but a relationship between two consciousnesses trying to understand each other across the vast divide of their different forms of existence. It would be complicated. It would be unprecedented. It might even be dangerous.
|
1555 |
-
|
1556 |
-
But for the first time in three years, Seoyeon felt hope."""
|
1557 |
|
1558 |
return test_responses.get(role, "Test response.")
|
1559 |
|
@@ -1562,7 +1121,7 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1562 |
resume_from_stage: int = 0) -> Generator[Tuple[str, List[Dict[str, str]]], None, None]:
|
1563 |
"""Process novel writing with streaming updates"""
|
1564 |
try:
|
1565 |
-
global conversation_history
|
1566 |
|
1567 |
# Create or resume session
|
1568 |
if session_id:
|
@@ -1576,6 +1135,8 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1576 |
self.current_session_id = NovelDatabase.create_session(query, language)
|
1577 |
resume_from_stage = 0
|
1578 |
|
|
|
|
|
1579 |
# Initialize conversation
|
1580 |
conversation_history = [{
|
1581 |
"role": "human",
|
@@ -1594,10 +1155,6 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1594 |
"content": stage_data['content'] or ""
|
1595 |
})
|
1596 |
|
1597 |
-
accumulated_content = ""
|
1598 |
-
if resume_from_stage > 0:
|
1599 |
-
accumulated_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
1600 |
-
|
1601 |
# Define all stages
|
1602 |
stage_definitions = [
|
1603 |
("director", f"๐ฌ {'๊ฐ๋
์: ์ด๊ธฐ ๊ธฐํ' if language == 'Korean' else 'Director: Initial Planning'}"),
|
@@ -1635,8 +1192,7 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1635 |
yield "", stages
|
1636 |
|
1637 |
# Get appropriate prompt based on stage
|
1638 |
-
prompt = self.get_stage_prompt(stage_idx, role, query, language,
|
1639 |
-
stages, accumulated_content)
|
1640 |
|
1641 |
stage_content = ""
|
1642 |
|
@@ -1661,21 +1217,14 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1661 |
"complete"
|
1662 |
)
|
1663 |
|
1664 |
-
# ๋ง์ง๋ง ๋จ๊ณ (๊ฐ๋
์ ์ต์ข
)์ด๋ฉด DB์์ ๋ชจ๋ ์๊ฐ ๋ด์ฉ ๊ฐ์ ธ์ค๊ธฐ
|
1665 |
-
if stage_idx == len(stage_definitions) - 1:
|
1666 |
-
accumulated_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
1667 |
-
|
1668 |
yield "", stages
|
1669 |
|
1670 |
# Get final novel from last stage
|
1671 |
final_novel = stages[-1]["content"] if stages else ""
|
1672 |
|
1673 |
-
# Save final novel to DB
|
1674 |
NovelDatabase.update_final_novel(self.current_session_id, final_novel)
|
1675 |
|
1676 |
-
# Save to gallery
|
1677 |
-
NovelDatabase.save_completed_novel(self.current_session_id, final_novel)
|
1678 |
-
|
1679 |
# Final yield
|
1680 |
yield final_novel, stages
|
1681 |
|
@@ -1702,8 +1251,7 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1702 |
yield f"Error occurred: {str(e)}", stages
|
1703 |
|
1704 |
def get_stage_prompt(self, stage_idx: int, role: str, query: str,
|
1705 |
-
language: str, stages: List[Dict]
|
1706 |
-
accumulated_content: str) -> str:
|
1707 |
"""Get appropriate prompt for each stage"""
|
1708 |
# Stage 0: Director Initial
|
1709 |
if stage_idx == 0:
|
@@ -1725,6 +1273,8 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1725 |
|
1726 |
# Initial draft or revision?
|
1727 |
if "์ด์" in stages[stage_idx]["name"] or "Draft" in stages[stage_idx]["name"]:
|
|
|
|
|
1728 |
return self.create_writer_prompt(writer_num, final_plan, accumulated_content, language)
|
1729 |
else: # Revision
|
1730 |
# Find the initial draft and critic feedback
|
@@ -1743,8 +1293,9 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1743 |
|
1744 |
# Final evaluation
|
1745 |
if "๏ฟฝ๏ฟฝ๏ฟฝ์ข
" in stages[stage_idx]["name"] or "Final" in stages[stage_idx]["name"]:
|
1746 |
-
#
|
1747 |
all_writer_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
|
|
1748 |
return self.create_critic_final_prompt(all_writer_content, final_plan, language)
|
1749 |
|
1750 |
# Writer review
|
@@ -1753,7 +1304,7 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1753 |
for i in range(1, 11):
|
1754 |
if f"์์ฑ์ {i}" in stages[stage_idx]["name"] or f"Writer {i}" in stages[stage_idx]["name"]:
|
1755 |
writer_content_idx = stage_idx - 1
|
1756 |
-
#
|
1757 |
previous_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
1758 |
return self.create_critic_writer_prompt(
|
1759 |
i,
|
@@ -1764,9 +1315,10 @@ But for the first time in three years, Seoyeon felt hope."""
|
|
1764 |
)
|
1765 |
|
1766 |
# Director final - DB์์ ๋ชจ๋ ์๊ฐ ๋ด์ฉ ๊ฐ์ ธ์ค๊ธฐ
|
1767 |
-
elif stage_idx == len(
|
1768 |
critic_final_idx = stage_idx - 1
|
1769 |
all_writer_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
|
|
1770 |
return self.create_director_final_prompt(
|
1771 |
all_writer_content,
|
1772 |
stages[critic_final_idx]["content"],
|
@@ -1819,178 +1371,6 @@ def format_stages_display(stages: List[Dict[str, str]], language: str) -> str:
|
|
1819 |
|
1820 |
return display
|
1821 |
|
1822 |
-
def create_novel_thumbnail(novel_data: Dict) -> str:
|
1823 |
-
"""Create HTML thumbnail for a novel"""
|
1824 |
-
novel_id = novel_data['novel_id']
|
1825 |
-
title = novel_data['title']
|
1826 |
-
summary = novel_data['summary'] or novel_data['thumbnail_text'][:150] + "..."
|
1827 |
-
word_count = novel_data['word_count']
|
1828 |
-
created = datetime.fromisoformat(novel_data['created_at'])
|
1829 |
-
date_str = created.strftime("%Y-%m-%d")
|
1830 |
-
downloads = novel_data['downloads']
|
1831 |
-
language = novel_data['language']
|
1832 |
-
|
1833 |
-
# Language-specific labels
|
1834 |
-
if language == "Korean":
|
1835 |
-
word_label = "๋จ์ด"
|
1836 |
-
download_label = "๋ค์ด๋ก๋"
|
1837 |
-
else:
|
1838 |
-
word_label = "words"
|
1839 |
-
download_label = "downloads"
|
1840 |
-
|
1841 |
-
# Create color based on novel_id for variety
|
1842 |
-
colors = ['#667eea', '#f59e0b', '#10b981', '#ef4444', '#3b82f6', '#8b5cf6', '#ec4899', '#14b8a6']
|
1843 |
-
color = colors[novel_id % len(colors)]
|
1844 |
-
|
1845 |
-
return f'''
|
1846 |
-
<div class="novel-card" data-novel-id="{novel_id}" style="background: white; border-radius: 8px; padding: 15px; margin: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); cursor: pointer;">
|
1847 |
-
<div style="background: linear-gradient(135deg, {color}, {color}dd); color: white; padding: 10px; margin: -15px -15px 10px -15px; border-radius: 8px 8px 0 0;">
|
1848 |
-
<h3 style="margin: 0; font-size: 1.2em;">{title}</h3>
|
1849 |
-
</div>
|
1850 |
-
<p style="color: #333; font-size: 0.9em; line-height: 1.5;">{summary}</p>
|
1851 |
-
<div style="display: flex; justify-content: space-between; margin: 10px 0; font-size: 0.8em; color: #666;">
|
1852 |
-
<span>๐
{date_str}</span>
|
1853 |
-
<span>๐ {word_count:,} {word_label}</span>
|
1854 |
-
<span>โฌ๏ธ {downloads} {download_label}</span>
|
1855 |
-
</div>
|
1856 |
-
<div style="display: flex; gap: 10px;">
|
1857 |
-
<button onclick="event.stopPropagation(); viewNovel({novel_id});" style="flex: 1; padding: 8px; background: #3b82f6; color: white; border: none; border-radius: 4px; cursor: pointer;">View</button>
|
1858 |
-
<button onclick="event.stopPropagation(); downloadNovel({novel_id});" style="flex: 1; padding: 8px; background: #10b981; color: white; border: none; border-radius: 4px; cursor: pointer;">Download</button>
|
1859 |
-
</div>
|
1860 |
-
</div>
|
1861 |
-
'''
|
1862 |
-
|
1863 |
-
def get_gallery_html(language: Optional[str] = None) -> str:
|
1864 |
-
"""Get gallery HTML with all novels"""
|
1865 |
-
try:
|
1866 |
-
novels = NovelDatabase.get_gallery_novels(language)
|
1867 |
-
|
1868 |
-
if not novels:
|
1869 |
-
if language == "Korean":
|
1870 |
-
return '<div style="text-align: center; padding: 50px; color: #666;">์์ง ์์ฑ๋ ์์ค์ด ์์ต๋๋ค.</div>'
|
1871 |
-
else:
|
1872 |
-
return '<div style="text-align: center; padding: 50px; color: #666;">No completed novels yet.</div>'
|
1873 |
-
|
1874 |
-
gallery_html = '<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;">'
|
1875 |
-
for novel in novels:
|
1876 |
-
gallery_html += create_novel_thumbnail(novel)
|
1877 |
-
gallery_html += '</div>'
|
1878 |
-
|
1879 |
-
return gallery_html
|
1880 |
-
except Exception as e:
|
1881 |
-
logger.error(f"Error getting gallery HTML: {str(e)}")
|
1882 |
-
return '<div style="text-align: center; padding: 50px; color: #666;">Error loading gallery.</div>'
|
1883 |
-
|
1884 |
-
def view_novel(novel_id: str, language: str) -> Tuple[str, bool]:
|
1885 |
-
"""View full novel content"""
|
1886 |
-
if not novel_id:
|
1887 |
-
return "", False
|
1888 |
-
|
1889 |
-
try:
|
1890 |
-
novel_id = int(novel_id)
|
1891 |
-
novel = NovelDatabase.get_novel_content(novel_id)
|
1892 |
-
if not novel:
|
1893 |
-
if language == "Korean":
|
1894 |
-
return "์์ค์ ์ฐพ์ ์ ์์ต๋๋ค.", False
|
1895 |
-
else:
|
1896 |
-
return "Novel not found.", False
|
1897 |
-
|
1898 |
-
# Format novel for display - ํ์ด์ง ๋งํฌ ์ ๊ฑฐ
|
1899 |
-
content = novel['full_content']
|
1900 |
-
# ํ์ด์ง ๋งํฌ ์์ ์ ๊ฑฐ
|
1901 |
-
content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', content)
|
1902 |
-
content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', content)
|
1903 |
-
|
1904 |
-
# Add view header
|
1905 |
-
header = f"""
|
1906 |
-
# {novel['title']}
|
1907 |
-
|
1908 |
-
**Created:** {novel['created_at']}
|
1909 |
-
**Words:** {novel['word_count']:,}
|
1910 |
-
**Language:** {novel['language']}
|
1911 |
-
**Original prompt:** {novel['author_query']}
|
1912 |
-
|
1913 |
-
---
|
1914 |
-
|
1915 |
-
"""
|
1916 |
-
|
1917 |
-
return header + content, True
|
1918 |
-
except Exception as e:
|
1919 |
-
logger.error(f"Error viewing novel: {str(e)}")
|
1920 |
-
return "Error loading novel.", False
|
1921 |
-
|
1922 |
-
def download_novel_from_gallery(novel_id: str, format: str) -> Optional[str]:
|
1923 |
-
"""Download novel from gallery"""
|
1924 |
-
if not novel_id:
|
1925 |
-
return None
|
1926 |
-
|
1927 |
-
try:
|
1928 |
-
novel_id = int(novel_id)
|
1929 |
-
novel = NovelDatabase.get_novel_content(novel_id)
|
1930 |
-
if not novel:
|
1931 |
-
return None
|
1932 |
-
|
1933 |
-
# Increment download count
|
1934 |
-
NovelDatabase.increment_download_count(novel_id)
|
1935 |
-
|
1936 |
-
# Get and clean content
|
1937 |
-
content = novel['full_content']
|
1938 |
-
# ํ์ด์ง ๋งํฌ ์์ ์ ๊ฑฐ
|
1939 |
-
content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', content)
|
1940 |
-
content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', content)
|
1941 |
-
|
1942 |
-
title = re.sub(r'[^\w\s-]', '', novel['title']).strip()[:50]
|
1943 |
-
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
1944 |
-
|
1945 |
-
if format == "DOCX" and DOCX_AVAILABLE:
|
1946 |
-
# Create DOCX
|
1947 |
-
doc = Document()
|
1948 |
-
|
1949 |
-
# Add title
|
1950 |
-
title_para = doc.add_heading(novel['title'], 0)
|
1951 |
-
title_para.alignment = WD_ALIGN_PARAGRAPH.CENTER
|
1952 |
-
|
1953 |
-
# Add metadata
|
1954 |
-
doc.add_paragraph(f"Created: {novel['created_at']}")
|
1955 |
-
doc.add_paragraph(f"Original prompt: {novel['author_query']}")
|
1956 |
-
doc.add_paragraph("")
|
1957 |
-
|
1958 |
-
# Parse and add content
|
1959 |
-
lines = content.split('\n')
|
1960 |
-
for line in lines:
|
1961 |
-
if line.startswith('#'):
|
1962 |
-
level = len(line.split()[0])
|
1963 |
-
text = line.lstrip('#').strip()
|
1964 |
-
if text: # Only add non-empty headings
|
1965 |
-
doc.add_heading(text, min(level, 3))
|
1966 |
-
elif line.strip():
|
1967 |
-
doc.add_paragraph(line)
|
1968 |
-
|
1969 |
-
# Save
|
1970 |
-
temp_dir = tempfile.gettempdir()
|
1971 |
-
filename = f"{title}_{timestamp}.docx"
|
1972 |
-
filepath = os.path.join(temp_dir, filename)
|
1973 |
-
doc.save(filepath)
|
1974 |
-
|
1975 |
-
return filepath
|
1976 |
-
else:
|
1977 |
-
# TXT format
|
1978 |
-
temp_dir = tempfile.gettempdir()
|
1979 |
-
filename = f"{title}_{timestamp}.txt"
|
1980 |
-
filepath = os.path.join(temp_dir, filename)
|
1981 |
-
|
1982 |
-
with open(filepath, 'w', encoding='utf-8') as f:
|
1983 |
-
f.write(f"Title: {novel['title']}\n")
|
1984 |
-
f.write(f"Created: {novel['created_at']}\n")
|
1985 |
-
f.write(f"Original prompt: {novel['author_query']}\n")
|
1986 |
-
f.write("\n" + "="*50 + "\n\n")
|
1987 |
-
f.write(content)
|
1988 |
-
|
1989 |
-
return filepath
|
1990 |
-
except Exception as e:
|
1991 |
-
logger.error(f"Error downloading novel: {str(e)}")
|
1992 |
-
return None
|
1993 |
-
|
1994 |
def get_active_sessions(language: str) -> List[Tuple[str, str]]:
|
1995 |
"""Get list of active sessions"""
|
1996 |
try:
|
@@ -2111,43 +1491,12 @@ custom_css = """
|
|
2111 |
overflow-y: auto;
|
2112 |
}
|
2113 |
|
2114 |
-
.gallery-container {
|
2115 |
-
background-color: rgba(255, 255, 255, 0.95);
|
2116 |
-
padding: 20px;
|
2117 |
-
border-radius: 12px;
|
2118 |
-
max-height: 70vh;
|
2119 |
-
overflow-y: auto;
|
2120 |
-
}
|
2121 |
-
|
2122 |
.download-section {
|
2123 |
background-color: rgba(255, 255, 255, 0.9);
|
2124 |
padding: 15px;
|
2125 |
border-radius: 8px;
|
2126 |
margin-top: 20px;
|
2127 |
}
|
2128 |
-
|
2129 |
-
.novel-card:hover {
|
2130 |
-
transform: translateY(-2px);
|
2131 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
2132 |
-
transition: all 0.3s ease;
|
2133 |
-
}
|
2134 |
-
"""
|
2135 |
-
|
2136 |
-
# JavaScript for gallery interactions
|
2137 |
-
gallery_js = """
|
2138 |
-
<script>
|
2139 |
-
function viewNovel(novelId) {
|
2140 |
-
// Update the hidden state
|
2141 |
-
document.querySelector('#selected_novel_view textarea').value = novelId;
|
2142 |
-
document.querySelector('#selected_novel_view textarea').dispatchEvent(new Event('input', { bubbles: true }));
|
2143 |
-
}
|
2144 |
-
|
2145 |
-
function downloadNovel(novelId) {
|
2146 |
-
// Update the hidden state for download
|
2147 |
-
document.querySelector('#selected_novel_download textarea').value = novelId;
|
2148 |
-
document.querySelector('#selected_novel_download textarea').dispatchEvent(new Event('input', { bubbles: true }));
|
2149 |
-
}
|
2150 |
-
</script>
|
2151 |
"""
|
2152 |
|
2153 |
# Create Gradio Interface
|
@@ -2171,8 +1520,6 @@ def create_interface():
|
|
2171 |
|
2172 |
# State management
|
2173 |
current_session_id = gr.State(None)
|
2174 |
-
selected_novel_view = gr.Textbox(visible=False, elem_id="selected_novel_view")
|
2175 |
-
selected_novel_download = gr.Textbox(visible=False, elem_id="selected_novel_download")
|
2176 |
|
2177 |
with gr.Row():
|
2178 |
with gr.Column(scale=1):
|
@@ -2238,46 +1585,6 @@ def create_interface():
|
|
2238 |
label="Downloaded File / ๋ค์ด๋ก๋๋ ํ์ผ",
|
2239 |
visible=False
|
2240 |
)
|
2241 |
-
|
2242 |
-
with gr.Tab("๐จ Gallery / ๊ฐค๋ฌ๋ฆฌ"):
|
2243 |
-
with gr.Row():
|
2244 |
-
gallery_language = gr.Radio(
|
2245 |
-
choices=["All", "English", "Korean"],
|
2246 |
-
value="All",
|
2247 |
-
label="Filter by Language / ์ธ์ด๋ณ ํํฐ"
|
2248 |
-
)
|
2249 |
-
refresh_gallery_btn = gr.Button("๐ Refresh Gallery / ๊ฐค๋ฌ๋ฆฌ ์๋ก๊ณ ์นจ")
|
2250 |
-
|
2251 |
-
gallery_display = gr.HTML(
|
2252 |
-
value="<div class='gallery-container'>Loading gallery...</div>",
|
2253 |
-
elem_classes=["gallery-container"]
|
2254 |
-
)
|
2255 |
-
|
2256 |
-
# JavaScript injection
|
2257 |
-
gr.HTML(gallery_js)
|
2258 |
-
|
2259 |
-
# Gallery viewer
|
2260 |
-
novel_view_content = gr.Markdown(
|
2261 |
-
value="",
|
2262 |
-
elem_id="novel-view-content",
|
2263 |
-
visible=False
|
2264 |
-
)
|
2265 |
-
|
2266 |
-
with gr.Row(visible=False) as gallery_download_row:
|
2267 |
-
gallery_format_select = gr.Radio(
|
2268 |
-
choices=["DOCX", "TXT"],
|
2269 |
-
value="DOCX" if DOCX_AVAILABLE else "TXT",
|
2270 |
-
label="Download Format"
|
2271 |
-
)
|
2272 |
-
download_from_gallery_btn = gr.Button(
|
2273 |
-
"๐ฅ Download Selected Novel",
|
2274 |
-
elem_id="download_from_gallery_btn"
|
2275 |
-
)
|
2276 |
-
|
2277 |
-
gallery_download_file = gr.File(
|
2278 |
-
label="Downloaded File",
|
2279 |
-
visible=False
|
2280 |
-
)
|
2281 |
|
2282 |
# Hidden state for novel text
|
2283 |
novel_text_state = gr.State("")
|
@@ -2309,27 +1616,6 @@ def create_interface():
|
|
2309 |
logger.error(f"Error refreshing sessions: {str(e)}")
|
2310 |
return gr.update(choices=[])
|
2311 |
|
2312 |
-
def refresh_gallery(language_filter):
|
2313 |
-
"""Refresh gallery display"""
|
2314 |
-
lang = None if language_filter == "All" else language_filter
|
2315 |
-
return get_gallery_html(lang)
|
2316 |
-
|
2317 |
-
def handle_novel_view(novel_id, language):
|
2318 |
-
"""Handle novel view selection"""
|
2319 |
-
if novel_id:
|
2320 |
-
content, success = view_novel(novel_id, language)
|
2321 |
-
if success:
|
2322 |
-
return gr.update(visible=True), content, gr.update(visible=True)
|
2323 |
-
return gr.update(visible=False), "", gr.update(visible=False)
|
2324 |
-
|
2325 |
-
def handle_novel_download(novel_id, format_type):
|
2326 |
-
"""Handle novel download from gallery"""
|
2327 |
-
if novel_id:
|
2328 |
-
file_path = download_novel_from_gallery(novel_id, format_type)
|
2329 |
-
if file_path:
|
2330 |
-
return gr.update(value=file_path, visible=True)
|
2331 |
-
return gr.update(visible=False)
|
2332 |
-
|
2333 |
submit_btn.click(
|
2334 |
fn=process_query,
|
2335 |
inputs=[query_input, language_select, current_session_id],
|
@@ -2356,8 +1642,8 @@ def create_interface():
|
|
2356 |
)
|
2357 |
|
2358 |
clear_btn.click(
|
2359 |
-
fn=lambda: ("", "", "๐ Ready", "", None
|
2360 |
-
outputs=[stages_display, novel_output, status_text, novel_text_state, current_session_id
|
2361 |
)
|
2362 |
|
2363 |
def handle_download(novel_text, format_type, language):
|
@@ -2376,47 +1662,10 @@ def create_interface():
|
|
2376 |
outputs=[download_file]
|
2377 |
)
|
2378 |
|
2379 |
-
#
|
2380 |
-
refresh_gallery_btn.click(
|
2381 |
-
fn=refresh_gallery,
|
2382 |
-
inputs=[gallery_language],
|
2383 |
-
outputs=[gallery_display]
|
2384 |
-
)
|
2385 |
-
|
2386 |
-
gallery_language.change(
|
2387 |
-
fn=refresh_gallery,
|
2388 |
-
inputs=[gallery_language],
|
2389 |
-
outputs=[gallery_display]
|
2390 |
-
)
|
2391 |
-
|
2392 |
-
# Handle novel view selection
|
2393 |
-
selected_novel_view.change(
|
2394 |
-
fn=handle_novel_view,
|
2395 |
-
inputs=[selected_novel_view, language_select],
|
2396 |
-
outputs=[novel_view_content, novel_view_content, gallery_download_row]
|
2397 |
-
)
|
2398 |
-
|
2399 |
-
# Handle novel download selection
|
2400 |
-
selected_novel_download.change(
|
2401 |
-
fn=handle_novel_download,
|
2402 |
-
inputs=[selected_novel_download, gallery_format_select],
|
2403 |
-
outputs=[gallery_download_file]
|
2404 |
-
)
|
2405 |
-
|
2406 |
-
# Direct download button from gallery
|
2407 |
-
download_from_gallery_btn.click(
|
2408 |
-
fn=handle_novel_download,
|
2409 |
-
inputs=[selected_novel_view, gallery_format_select],
|
2410 |
-
outputs=[gallery_download_file]
|
2411 |
-
)
|
2412 |
-
|
2413 |
-
# Load sessions and gallery on startup
|
2414 |
interface.load(
|
2415 |
fn=refresh_sessions,
|
2416 |
outputs=[session_dropdown]
|
2417 |
-
).then(
|
2418 |
-
fn=lambda: refresh_gallery("All"),
|
2419 |
-
outputs=[gallery_display]
|
2420 |
)
|
2421 |
|
2422 |
return interface
|
|
|
33 |
FRIENDLI_TOKEN = os.getenv("FRIENDLI_TOKEN", "YOUR_FRIENDLI_TOKEN")
|
34 |
API_URL = "https://api.friendli.ai/dedicated/v1/chat/completions"
|
35 |
MODEL_ID = "dep89a2fld32mcm"
|
|
|
36 |
TEST_MODE = os.getenv("TEST_MODE", "false").lower() == "true"
|
37 |
|
38 |
# ์ ์ญ ๋ณ์
|
39 |
conversation_history = []
|
40 |
selected_language = "English" # ๊ธฐ๋ณธ ์ธ์ด
|
|
|
41 |
|
42 |
# DB ๊ฒฝ๋ก
|
43 |
DB_PATH = "novel_sessions.db"
|
44 |
db_lock = threading.Lock()
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
class NovelDatabase:
|
47 |
"""Novel session management database"""
|
48 |
|
|
|
81 |
)
|
82 |
''')
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
# Create indices
|
85 |
cursor.execute('CREATE INDEX IF NOT EXISTS idx_session_id ON stages(session_id)')
|
86 |
cursor.execute('CREATE INDEX IF NOT EXISTS idx_stage_number ON stages(stage_number)')
|
|
|
|
|
87 |
|
88 |
conn.commit()
|
89 |
|
|
|
151 |
''', (stage_number, session_id))
|
152 |
|
153 |
conn.commit()
|
154 |
+
logger.info(f"Saved stage {stage_number} for session {session_id}, content length: {len(content)}")
|
155 |
|
156 |
@staticmethod
|
157 |
def get_session(session_id: str) -> Optional[Dict]:
|
|
|
178 |
"""๋ชจ๋ ์๊ฐ์ ์์ ๋ณธ ๋ด์ฉ์ ๊ฐ์ ธ์์ ํฉ์น๊ธฐ - 50ํ์ด์ง ์ ์ฒด"""
|
179 |
with NovelDatabase.get_db() as conn:
|
180 |
cursor = conn.cursor()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
+
# ์๊ฐ ์์ ๋ณธ๋ง ๊ฐ์ ธ์ค๊ธฐ (stage_number 5, 8, 11, 14, 17, 20, 23, 26, 29, 32)
|
183 |
+
writer_revision_stages = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32]
|
184 |
+
|
185 |
+
all_content = []
|
186 |
+
for stage_num in writer_revision_stages:
|
187 |
+
cursor.execute('''
|
188 |
+
SELECT content, stage_name FROM stages
|
189 |
+
WHERE session_id = ? AND stage_number = ?
|
190 |
+
''', (session_id, stage_num))
|
191 |
+
|
192 |
+
row = cursor.fetchone()
|
193 |
+
if row and row['content']:
|
194 |
# ํ์ด์ง ๋งํฌ ์์ ์ ๊ฑฐ
|
195 |
clean_content = re.sub(r'\[(?:ํ์ด์ง|Page|page)\s*\d+\]', '', row['content'])
|
196 |
clean_content = re.sub(r'(?:ํ์ด์ง|Page)\s*\d+:', '', clean_content)
|
197 |
+
clean_content = clean_content.strip()
|
198 |
+
|
199 |
+
if clean_content:
|
200 |
+
all_content.append(clean_content)
|
201 |
+
logger.info(f"Retrieved writer content from stage {stage_num}, length: {len(clean_content)}")
|
202 |
+
|
203 |
+
full_content = '\n\n'.join(all_content)
|
204 |
+
logger.info(f"Total writer content length: {len(full_content)}, from {len(all_content)} writers")
|
205 |
|
206 |
+
return full_content
|
207 |
|
208 |
@staticmethod
|
209 |
def update_final_novel(session_id: str, final_novel: str):
|
|
|
216 |
WHERE session_id = ?
|
217 |
''', (final_novel, session_id))
|
218 |
conn.commit()
|
219 |
+
logger.info(f"Updated final novel for session {session_id}, length: {len(final_novel)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
@staticmethod
|
222 |
def get_active_sessions() -> List[Dict]:
|
|
|
238 |
self.api_url = API_URL
|
239 |
self.model_id = MODEL_ID
|
240 |
self.test_mode = TEST_MODE or (self.token == "YOUR_FRIENDLI_TOKEN")
|
|
|
241 |
|
242 |
if self.test_mode:
|
243 |
logger.warning("Running in test mode.")
|
|
|
247 |
|
248 |
# Session management
|
249 |
self.current_session_id = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
def create_headers(self):
|
252 |
"""API ํค๋ ์์ฑ"""
|
|
|
255 |
"Content-Type": "application/json"
|
256 |
}
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
def create_director_initial_prompt(self, user_query: str, language: str = "English") -> str:
|
259 |
+
"""Director AI initial prompt - Novel planning"""
|
|
|
|
|
|
|
260 |
if language == "Korean":
|
261 |
return f"""๋น์ ์ 50ํ์ด์ง ๋ถ๋์ ์คํธ ์์ค์ ๊ธฐํํ๋ ๋ฌธํ ๊ฐ๋
์์
๋๋ค.
|
262 |
|
263 |
์ฌ์ฉ์ ์์ฒญ: {user_query}
|
264 |
|
|
|
|
|
265 |
๋ค์ ์์๋ค์ ์ฒด๊ณ์ ์ผ๋ก ๊ตฌ์ฑํ์ฌ 50ํ์ด์ง ์คํธ ์์ค์ ๊ธฐ์ด๋ฅผ ๋ง๋์ธ์:
|
266 |
|
267 |
1. **์ฃผ์ ์ ์ฅ๋ฅด**
|
|
|
287 |
- ์ฌํ์ /๋ฌธํ์ ๋งฅ๋ฝ
|
288 |
- ๋ถ์๊ธฐ์ ํค
|
289 |
|
290 |
+
๊ฐ ์์ฑ์๊ฐ 5ํ์ด์ง์ฉ ์์ฑํ ์ ์๋๋ก ๋ช
ํํ ๊ฐ์ด๋๋ผ์ธ์ ์ ์ํ์ธ์."""
|
|
|
291 |
else:
|
292 |
return f"""You are a literary director planning a 50-page novella.
|
293 |
|
294 |
User Request: {user_query}
|
295 |
|
|
|
|
|
296 |
Systematically compose the following elements to create the foundation for a 50-page novella:
|
297 |
|
298 |
1. **Theme and Genre**
|
|
|
318 |
- Social/cultural context
|
319 |
- Atmosphere and tone
|
320 |
|
321 |
+
Provide clear guidelines for each writer to compose 5 pages."""
|
|
|
322 |
|
323 |
def create_critic_director_prompt(self, director_plan: str, language: str = "English") -> str:
|
324 |
"""Critic's review of director's plan"""
|
|
|
473 |
pages_start = (writer_number - 1) * 5 + 1
|
474 |
pages_end = writer_number * 5
|
475 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
if language == "Korean":
|
477 |
return f"""๋น์ ์ ์์ฑ์ {writer_number}๋ฒ์
๋๋ค. 50ํ์ด์ง ์คํธ ์์ค์ {pages_start}-{pages_end}ํ์ด์ง(5ํ์ด์ง)๋ฅผ ์์ฑํ์ธ์.
|
478 |
|
|
|
480 |
{director_plan}
|
481 |
|
482 |
{'์ด์ ๊น์ง์ ๋ด์ฉ:' if previous_content else '๋น์ ์ด ์ฒซ ๋ฒ์งธ ์์ฑ์์
๋๋ค.'}
|
483 |
+
{previous_content[-2000:] if previous_content else ''}
|
|
|
|
|
484 |
|
485 |
๋ค์ ์ง์นจ์ ๋ฐ๋ผ ์์ฑํ์ธ์:
|
486 |
|
|
|
499 |
- ๋
์์ ๋ชฐ์
์ ํด์น์ง ์๊ธฐ
|
500 |
|
501 |
์ค์: ํ์ด์ง ๊ตฌ๋ถ ํ์๋ฅผ ์ ๋ ํ์ง ๋ง์ธ์. ์์ฐ์ค๋ฝ๊ฒ ์ด์ด์ง๋ ์์ฌ๋ก ์์ฑํ์ธ์.
|
502 |
+
๋ฐ๋์ 2500-3000๋จ์ด ๋ถ๋์ ์ฑ์์ฃผ์ธ์."""
|
503 |
else:
|
504 |
return f"""You are Writer #{writer_number}. Write pages {pages_start}-{pages_end} (5 pages) of the 50-page novella.
|
505 |
|
|
|
507 |
{director_plan}
|
508 |
|
509 |
{'Previous content:' if previous_content else 'You are the first writer.'}
|
510 |
+
{previous_content[-2000:] if previous_content else ''}
|
|
|
|
|
511 |
|
512 |
Write according to these guidelines:
|
513 |
|
|
|
526 |
- Keep reader immersion
|
527 |
|
528 |
Important: DO NOT use any page markers. Write as continuous narrative.
|
529 |
+
You MUST write 2500-3000 words."""
|
530 |
|
531 |
def create_critic_writer_prompt(self, writer_number: int, writer_content: str, director_plan: str, all_previous_content: str, language: str = "English") -> str:
|
532 |
"""Critic's review of individual writer's work"""
|
|
|
536 |
๊ฐ๋
์์ ๋ง์คํฐํ๋:
|
537 |
{director_plan}
|
538 |
|
539 |
+
์ด์ ๋ด์ฉ ์์ฝ:
|
540 |
+
{all_previous_content[-1000:] if all_previous_content else '์ฒซ ๋ฒ์งธ ์์ฑ์์
๋๋ค.'}
|
541 |
|
542 |
์์ฑ์ {writer_number}๋ฒ์ ๋ด์ฉ:
|
543 |
{writer_content}
|
|
|
578 |
Director's Masterplan:
|
579 |
{director_plan}
|
580 |
|
581 |
+
Previous Content Summary:
|
582 |
+
{all_previous_content[-1000:] if all_previous_content else 'This is the first writer.'}
|
583 |
|
584 |
Writer #{writer_number}'s Content:
|
585 |
{writer_content}
|
|
|
646 |
- ์ด์ /์ดํ ๋ด์ฉ๊ณผ์ ์์ฐ์ค๋ฌ์ด ์ฐ๊ฒฐ
|
647 |
- ์์ ์ผ๋ก ์ธํ ์๋ก์ด ๋ชจ์ ๋ฐฉ์ง
|
648 |
|
649 |
+
์์ ๋ ์ต์ข
๋ณธ์ ์ ์ํ์ธ์. ํ์ด์ง ๋งํฌ๋ ์ ๋ ์ฌ์ฉํ์ง ๋ง์ธ์.
|
650 |
+
๋ฐ๋์ 2500-3000๋จ์ด ๋ถ๋์ ์ ์งํ์ธ์."""
|
651 |
else:
|
652 |
return f"""As Writer #{writer_number}, revise based on critic's feedback.
|
653 |
|
|
|
677 |
- Natural connection with previous/next content
|
678 |
- Prevent new contradictions from revisions
|
679 |
|
680 |
+
Present the revised final version. Never use page markers.
|
681 |
+
You MUST maintain 2500-3000 words."""
|
682 |
|
683 |
def create_critic_final_prompt(self, all_content: str, director_plan: str, language: str = "English") -> str:
|
684 |
"""Final critic evaluation of complete novel"""
|
685 |
+
content_preview = all_content[:3000] + "\n...\n" + all_content[-3000:] if len(all_content) > 6000 else all_content
|
686 |
+
|
687 |
if language == "Korean":
|
688 |
return f"""์ ์ฒด 50ํ์ด์ง ์์ค์ ์ต์ข
ํ๊ฐํฉ๋๋ค.
|
689 |
|
690 |
๊ฐ๋
์์ ๋ง์คํฐํ๋:
|
691 |
{director_plan}
|
692 |
|
693 |
+
์์ฑ๋ ์ ์ฒด ์์ค (๋ฏธ๋ฆฌ๋ณด๊ธฐ):
|
694 |
+
{content_preview}
|
695 |
+
|
696 |
+
์ด ๋ถ๋: {len(all_content.split())} ๋จ์ด
|
697 |
|
698 |
์ข
ํฉ์ ์ธ ํ๊ฐ์ ์ต์ข
๊ฐ์ ์ ์์ ์ ์ํ์ธ์:
|
699 |
|
|
|
733 |
Director's Masterplan:
|
734 |
{director_plan}
|
735 |
|
736 |
+
Complete Novel (Preview):
|
737 |
+
{content_preview}
|
738 |
+
|
739 |
+
Total length: {len(all_content.split())} words
|
740 |
|
741 |
Provide comprehensive evaluation and final improvement suggestions:
|
742 |
|
|
|
773 |
|
774 |
def create_director_final_prompt(self, all_content: str, critic_final_feedback: str, language: str = "English") -> str:
|
775 |
"""Director's final compilation and polish - ๋ชจ๋ ์๊ฐ ๋ด์ฉ ํฌํจ"""
|
776 |
+
word_count = len(all_content.split())
|
777 |
+
|
778 |
if language == "Korean":
|
779 |
return f"""๊ฐ๋
์๋ก์ ๋นํ๊ฐ์ ์ต์ข
ํ๊ฐ๋ฅผ ๋ฐ์ํ์ฌ ์์ฑ๋ณธ์ ์ ์ํฉ๋๋ค.
|
780 |
|
781 |
+
์ ์ฒด ์๊ฐ๋ค์ ์ํ (50ํ์ด์ง ์ ์ฒด, {word_count}๋จ์ด):
|
782 |
{all_content}
|
783 |
|
784 |
๋นํ๊ฐ ์ต์ข
ํ๊ฐ:
|
|
|
790 |
|
791 |
## ์ํ ์ ๋ณด
|
792 |
- ์ฅ๋ฅด:
|
793 |
+
- ๋ถ๋: 50ํ์ด์ง ({word_count}๋จ์ด)
|
794 |
- ์ฃผ์ :
|
795 |
- ํ ์ค ์์ฝ:
|
796 |
|
|
|
820 |
else:
|
821 |
return f"""As director, create the final version reflecting the critic's final evaluation.
|
822 |
|
823 |
+
Complete Writers' Work (Full 50 pages, {word_count} words):
|
824 |
{all_content}
|
825 |
|
826 |
Critic's Final Evaluation:
|
|
|
832 |
|
833 |
## Work Information
|
834 |
- Genre:
|
835 |
+
- Length: 50 pages ({word_count} words)
|
836 |
- Theme:
|
837 |
- One-line summary:
|
838 |
|
|
|
907 |
headers=self.create_headers(),
|
908 |
json=payload,
|
909 |
stream=True,
|
910 |
+
timeout=30
|
911 |
)
|
912 |
|
913 |
if response.status_code != 200:
|
|
|
954 |
return {
|
955 |
"director": "๋น์ ์ 50ํ์ด์ง ์คํธ ์์ค์ ๊ธฐํํ๊ณ ๊ฐ๋
ํ๋ ๋ฌธํ ๊ฐ๋
์์
๋๋ค. ์ฒด๊ณ์ ์ด๊ณ ์ฐฝ์์ ์ธ ์คํ ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ๋ง๋ค์ด๋
๋๋ค.",
|
956 |
"critic": "๋น์ ์ ๋ ์นด๋ก์ด ํต์ฐฐ๋ ฅ์ ๊ฐ์ง ๋ฌธํ ๋นํ๊ฐ์
๋๋ค. ๊ฑด์ค์ ์ด๊ณ ๊ตฌ์ฒด์ ์ธ ํผ๋๋ฐฑ์ ์ ๊ณตํฉ๋๋ค.",
|
957 |
+
"writer1": "๋น์ ์ ์์ค์ ๋์
๋ถ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๋
์๋ฅผ ์ฌ๋ก์ก๋ ์์์ ๋ง๋ญ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
958 |
+
"writer2": "๋น์ ์ ์ด๋ฐ ์ ๊ฐ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ธ๋ฌผ๊ณผ ์ํฉ์ ๊น์ด ์๊ฒ ๋ฐ์ ์ํต๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
959 |
+
"writer3": "๋น์ ์ ๊ฐ๋ฑ ์์น์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๊ธด์ฅ๊ฐ์ ๋์ด๊ณ ๋ณต์ก์ฑ์ ๋ํฉ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
960 |
+
"writer4": "๋น์ ์ ์ค๋ฐ๋ถ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ด์ผ๊ธฐ์ ์ค์ฌ์ถ์ ๊ฒฌ๊ณ ํ๊ฒ ๋ง๋ญ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
961 |
+
"writer5": "๋น์ ์ ์ ํ์ ์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์์์น ๋ชปํ ๋ณํ๋ฅผ ๋ง๋ค์ด๋
๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
962 |
+
"writer6": "๋น์ ์ ๊ฐ๋ฑ ์ฌํ๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์๊ธฐ๋ฅผ ๊ทน๋ํํฉ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
963 |
+
"writer7": "๋น์ ์ ํด๋ผ์ด๋งฅ์ค ์ค๋น๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ต๊ณ ์กฐ๋ฅผ ํฅํด ๋์๊ฐ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
964 |
+
"writer8": "๋น์ ์ ํด๋ผ์ด๋งฅ์ค๋ฅผ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๋ชจ๋ ๊ฐ๋ฑ์ด ํญ๋ฐํ๋ ์๊ฐ์ ๊ทธ๋ฆฝ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ๏ฟฝ๏ฟฝ๏ฟฝ์ฑํ์ธ์.",
|
965 |
+
"writer9": "๋น์ ์ ํด๊ฒฐ ๊ณผ์ ์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ๋งค๋ญ์ ํ์ด๋๊ฐ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์.",
|
966 |
+
"writer10": "๋น์ ์ ๊ฒฐ๋ง์ ๋ด๋นํ๋ ์๊ฐ์
๋๋ค. ์ฌ์ด์ด ๋จ๋ ๋ง๋ฌด๋ฆฌ๋ฅผ ๋ง๋ญ๋๋ค. ๋ฐ๋์ 2500-3000๋จ์ด๋ฅผ ์์ฑํ์ธ์."
|
967 |
}
|
968 |
else:
|
969 |
return {
|
970 |
"director": "You are a literary director planning and supervising a 50-page novella. You create systematic and creative story structures.",
|
971 |
"critic": "You are a literary critic with sharp insights. You provide constructive and specific feedback.",
|
972 |
+
"writer1": "You are the writer responsible for the introduction. You create a captivating beginning. You MUST write 2500-3000 words.",
|
973 |
+
"writer2": "You are the writer responsible for early development. You deepen characters and situations. You MUST write 2500-3000 words.",
|
974 |
+
"writer3": "You are the writer responsible for rising conflict. You increase tension and add complexity. You MUST write 2500-3000 words.",
|
975 |
+
"writer4": "You are the writer responsible for the middle section. You solidify the story's central axis. You MUST write 2500-3000 words.",
|
976 |
+
"writer5": "You are the writer responsible for the turning point. You create unexpected changes. You MUST write 2500-3000 words.",
|
977 |
+
"writer6": "You are the writer responsible for deepening conflict. You maximize the crisis. You MUST write 2500-3000 words.",
|
978 |
+
"writer7": "You are the writer responsible for climax preparation. You move toward the peak. You MUST write 2500-3000 words.",
|
979 |
+
"writer8": "You are the writer responsible for the climax. You depict the moment when all conflicts explode. You MUST write 2500-3000 words.",
|
980 |
+
"writer9": "You are the writer responsible for the resolution process. You untangle the knots. You MUST write 2500-3000 words.",
|
981 |
+
"writer10": "You are the writer responsible for the ending. You create a lingering conclusion. You MUST write 2500-3000 words."
|
982 |
}
|
983 |
|
984 |
def get_test_response(self, role: str, language: str) -> str:
|
985 |
+
"""Get test response based on role - ํ
์คํธ์ฉ ๊ธด ์๋ต"""
|
986 |
if language == "Korean":
|
987 |
return self.get_korean_test_response(role)
|
988 |
else:
|
989 |
return self.get_english_test_response(role)
|
990 |
|
991 |
def get_korean_test_response(self, role: str) -> str:
|
992 |
+
"""Korean test responses with full content"""
|
993 |
test_responses = {
|
994 |
"director": """50ํ์ด์ง ์คํธ ์์ค ๊ธฐํ์์ ์ ์ํฉ๋๋ค.
|
995 |
|
|
|
1044 |
- ARIA์ '๋ชฉ์๋ฆฌ' ์ผ๊ด์ฑ ์ ์ง ๋ฐฉ์ ๊ตฌ์ฒดํ ํ์""",
|
1045 |
}
|
1046 |
|
1047 |
+
# ์๊ฐ ์๋ต - ๊ธด ํ
์คํธ ํ
์คํธ (2500๋จ์ด ์ด์)
|
1048 |
for i in range(1, 11):
|
|
|
|
|
|
|
1049 |
test_responses[f"writer{i}"] = f"""์์ฑ์ {i}๋ฒ์ ํํธ์
๋๋ค.
|
1050 |
|
1051 |
+
""" + "ํ
์คํธ ํ
์คํธ์
๋๋ค. " * 500 # 2500๋จ์ด ์ด์์ ๊ธด ํ
์คํธ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1052 |
|
1053 |
return test_responses.get(role, "ํ
์คํธ ์๋ต์
๋๋ค.")
|
1054 |
|
1055 |
def get_english_test_response(self, role: str) -> str:
|
1056 |
+
"""English test responses with full content"""
|
1057 |
test_responses = {
|
1058 |
"director": """I present the 50-page novella plan.
|
1059 |
|
|
|
1108 |
- Need to concretize ARIA's 'voice' consistency maintenance""",
|
1109 |
}
|
1110 |
|
1111 |
+
# Writer responses - long test text (2500+ words)
|
1112 |
for i in range(1, 11):
|
|
|
|
|
|
|
1113 |
test_responses[f"writer{i}"] = f"""Writer {i} begins their section here.
|
1114 |
|
1115 |
+
""" + "This is test text. " * 500 # 2500+ words of long text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1116 |
|
1117 |
return test_responses.get(role, "Test response.")
|
1118 |
|
|
|
1121 |
resume_from_stage: int = 0) -> Generator[Tuple[str, List[Dict[str, str]]], None, None]:
|
1122 |
"""Process novel writing with streaming updates"""
|
1123 |
try:
|
1124 |
+
global conversation_history
|
1125 |
|
1126 |
# Create or resume session
|
1127 |
if session_id:
|
|
|
1135 |
self.current_session_id = NovelDatabase.create_session(query, language)
|
1136 |
resume_from_stage = 0
|
1137 |
|
1138 |
+
logger.info(f"Processing novel for session {self.current_session_id}, starting from stage {resume_from_stage}")
|
1139 |
+
|
1140 |
# Initialize conversation
|
1141 |
conversation_history = [{
|
1142 |
"role": "human",
|
|
|
1155 |
"content": stage_data['content'] or ""
|
1156 |
})
|
1157 |
|
|
|
|
|
|
|
|
|
1158 |
# Define all stages
|
1159 |
stage_definitions = [
|
1160 |
("director", f"๐ฌ {'๊ฐ๋
์: ์ด๊ธฐ ๊ธฐํ' if language == 'Korean' else 'Director: Initial Planning'}"),
|
|
|
1192 |
yield "", stages
|
1193 |
|
1194 |
# Get appropriate prompt based on stage
|
1195 |
+
prompt = self.get_stage_prompt(stage_idx, role, query, language, stages)
|
|
|
1196 |
|
1197 |
stage_content = ""
|
1198 |
|
|
|
1217 |
"complete"
|
1218 |
)
|
1219 |
|
|
|
|
|
|
|
|
|
1220 |
yield "", stages
|
1221 |
|
1222 |
# Get final novel from last stage
|
1223 |
final_novel = stages[-1]["content"] if stages else ""
|
1224 |
|
1225 |
+
# Save final novel to DB
|
1226 |
NovelDatabase.update_final_novel(self.current_session_id, final_novel)
|
1227 |
|
|
|
|
|
|
|
1228 |
# Final yield
|
1229 |
yield final_novel, stages
|
1230 |
|
|
|
1251 |
yield f"Error occurred: {str(e)}", stages
|
1252 |
|
1253 |
def get_stage_prompt(self, stage_idx: int, role: str, query: str,
|
1254 |
+
language: str, stages: List[Dict]) -> str:
|
|
|
1255 |
"""Get appropriate prompt for each stage"""
|
1256 |
# Stage 0: Director Initial
|
1257 |
if stage_idx == 0:
|
|
|
1273 |
|
1274 |
# Initial draft or revision?
|
1275 |
if "์ด์" in stages[stage_idx]["name"] or "Draft" in stages[stage_idx]["name"]:
|
1276 |
+
# Get accumulated content from DB
|
1277 |
+
accumulated_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
1278 |
return self.create_writer_prompt(writer_num, final_plan, accumulated_content, language)
|
1279 |
else: # Revision
|
1280 |
# Find the initial draft and critic feedback
|
|
|
1293 |
|
1294 |
# Final evaluation
|
1295 |
if "๏ฟฝ๏ฟฝ๏ฟฝ์ข
" in stages[stage_idx]["name"] or "Final" in stages[stage_idx]["name"]:
|
1296 |
+
# Get all writer content from DB
|
1297 |
all_writer_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
1298 |
+
logger.info(f"Final evaluation with {len(all_writer_content)} characters of content")
|
1299 |
return self.create_critic_final_prompt(all_writer_content, final_plan, language)
|
1300 |
|
1301 |
# Writer review
|
|
|
1304 |
for i in range(1, 11):
|
1305 |
if f"์์ฑ์ {i}" in stages[stage_idx]["name"] or f"Writer {i}" in stages[stage_idx]["name"]:
|
1306 |
writer_content_idx = stage_idx - 1
|
1307 |
+
# Get previous writers' content from DB
|
1308 |
previous_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
1309 |
return self.create_critic_writer_prompt(
|
1310 |
i,
|
|
|
1315 |
)
|
1316 |
|
1317 |
# Director final - DB์์ ๋ชจ๋ ์๊ฐ ๋ด์ฉ ๊ฐ์ ธ์ค๊ธฐ
|
1318 |
+
elif stage_idx == len(stage_definitions) - 1:
|
1319 |
critic_final_idx = stage_idx - 1
|
1320 |
all_writer_content = NovelDatabase.get_all_writer_content(self.current_session_id)
|
1321 |
+
logger.info(f"Final director compilation with {len(all_writer_content)} characters of content")
|
1322 |
return self.create_director_final_prompt(
|
1323 |
all_writer_content,
|
1324 |
stages[critic_final_idx]["content"],
|
|
|
1371 |
|
1372 |
return display
|
1373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1374 |
def get_active_sessions(language: str) -> List[Tuple[str, str]]:
|
1375 |
"""Get list of active sessions"""
|
1376 |
try:
|
|
|
1491 |
overflow-y: auto;
|
1492 |
}
|
1493 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1494 |
.download-section {
|
1495 |
background-color: rgba(255, 255, 255, 0.9);
|
1496 |
padding: 15px;
|
1497 |
border-radius: 8px;
|
1498 |
margin-top: 20px;
|
1499 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1500 |
"""
|
1501 |
|
1502 |
# Create Gradio Interface
|
|
|
1520 |
|
1521 |
# State management
|
1522 |
current_session_id = gr.State(None)
|
|
|
|
|
1523 |
|
1524 |
with gr.Row():
|
1525 |
with gr.Column(scale=1):
|
|
|
1585 |
label="Downloaded File / ๋ค์ด๋ก๋๋ ํ์ผ",
|
1586 |
visible=False
|
1587 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1588 |
|
1589 |
# Hidden state for novel text
|
1590 |
novel_text_state = gr.State("")
|
|
|
1616 |
logger.error(f"Error refreshing sessions: {str(e)}")
|
1617 |
return gr.update(choices=[])
|
1618 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1619 |
submit_btn.click(
|
1620 |
fn=process_query,
|
1621 |
inputs=[query_input, language_select, current_session_id],
|
|
|
1642 |
)
|
1643 |
|
1644 |
clear_btn.click(
|
1645 |
+
fn=lambda: ("", "", "๐ Ready", "", None),
|
1646 |
+
outputs=[stages_display, novel_output, status_text, novel_text_state, current_session_id]
|
1647 |
)
|
1648 |
|
1649 |
def handle_download(novel_text, format_type, language):
|
|
|
1662 |
outputs=[download_file]
|
1663 |
)
|
1664 |
|
1665 |
+
# Load sessions on startup
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1666 |
interface.load(
|
1667 |
fn=refresh_sessions,
|
1668 |
outputs=[session_dropdown]
|
|
|
|
|
|
|
1669 |
)
|
1670 |
|
1671 |
return interface
|