openfree commited on
Commit
7cd383c
Β·
verified Β·
1 Parent(s): 278cd2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -1619,7 +1619,7 @@ Carefully review for any remaining repetitions after editing."""
1619
  logger.error(f"슀트리밍 였λ₯˜: {type(e).__name__}: {str(e)}")
1620
  yield f"❌ 였λ₯˜ λ°œμƒ: {str(e)}"
1621
 
1622
- def get_system_prompts(self, language: str) -> Dict[str, str]:
1623
  """역할별 μ‹œμŠ€ν…œ ν”„λ‘¬ν”„νŠΈ"""
1624
 
1625
  base_prompts = {
@@ -1696,7 +1696,7 @@ Edit so insights accumulate and develop."""
1696
  return prompts
1697
 
1698
  # --- 메인 ν”„λ‘œμ„ΈμŠ€ ---
1699
- def process_novel_stream(self, query: str, language: str, session_id: Optional[str] = None) -> Generator[Tuple[str, List[Dict[str, Any]], str], None, None]:
1700
  """μ†Œμ„€ 생성 ν”„λ‘œμ„ΈμŠ€"""
1701
  try:
1702
  resume_from_stage = 0
@@ -1807,7 +1807,7 @@ Edit so insights accumulate and develop."""
1807
  logger.error(f"μ†Œμ„€ 생성 ν”„λ‘œμ„ΈμŠ€ 였λ₯˜: {e}", exc_info=True)
1808
  yield f"❌ 였λ₯˜ λ°œμƒ: {e}", stages if 'stages' in locals() else [], self.current_session_id
1809
 
1810
- def get_stage_prompt(self, stage_idx: int, role: str, query: str, language: str, stages: List[Dict]) -> str:
1811
  """단계별 ν”„λ‘¬ν”„νŠΈ 생성"""
1812
  if stage_idx == 0:
1813
  return self.create_director_initial_prompt(query, language)
@@ -1854,7 +1854,7 @@ Edit so insights accumulate and develop."""
1854
 
1855
  return ""
1856
 
1857
- def create_director_revision_prompt(self, initial_plan: str, critic_feedback: str, user_query: str, language: str) -> str:
1858
  """κ°λ…μž μˆ˜μ • ν”„λ‘¬ν”„νŠΈ"""
1859
  return f"""비평을 λ°˜μ˜ν•˜μ—¬ ν†΅ν•©λœ μ„œμ‚¬ ꡬ쑰λ₯Ό μ™„μ„±ν•˜μ„Έμš”.
1860
 
@@ -1878,7 +1878,7 @@ Edit so insights accumulate and develop."""
1878
 
1879
  각 단계가 μ΄μ „μ˜ 필연적 κ²°κ³Όκ°€ λ˜λ„λ‘ μˆ˜μ •ν•˜μ„Έμš”."""
1880
 
1881
- def get_previous_writer_content(self, stages: List[Dict], current_writer: int) -> str:
1882
  """이전 μž‘κ°€μ˜ λ‚΄μš© κ°€μ Έμ˜€κΈ°"""
1883
  if current_writer == 1:
1884
  return ""
@@ -1890,7 +1890,7 @@ Edit so insights accumulate and develop."""
1890
 
1891
  return ""
1892
 
1893
- def get_all_writer_content(self, stages: List[Dict], up_to_stage: int) -> str:
1894
  """νŠΉμ • λ‹¨κ³„κΉŒμ§€μ˜ λͺ¨λ“  μž‘κ°€ λ‚΄μš©"""
1895
  contents = []
1896
  for i, s in enumerate(stages):
@@ -1898,14 +1898,14 @@ Edit so insights accumulate and develop."""
1898
  contents.append(s["content"])
1899
  return "\n\n".join(contents)
1900
 
1901
- def get_edited_content(self, stages: List[Dict]) -> str:
1902
  """νŽΈμ§‘λœ λ‚΄μš© κ°€μ Έμ˜€κΈ°"""
1903
  for s in stages:
1904
  if "νŽΈμ§‘μž" in s.get("name", "") and s["content"]:
1905
  return s["content"]
1906
  return ""
1907
 
1908
- def generate_narrative_summary(self, stages: List[Dict], up_to_writer: int) -> str:
1909
  """ν˜„μž¬κΉŒμ§€μ˜ μ„œμ‚¬ μš”μ•½"""
1910
  if up_to_writer == 1:
1911
  return "첫 μ‹œμž‘μž…λ‹ˆλ‹€."
@@ -1917,7 +1917,7 @@ Edit so insights accumulate and develop."""
1917
 
1918
  return "\n".join(summary_parts) if summary_parts else "이전 λ‚΄μš©μ„ 이어받아 μ§„ν–‰ν•˜μ„Έμš”."
1919
 
1920
- def update_narrative_tracker(self, content: str, writer_num: int):
1921
  """μ„œμ‚¬ 좔적기 μ—…λ°μ΄νŠΈ"""
1922
  # κ°„λ‹¨ν•œ μš”μ•½ 생성 (μ‹€μ œλ‘œλŠ” 더 μ •κ΅ν•œ 뢄석 ν•„μš”)
1923
  lines = content.split('\n')
@@ -1947,7 +1947,7 @@ Edit so insights accumulate and develop."""
1947
  if literary_devices:
1948
  self.narrative_tracker.literary_devices[writer_num] = literary_devices
1949
 
1950
- def detect_issues(self, content: str) -> List[str]:
1951
  """문제점 감지"""
1952
  issues = []
1953
 
@@ -1971,7 +1971,7 @@ Edit so insights accumulate and develop."""
1971
 
1972
  return issues
1973
 
1974
- def evaluate_progression(self, content: str, phase: int) -> float:
1975
  """μ„œμ‚¬ 진행도 평가"""
1976
  score = 5.0
1977
 
@@ -2003,7 +2003,7 @@ Edit so insights accumulate and develop."""
2003
 
2004
  return min(10.0, score)
2005
 
2006
- def generate_literary_report(self, complete_novel: str, word_count: int, language: str) -> str:
2007
  """μ΅œμ’… 문학적 평가"""
2008
  prompt = self.create_critic_final_prompt(complete_novel, word_count, language)
2009
  try:
 
1619
  logger.error(f"슀트리밍 였λ₯˜: {type(e).__name__}: {str(e)}")
1620
  yield f"❌ 였λ₯˜ λ°œμƒ: {str(e)}"
1621
 
1622
+ def get_system_prompts(self, language: str) -> Dict[str, str]:
1623
  """역할별 μ‹œμŠ€ν…œ ν”„λ‘¬ν”„νŠΈ"""
1624
 
1625
  base_prompts = {
 
1696
  return prompts
1697
 
1698
  # --- 메인 ν”„λ‘œμ„ΈμŠ€ ---
1699
+ def process_novel_stream(self, query: str, language: str, session_id: Optional[str] = None) -> Generator[Tuple[str, List[Dict[str, Any]], str], None, None]:
1700
  """μ†Œμ„€ 생성 ν”„λ‘œμ„ΈμŠ€"""
1701
  try:
1702
  resume_from_stage = 0
 
1807
  logger.error(f"μ†Œμ„€ 생성 ν”„λ‘œμ„ΈμŠ€ 였λ₯˜: {e}", exc_info=True)
1808
  yield f"❌ 였λ₯˜ λ°œμƒ: {e}", stages if 'stages' in locals() else [], self.current_session_id
1809
 
1810
+ def get_stage_prompt(self, stage_idx: int, role: str, query: str, language: str, stages: List[Dict]) -> str:
1811
  """단계별 ν”„λ‘¬ν”„νŠΈ 생성"""
1812
  if stage_idx == 0:
1813
  return self.create_director_initial_prompt(query, language)
 
1854
 
1855
  return ""
1856
 
1857
+ def create_director_revision_prompt(self, initial_plan: str, critic_feedback: str, user_query: str, language: str) -> str:
1858
  """κ°λ…μž μˆ˜μ • ν”„λ‘¬ν”„νŠΈ"""
1859
  return f"""비평을 λ°˜μ˜ν•˜μ—¬ ν†΅ν•©λœ μ„œμ‚¬ ꡬ쑰λ₯Ό μ™„μ„±ν•˜μ„Έμš”.
1860
 
 
1878
 
1879
  각 단계가 μ΄μ „μ˜ 필연적 κ²°κ³Όκ°€ λ˜λ„λ‘ μˆ˜μ •ν•˜μ„Έμš”."""
1880
 
1881
+ def get_previous_writer_content(self, stages: List[Dict], current_writer: int) -> str:
1882
  """이전 μž‘κ°€μ˜ λ‚΄μš© κ°€μ Έμ˜€κΈ°"""
1883
  if current_writer == 1:
1884
  return ""
 
1890
 
1891
  return ""
1892
 
1893
+ def get_all_writer_content(self, stages: List[Dict], up_to_stage: int) -> str:
1894
  """νŠΉμ • λ‹¨κ³„κΉŒμ§€μ˜ λͺ¨λ“  μž‘κ°€ λ‚΄μš©"""
1895
  contents = []
1896
  for i, s in enumerate(stages):
 
1898
  contents.append(s["content"])
1899
  return "\n\n".join(contents)
1900
 
1901
+ def get_edited_content(self, stages: List[Dict]) -> str:
1902
  """νŽΈμ§‘λœ λ‚΄μš© κ°€μ Έμ˜€κΈ°"""
1903
  for s in stages:
1904
  if "νŽΈμ§‘μž" in s.get("name", "") and s["content"]:
1905
  return s["content"]
1906
  return ""
1907
 
1908
+ def generate_narrative_summary(self, stages: List[Dict], up_to_writer: int) -> str:
1909
  """ν˜„μž¬κΉŒμ§€μ˜ μ„œμ‚¬ μš”μ•½"""
1910
  if up_to_writer == 1:
1911
  return "첫 μ‹œμž‘μž…λ‹ˆλ‹€."
 
1917
 
1918
  return "\n".join(summary_parts) if summary_parts else "이전 λ‚΄μš©μ„ 이어받아 μ§„ν–‰ν•˜μ„Έμš”."
1919
 
1920
+ def update_narrative_tracker(self, content: str, writer_num: int):
1921
  """μ„œμ‚¬ 좔적기 μ—…λ°μ΄νŠΈ"""
1922
  # κ°„λ‹¨ν•œ μš”μ•½ 생성 (μ‹€μ œλ‘œλŠ” 더 μ •κ΅ν•œ 뢄석 ν•„μš”)
1923
  lines = content.split('\n')
 
1947
  if literary_devices:
1948
  self.narrative_tracker.literary_devices[writer_num] = literary_devices
1949
 
1950
+ def detect_issues(self, content: str) -> List[str]:
1951
  """문제점 감지"""
1952
  issues = []
1953
 
 
1971
 
1972
  return issues
1973
 
1974
+ def evaluate_progression(self, content: str, phase: int) -> float:
1975
  """μ„œμ‚¬ 진행도 평가"""
1976
  score = 5.0
1977
 
 
2003
 
2004
  return min(10.0, score)
2005
 
2006
+ def generate_literary_report(self, complete_novel: str, word_count: int, language: str) -> str:
2007
  """μ΅œμ’… 문학적 평가"""
2008
  prompt = self.create_critic_final_prompt(complete_novel, word_count, language)
2009
  try: