Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
1623 |
"""μν λ³ μμ€ν
ν둬ννΈ"""
|
1624 |
|
1625 |
base_prompts = {
|
@@ -1696,7 +1696,7 @@ Edit so insights accumulate and develop."""
|
|
1696 |
return prompts
|
1697 |
|
1698 |
# --- λ©μΈ νλ‘μΈμ€ ---
|
1699 |
-
|
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 |
-
|
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 |
-
|
1858 |
"""κ°λ
μ μμ ν둬ννΈ"""
|
1859 |
return f"""λΉνμ λ°μνμ¬ ν΅ν©λ μμ¬ κ΅¬μ‘°λ₯Ό μμ±νμΈμ.
|
1860 |
|
@@ -1878,7 +1878,7 @@ Edit so insights accumulate and develop."""
|
|
1878 |
|
1879 |
κ° λ¨κ³κ° μ΄μ μ νμ°μ κ²°κ³Όκ° λλλ‘ μμ νμΈμ."""
|
1880 |
|
1881 |
-
|
1882 |
"""μ΄μ μκ°μ λ΄μ© κ°μ Έμ€κΈ°"""
|
1883 |
if current_writer == 1:
|
1884 |
return ""
|
@@ -1890,7 +1890,7 @@ Edit so insights accumulate and develop."""
|
|
1890 |
|
1891 |
return ""
|
1892 |
|
1893 |
-
|
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 |
-
|
1902 |
"""νΈμ§λ λ΄μ© κ°μ Έμ€κΈ°"""
|
1903 |
for s in stages:
|
1904 |
if "νΈμ§μ" in s.get("name", "") and s["content"]:
|
1905 |
return s["content"]
|
1906 |
return ""
|
1907 |
|
1908 |
-
|
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 |
-
|
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 |
-
|
1951 |
"""λ¬Έμ μ κ°μ§"""
|
1952 |
issues = []
|
1953 |
|
@@ -1971,7 +1971,7 @@ Edit so insights accumulate and develop."""
|
|
1971 |
|
1972 |
return issues
|
1973 |
|
1974 |
-
|
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 |
-
|
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:
|