Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -398,18 +398,20 @@ class ScreenplayDatabase:
|
|
398 |
conn.commit()
|
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 |
-
#
|
410 |
-
|
411 |
-
|
412 |
-
|
|
|
|
|
|
|
413 |
|
414 |
with ScreenplayDatabase.get_db() as conn:
|
415 |
cursor = conn.cursor()
|
@@ -437,16 +439,14 @@ class ScreenplayDatabase:
|
|
437 |
WHERE session_id = ?
|
438 |
''', (session_id, session_id))
|
439 |
|
440 |
-
conn.commit()
|
|
|
441 |
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
@staticmethod
|
446 |
def save_screenplay_bible(session_id: str, bible: ScreenplayBible):
|
447 |
"""Save screenplay bible"""
|
448 |
with ScreenplayDatabase.get_db() as conn:
|
449 |
-
|
450 |
conn.cursor().execute(
|
451 |
'UPDATE screenplay_sessions SET screenplay_bible = ? WHERE session_id = ?',
|
452 |
(bible_json, session_id)
|
@@ -1697,12 +1697,12 @@ Provide specific solutions for each issue."""
|
|
1697 |
# For now, returning a placeholder
|
1698 |
return f"Scenes for {act} from the breakdown"
|
1699 |
|
1700 |
-
|
1701 |
-
|
1702 |
-
def calculate_screenplay_pages(self, content: str) -> float:
|
1703 |
"""Calculate screenplay pages more accurately"""
|
1704 |
if not content:
|
1705 |
return 0.0
|
|
|
1706 |
|
1707 |
lines = content.split('\n')
|
1708 |
|
@@ -2161,12 +2161,18 @@ You provide feedback that's critical yet encouraging."""
|
|
2161 |
|
2162 |
return ""
|
2163 |
|
2164 |
-
|
2165 |
-
|
2166 |
def _get_previous_acts(self, stages: List[Dict], current_idx: int) -> str:
|
2167 |
-
"""Get previous acts content"""
|
2168 |
previous = []
|
2169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2170 |
|
2171 |
if current_idx in act_indices:
|
2172 |
for idx in act_indices[current_idx]:
|
@@ -2175,7 +2181,6 @@ You provide feedback that's critical yet encouraging."""
|
|
2175 |
|
2176 |
return "\n\n---\n\n".join(previous) if previous else ""
|
2177 |
|
2178 |
-
|
2179 |
def _extract_field(self, content: str, field_pattern: str) -> Optional[str]:
|
2180 |
"""Extract field value from content with improved parsing"""
|
2181 |
pattern = rf'{field_pattern}[:\s]*([^\n]+?)(?=\n[A-Z๊ฐ-ํฃ]|$)'
|
|
|
398 |
conn.commit()
|
399 |
return session_id
|
400 |
|
|
|
401 |
@staticmethod
|
402 |
def save_stage(session_id: str, stage_number: int, stage_name: str,
|
403 |
role: str, content: str, status: str = 'complete'):
|
404 |
page_count = 0
|
405 |
+
|
406 |
+
# save_stage ํจ์ ๋ด๋ถ
|
407 |
if role == "screenwriter" and content:
|
408 |
+
# ํ์ด์ง ๊ณ์ฐ์ ์ฌ๊ธฐ์ ๋ ์ ํํ๊ฒ ์ํ
|
409 |
+
if "Expanded Final Version" in stage_name:
|
410 |
+
# ํ์ฅ ์ต์ข
๋ฒ์ ์ ์ ํํ ๊ณ์ฐ ์ฌ์ฉ
|
411 |
+
page_count = ScreenplayGenerationSystem.calculate_screenplay_pages(content)
|
412 |
+
else:
|
413 |
+
# ์ด์์ ๊ฐ๋จํ ๊ณ์ฐ ์ฌ์ฉ
|
414 |
+
page_count = len(content.split('\n')) / 55
|
415 |
|
416 |
with ScreenplayDatabase.get_db() as conn:
|
417 |
cursor = conn.cursor()
|
|
|
439 |
WHERE session_id = ?
|
440 |
''', (session_id, session_id))
|
441 |
|
442 |
+
conn.commit()
|
443 |
+
|
444 |
|
|
|
|
|
|
|
445 |
@staticmethod
|
446 |
def save_screenplay_bible(session_id: str, bible: ScreenplayBible):
|
447 |
"""Save screenplay bible"""
|
448 |
with ScreenplayDatabase.get_db() as conn:
|
449 |
+
bible_json = json.dumps(asdict(bible))
|
450 |
conn.cursor().execute(
|
451 |
'UPDATE screenplay_sessions SET screenplay_bible = ? WHERE session_id = ?',
|
452 |
(bible_json, session_id)
|
|
|
1697 |
# For now, returning a placeholder
|
1698 |
return f"Scenes for {act} from the breakdown"
|
1699 |
|
1700 |
+
@staticmethod
|
1701 |
+
def calculate_screenplay_pages(content: str) -> float:
|
|
|
1702 |
"""Calculate screenplay pages more accurately"""
|
1703 |
if not content:
|
1704 |
return 0.0
|
1705 |
+
|
1706 |
|
1707 |
lines = content.split('\n')
|
1708 |
|
|
|
2161 |
|
2162 |
return ""
|
2163 |
|
|
|
|
|
2164 |
def _get_previous_acts(self, stages: List[Dict], current_idx: int) -> str:
|
2165 |
+
"""Get previous acts content - Fixed for 3-stage structure"""
|
2166 |
previous = []
|
2167 |
+
|
2168 |
+
# 3๋จ๊ณ ๊ตฌ์กฐ์ ๋ง๋ ์ธ๋ฑ์ค ๋งคํ
|
2169 |
+
# ๊ฐ ๋ง์ ์ต์ข
ํ์ฅ ๋ฒ์ ์ธ๋ฑ์ค๋ง ์ฌ์ฉ
|
2170 |
+
act_indices = {
|
2171 |
+
5: [], # Act 1 draft - no previous acts
|
2172 |
+
8: [7], # Act 2A draft - use Act 1 final
|
2173 |
+
11: [7, 10], # Act 2B draft - use Act 1 & 2A finals
|
2174 |
+
14: [7, 10, 13] # Act 3 draft - use Act 1, 2A & 2B finals
|
2175 |
+
}
|
2176 |
|
2177 |
if current_idx in act_indices:
|
2178 |
for idx in act_indices[current_idx]:
|
|
|
2181 |
|
2182 |
return "\n\n---\n\n".join(previous) if previous else ""
|
2183 |
|
|
|
2184 |
def _extract_field(self, content: str, field_pattern: str) -> Optional[str]:
|
2185 |
"""Extract field value from content with improved parsing"""
|
2186 |
pattern = rf'{field_pattern}[:\s]*([^\n]+?)(?=\n[A-Z๊ฐ-ํฃ]|$)'
|