Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -399,53 +399,18 @@ class ScreenplayDatabase:
|
|
399 |
return session_id
|
400 |
|
401 |
# In ScreenplayDatabase.save_stage method, add page count tracking
|
402 |
-
@staticmethod
|
403 |
-
def save_stage(session_id: str, stage_number: int, stage_name: str,
|
404 |
-
role: str, content: str, status: str = 'complete'):
|
405 |
-
page_count = 0
|
406 |
-
if role == "screenwriter" and content:
|
407 |
-
# Use the accurate page calculation
|
408 |
-
system = ScreenplayGenerationSystem()
|
409 |
-
page_count = system.calculate_screenplay_pages(content)
|
410 |
-
|
411 |
-
with ScreenplayDatabase.get_db() as conn:
|
412 |
-
cursor = conn.cursor()
|
413 |
-
cursor.execute('''
|
414 |
-
INSERT INTO screenplay_stages
|
415 |
-
(session_id, stage_number, stage_name, role, content, page_count, status)
|
416 |
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
417 |
-
ON CONFLICT(session_id, stage_number)
|
418 |
-
DO UPDATE SET content=?, page_count=?, status=?, updated_at=datetime('now')
|
419 |
-
''', (session_id, stage_number, stage_name, role, content, page_count, status,
|
420 |
-
content, page_count, status))
|
421 |
-
|
422 |
-
# Update total pages in session
|
423 |
-
if role == "screenwriter" and "Expanded" in stage_name:
|
424 |
-
cursor.execute('''
|
425 |
-
UPDATE screenplay_sessions
|
426 |
-
SET total_pages = (
|
427 |
-
SELECT SUM(page_count)
|
428 |
-
FROM screenplay_stages
|
429 |
-
WHERE session_id = ?
|
430 |
-
AND role = 'screenwriter'
|
431 |
-
AND stage_name LIKE '%Expanded%'
|
432 |
-
),
|
433 |
-
updated_at = datetime('now')
|
434 |
-
WHERE session_id = ?
|
435 |
-
''', (session_id, session_id))
|
436 |
-
|
437 |
-
conn.commit()# In ScreenplayDatabase.save_stage method, add page count tracking
|
438 |
-
|
439 |
-
|
440 |
@staticmethod
|
441 |
def save_stage(session_id: str, stage_number: int, stage_name: str,
|
442 |
role: str, content: str, status: str = 'complete'):
|
443 |
page_count = 0
|
|
|
|
|
444 |
if role == "screenwriter" and content:
|
445 |
# Use the accurate page calculation
|
446 |
-
system = ScreenplayGenerationSystem()
|
447 |
page_count = system.calculate_screenplay_pages(content)
|
448 |
|
|
|
449 |
with ScreenplayDatabase.get_db() as conn:
|
450 |
cursor = conn.cursor()
|
451 |
cursor.execute('''
|
@@ -472,8 +437,9 @@ def save_stage(session_id: str, stage_number: int, stage_name: str,
|
|
472 |
WHERE session_id = ?
|
473 |
''', (session_id, session_id))
|
474 |
|
475 |
-
conn.commit()
|
476 |
|
|
|
477 |
|
478 |
|
479 |
@staticmethod
|
@@ -1342,7 +1308,6 @@ Provide specific revision suggestions with improved examples."""
|
|
1342 |
|
1343 |
return lang_prompts.get(language, lang_prompts["English"])
|
1344 |
|
1345 |
-
# โญ ์ฌ๊ธฐ์ ์๋ก์ด ํจ์ ์ถ๊ฐ (๊ธฐ์กด create_script_doctor_prompt ๋ฐ๋ก ์๋)
|
1346 |
def create_script_doctor_expansion_prompt(self, act_content: str, act: str,
|
1347 |
screenplay_type: str, genre: str,
|
1348 |
language: str) -> str:
|
@@ -1355,13 +1320,89 @@ Provide specific revision suggestions with improved examples."""
|
|
1355 |
expansion_needed = target_pages - current_pages
|
1356 |
|
1357 |
lang_prompts = {
|
1358 |
-
"Korean": f"""๋น์ ์ ์คํฌ๋ฆฝํธ
|
1359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1360 |
}
|
1361 |
-
|
1362 |
return lang_prompts.get(language, lang_prompts["English"])
|
1363 |
|
1364 |
-
# โญ create_script_doctor_expansion_prompt ํจ์ ๋ฐ๋ก ์๋์ ์ถ๊ฐ
|
1365 |
def create_expansion_writer_prompt(self, act: str, original_content: str,
|
1366 |
expansion_notes: str, screenplay_type: str,
|
1367 |
language: str) -> str:
|
@@ -1371,10 +1412,75 @@ Provide specific revision suggestions with improved examples."""
|
|
1371 |
target_lines = target_pages * 55
|
1372 |
|
1373 |
lang_prompts = {
|
1374 |
-
"Korean": f"""์๋ณธ {act}๋ฅผ ํ์ฅ ์ง์์ฌํญ์
|
1375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1376 |
}
|
1377 |
-
|
1378 |
return lang_prompts.get(language, lang_prompts["English"])
|
1379 |
|
1380 |
def create_final_reviewer_prompt(self, complete_screenplay: str,
|
|
|
399 |
return session_id
|
400 |
|
401 |
# In ScreenplayDatabase.save_stage method, add page count tracking
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
@staticmethod
|
403 |
def save_stage(session_id: str, stage_number: int, stage_name: str,
|
404 |
role: str, content: str, status: str = 'complete'):
|
405 |
page_count = 0
|
406 |
+
|
407 |
+
# save_stage ํจ์ ๋ด๋ถ
|
408 |
if role == "screenwriter" and content:
|
409 |
# Use the accurate page calculation
|
410 |
+
system = ScreenplayGenerationSystem() # โ ๋งค๋ฒ ์ ์ธ์คํด์ค ์์ฑ
|
411 |
page_count = system.calculate_screenplay_pages(content)
|
412 |
|
413 |
+
|
414 |
with ScreenplayDatabase.get_db() as conn:
|
415 |
cursor = conn.cursor()
|
416 |
cursor.execute('''
|
|
|
437 |
WHERE session_id = ?
|
438 |
''', (session_id, session_id))
|
439 |
|
440 |
+
conn.commit()# In ScreenplayDatabase.save_stage method, add page count tracking
|
441 |
|
442 |
+
|
443 |
|
444 |
|
445 |
@staticmethod
|
|
|
1308 |
|
1309 |
return lang_prompts.get(language, lang_prompts["English"])
|
1310 |
|
|
|
1311 |
def create_script_doctor_expansion_prompt(self, act_content: str, act: str,
|
1312 |
screenplay_type: str, genre: str,
|
1313 |
language: str) -> str:
|
|
|
1320 |
expansion_needed = target_pages - current_pages
|
1321 |
|
1322 |
lang_prompts = {
|
1323 |
+
"Korean": f"""๋น์ ์ ์คํฌ๋ฆฝํธ ๋ฅํฐ์
๋๋ค. {act}๋ฅผ ๊ฒํ ํ๊ณ ํ์ฅ ์ง์์ฌํญ์ ์ ๊ณตํ์ธ์.
|
1324 |
+
|
1325 |
+
**ํ์ฌ ๋ถ๋:** {current_pages:.1f}ํ์ด์ง ({current_lines}์ค)
|
1326 |
+
**๋ชฉํ ๋ถ๋:** {target_pages}ํ์ด์ง
|
1327 |
+
**ํ์ ์ถ๊ฐ๋ถ:** {expansion_needed:.1f}ํ์ด์ง (์ฝ {int(expansion_needed * 55)}์ค)
|
1328 |
+
|
1329 |
+
**์์ฑ๋ ๋ด์ฉ:**
|
1330 |
+
{act_content}
|
1331 |
+
|
1332 |
+
**ํ์ฅ ๋ถ์ ๋ฐ ์ง์์ฌํญ:**
|
1333 |
+
|
1334 |
+
1. **๋ํ ํ์ฅ ๊ธฐํ**
|
1335 |
+
๊ฐ ๋ํ ์ํ์ค๋ฅผ ๊ฒํ ํ๊ณ ๋ค์์ ์ถ๊ฐํ์ธ์:
|
1336 |
+
- ๋น ๋ฅด๊ฒ ์งํ๋ ๋ํ์ ์๋ธํ
์คํธ ์ถ๊ฐ
|
1337 |
+
- ๊ฐ์ ์ ๋นํธ์ ๋ฐ์ ์ถ๊ฐ
|
1338 |
+
- ๊ฐ๋ฑ์ ๋ ๊น์ด ํ๊ตฌํ ๋ํ
|
1339 |
+
- ์บ๋ฆญํฐ์ ๋ด๋ฉด์ ๋๋ฌ๋ผ ๋์ฌ
|
1340 |
+
|
1341 |
+
2. **์ก์
/๋ฌ์ฌ ํ์ฅ**
|
1342 |
+
- ๊ฐ ์ฌ ์คํ๋์ ๋ถ์๊ธฐ ๋ฌ์ฌ ์ถ๊ฐ
|
1343 |
+
- ์บ๋ฆญํฐ ๋ฑ์ฅ ์ ์์ธํ ๋น์ฃผ์ผ ๋ฌ์ฌ
|
1344 |
+
- ์ค์ํ ์๊ฐ์ ์ฌ๋ก์ฐ๋ชจ์
ํจ๊ณผ
|
1345 |
+
- ์ ํ ์ฅ๋ฉด๊ณผ ๋ธ๋ฆฟ์ง ์ถ๊ฐ
|
1346 |
+
|
1347 |
+
3. **์๋ก์ด ๋นํธ ์ฝ์
**
|
1348 |
+
- ๊ธด์ฅ ์๊ธ์ ์ํ ํธํก ์ฅ๋ฉด
|
1349 |
+
- ์บ๋ฆญํฐ์ ์ผ์์ ํ๋ ์ถ๊ฐ
|
1350 |
+
- ๊ด๊ณ๋ฅผ ๋ณด์ฌ์ฃผ๋ ์์ ์๊ฐ๋ค
|
1351 |
+
- ๋ณต์ ์ด ๋ ์ ์๋ ๋ํ
์ผ
|
1352 |
+
|
1353 |
+
4. **{genre} ์ฅ๋ฅด ๊ฐํ**
|
1354 |
+
๋ค์ ์ฅ๋ฅด ์์๋ฅผ ๋ ์ถ๊ฐํ์ธ์:
|
1355 |
+
{chr(10).join([f" - {element}" for element in GENRE_TEMPLATES[genre]['key_elements']])}
|
1356 |
+
|
1357 |
+
5. **๊ตฌ์ฒด์ ํ์ฅ ์์น**
|
1358 |
+
๊ฐ ์ฌ๋ณ๋ก ์ ํํ ์ด๋์ ๋ฌด์์ ์ถ๊ฐํด์ผ ํ๋์ง ๋ช
์ํ์ธ์:
|
1359 |
+
[์ฌ ๋ฒํธ] - [ํ์ฅ ๋ด์ฉ] - [์์ ์ถ๊ฐ ์ค ์]
|
1360 |
+
|
1361 |
+
**๋ชฉํ: ์๋ณธ์ 2๋ฐฐ ๋ถ๋์ผ๋ก ํ์ฅํ๋, ์์ฐ์ค๋ฝ๊ณ ํ์ํ ๋ด์ฉ๋ง ์ถ๊ฐ**""",
|
1362 |
+
|
1363 |
+
"English": f"""You are a script doctor. Review {act} and provide expansion instructions.
|
1364 |
+
|
1365 |
+
**Current Length:** {current_pages:.1f} pages ({current_lines} lines)
|
1366 |
+
**Target Length:** {target_pages} pages
|
1367 |
+
**Additional Needed:** {expansion_needed:.1f} pages (approx {int(expansion_needed * 55)} lines)
|
1368 |
+
|
1369 |
+
**Written Content:**
|
1370 |
+
{act_content}
|
1371 |
+
|
1372 |
+
**Expansion Analysis & Instructions:**
|
1373 |
+
|
1374 |
+
1. **Dialogue Expansion Opportunities**
|
1375 |
+
Review each dialogue sequence and add:
|
1376 |
+
- Subtext to rushed conversations
|
1377 |
+
- Emotional beats and reactions
|
1378 |
+
- Deeper conflict exploration
|
1379 |
+
- Lines revealing character interior
|
1380 |
+
|
1381 |
+
2. **Action/Description Expansion**
|
1382 |
+
- Atmosphere description at scene openings
|
1383 |
+
- Detailed visual when characters appear
|
1384 |
+
- Slow-motion effect for key moments
|
1385 |
+
- Transition scenes and bridges
|
1386 |
+
|
1387 |
+
3. **New Beat Insertions**
|
1388 |
+
- Breathing scenes for pacing
|
1389 |
+
- Character routine actions
|
1390 |
+
- Small relationship moments
|
1391 |
+
- Foreshadowing details
|
1392 |
+
|
1393 |
+
4. **{genre} Genre Enhancement**
|
1394 |
+
Add more of these genre elements:
|
1395 |
+
{chr(10).join([f" - {element}" for element in GENRE_TEMPLATES[genre]['key_elements']])}
|
1396 |
+
|
1397 |
+
5. **Specific Expansion Locations**
|
1398 |
+
Specify exactly where and what to add per scene:
|
1399 |
+
[Scene Number] - [Expansion Content] - [Estimated Additional Lines]
|
1400 |
+
|
1401 |
+
**Goal: Expand to double the original length with natural, necessary content**"""
|
1402 |
}
|
1403 |
+
|
1404 |
return lang_prompts.get(language, lang_prompts["English"])
|
1405 |
|
|
|
1406 |
def create_expansion_writer_prompt(self, act: str, original_content: str,
|
1407 |
expansion_notes: str, screenplay_type: str,
|
1408 |
language: str) -> str:
|
|
|
1412 |
target_lines = target_pages * 55
|
1413 |
|
1414 |
lang_prompts = {
|
1415 |
+
"Korean": f"""์๋ณธ {act}๋ฅผ ํ์ฅ ์ง์์ฌํญ์ ๋ฐ๋ผ ๋ค์ ์์ฑํ์ธ์.
|
1416 |
+
|
1417 |
+
**๋ชฉํ ๋ถ๋:** {target_pages}ํ์ด์ง ({target_lines}์ค)
|
1418 |
+
|
1419 |
+
**์๋ณธ ์ด๊ณ :**
|
1420 |
+
{original_content}
|
1421 |
+
|
1422 |
+
**ํ์ฅ ์ง์์ฌํญ:**
|
1423 |
+
{expansion_notes}
|
1424 |
+
|
1425 |
+
**ํ์ฅ ์์ฑ ์์น:**
|
1426 |
+
|
1427 |
+
1. **๊ตฌ์กฐ ์ ์ง**
|
1428 |
+
- ์๋ณธ์ ์ฌ ์์์ ํต์ฌ ์ฌ๊ฑด ์ ์ง
|
1429 |
+
- ์คํ ๋ฆฌ ์งํ์ ๋
ผ๋ฆฌ์ฑ ๋ณด์กด
|
1430 |
+
- ์บ๋ฆญํฐ ์ํฌ์ ์ผ๊ด์ฑ
|
1431 |
+
|
1432 |
+
2. **์์ฐ์ค๋ฌ์ด ํ์ฅ**
|
1433 |
+
- ์ถ๊ฐ ๋ด์ฉ์ด ์ต์ง์ค๋ฝ์ง ์๊ฒ
|
1434 |
+
- ๊ธฐ์กด ๋ด์ฉ๊ณผ ์ ๊ธฐ์ ์ผ๋ก ์ฐ๊ฒฐ
|
1435 |
+
- ํ์ด์ฑ์ ํด์น์ง ์๋ ์ ์์
|
1436 |
+
|
1437 |
+
3. **ํ์ง ํฅ์**
|
1438 |
+
- ๋ ๊น์ ๊ฐ์ ํํ
|
1439 |
+
- ๋ ์ ๋ช
ํ ์๊ฐ์ ์ด๋ฏธ์ง
|
1440 |
+
- ๋ ๊ฐ๋ ฅํ ๋๋ผ๋งํฑ ์ํฉํธ
|
1441 |
+
|
1442 |
+
4. **ํฌ๋งท ์ค์**
|
1443 |
+
- ํ์ค ์๋๋ฆฌ์ค ํฌ๋งท ์๊ฒฉํ ์ค์
|
1444 |
+
- ์ ์ ํ ์ฌ๋ฐฑ๊ณผ ๊ฐ๊ฒฉ
|
1445 |
+
- ์ฝ๊ธฐ ์ฌ์ด ๊ตฌ์ฑ
|
1446 |
+
|
1447 |
+
**๋ฐ๋์ {target_lines}์ค ์ด์์ ์์ ํ ํ์ฅ ๋ฒ์ ์ ์์ฑํ์ธ์.**""",
|
1448 |
+
|
1449 |
+
"English": f"""Rewrite {act} following expansion instructions.
|
1450 |
+
|
1451 |
+
**Target Length:** {target_pages} pages ({target_lines} lines)
|
1452 |
+
|
1453 |
+
**Original Draft:**
|
1454 |
+
{original_content}
|
1455 |
+
|
1456 |
+
**Expansion Instructions:**
|
1457 |
+
{expansion_notes}
|
1458 |
+
|
1459 |
+
**Expansion Principles:**
|
1460 |
+
|
1461 |
+
1. **Structure Maintenance**
|
1462 |
+
- Keep original scene order and key events
|
1463 |
+
- Preserve story progression logic
|
1464 |
+
- Character arc consistency
|
1465 |
+
|
1466 |
+
2. **Natural Expansion**
|
1467 |
+
- Additional content not forced
|
1468 |
+
- Organically connected to existing
|
1469 |
+
- Without harming pacing
|
1470 |
+
|
1471 |
+
3. **Quality Enhancement**
|
1472 |
+
- Deeper emotional expression
|
1473 |
+
- Clearer visual imagery
|
1474 |
+
- Stronger dramatic impact
|
1475 |
+
|
1476 |
+
4. **Format Compliance**
|
1477 |
+
- Strict standard screenplay format
|
1478 |
+
- Proper margins and spacing
|
1479 |
+
- Reader-friendly composition
|
1480 |
+
|
1481 |
+
**MUST write complete expanded version of {target_lines}+ lines.**"""
|
1482 |
}
|
1483 |
+
|
1484 |
return lang_prompts.get(language, lang_prompts["English"])
|
1485 |
|
1486 |
def create_final_reviewer_prompt(self, complete_screenplay: str,
|