openfree commited on
Commit
b04570f
ยท
verified ยท
1 Parent(s): 405dc84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -20
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
- # 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()
@@ -437,16 +439,14 @@ class ScreenplayDatabase:
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
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,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
- # โญ ์—ฌ๊ธฐ์— ์ƒˆ๋กœ์šด ํ•จ์ˆ˜ ์ถ”๊ฐ€ (_extract_act_scenes ๊ฐ™์€ ํ—ฌํผ ๋ฉ”์„œ๋“œ๋“ค ๊ทผ์ฒ˜)
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
- act_indices = {5: [], 7: [5], 9: [5, 7], 11: [5, 7, 9]}
 
 
 
 
 
 
 
 
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๊ฐ€-ํžฃ]|$)'