Spaces:
Sleeping
Sleeping
๐ญ ์์ฑ: AI ๊ธฐ๋ฐ ๋์ ๋งค๋ ฅ์ ๊ฒฐํจ/๋ชจ์ ์์ฑ ์์คํ - ์ฑ๊ฒฉ ์กฐ์ ์ 152๊ฐ ๋ณ์ + ๋งค๋ ฅ์ ๊ฒฐํจ + ๋ชจ์์ ํน์ฑ ๋ชจ๋ ์ผ๊ด์ฑ ์๊ฒ ์ฌ์์ฑ
Browse files
app.py
CHANGED
|
@@ -557,6 +557,41 @@ def adjust_persona_traits(persona, warmth, competence, extraversion, humor_style
|
|
| 557 |
|
| 558 |
# ์
๋ฐ์ดํธ๋ ํ๋กํ ์ ์ฅ
|
| 559 |
adjusted_persona["์ฑ๊ฒฉํ๋กํ"] = profile.to_dict()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
|
| 561 |
# ์กฐ์ ๋ ๋ณ์๋ค์ DataFrame์ผ๋ก ์์ฑ
|
| 562 |
variables_df = []
|
|
@@ -637,6 +672,27 @@ def adjust_persona_traits(persona, warmth, competence, extraversion, humor_style
|
|
| 637 |
# ๋ณํ๋ ๋ถ์ ์์ฑ
|
| 638 |
change_analysis = show_variable_changes(original_persona, adjusted_persona)
|
| 639 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 640 |
adjustment_message = f"""
|
| 641 |
### ๐ญ {persona_name}์ ์ฑ๊ฒฉ์ด ์กฐ์ ๋์์ต๋๋ค!
|
| 642 |
|
|
@@ -649,15 +705,33 @@ def adjust_persona_traits(persona, warmth, competence, extraversion, humor_style
|
|
| 649 |
|
| 650 |
๐งฌ **๋ฐฑ๊ทธ๋ผ์ด๋**: 152๊ฐ ์ธ๋ถ ๋ณ์๊ฐ ์ด ์ค์ ์ ๋ง์ถฐ ์๋ ์กฐ์ ๋์์ต๋๋ค.
|
| 651 |
|
| 652 |
-
{change_analysis}
|
| 653 |
"""
|
| 654 |
|
| 655 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 656 |
|
| 657 |
except Exception as e:
|
| 658 |
import traceback
|
| 659 |
traceback.print_exc()
|
| 660 |
-
return persona, f"์กฐ์ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}", {}, []
|
| 661 |
|
| 662 |
def finalize_persona(persona):
|
| 663 |
"""ํ๋ฅด์๋ ์ต์ข
ํ์ - ํ๊ฒฝ๋ณ์ API ์ค์ ์ฌ์ฉ"""
|
|
@@ -1744,7 +1818,7 @@ def create_main_interface():
|
|
| 1744 |
adjust_btn.click(
|
| 1745 |
fn=adjust_persona_traits,
|
| 1746 |
inputs=[current_persona, warmth_slider, competence_slider, extraversion_slider, humor_style_radio],
|
| 1747 |
-
outputs=[current_persona, adjustment_result, adjusted_info_output, personality_variables_output]
|
| 1748 |
).then(
|
| 1749 |
# ๋ฐ์ ํ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ ์
๋ฐ์ดํธ
|
| 1750 |
fn=generate_realtime_preview,
|
|
|
|
| 557 |
|
| 558 |
# ์
๋ฐ์ดํธ๋ ํ๋กํ ์ ์ฅ
|
| 559 |
adjusted_persona["์ฑ๊ฒฉํ๋กํ"] = profile.to_dict()
|
| 560 |
+
|
| 561 |
+
# ๐ ๋ณ๊ฒฝ๋ ๋ณ์ ๊ฐ ๊ธฐ๋ฐ์ผ๋ก AI๊ฐ ์๋ก์ด ๋งค๋ ฅ์ ๊ฒฐํจ๊ณผ ๋ชจ์์ ํน์ฑ ์์ฑ
|
| 562 |
+
try:
|
| 563 |
+
global persona_generator
|
| 564 |
+
if persona_generator and hasattr(persona_generator, 'api_key') and persona_generator.api_key:
|
| 565 |
+
# ์ฌ๋ฌผ ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
|
| 566 |
+
object_analysis = {
|
| 567 |
+
"object_type": adjusted_persona.get("๊ธฐ๋ณธ์ ๋ณด", {}).get("์ ํ", "์ฌ๋ฌผ"),
|
| 568 |
+
"material": adjusted_persona.get("๊ธฐ๋ณธ์ ๋ณด", {}).get("์ฌ์ง", "์ ์ ์๋ ์ฌ์ง"),
|
| 569 |
+
"description": adjusted_persona.get("๊ธฐ๋ณธ์ ๋ณด", {}).get("์ค๋ช
", "")
|
| 570 |
+
}
|
| 571 |
+
|
| 572 |
+
# AI ๊ธฐ๋ฐ ๋งค๋ ฅ์ ๊ฒฐํจ ์์ฑ (๋ณ๊ฒฝ๋ ์ฑ๊ฒฉ ๋ณ์ ๋ฐ์)
|
| 573 |
+
new_flaws = persona_generator.generate_attractive_flaws(
|
| 574 |
+
object_analysis,
|
| 575 |
+
adjusted_persona["์ฑ๊ฒฉํน์ฑ"]
|
| 576 |
+
)
|
| 577 |
+
|
| 578 |
+
# AI ๊ธฐ๋ฐ ๋ชจ์์ ํน์ฑ ์์ฑ (๋ณ๊ฒฝ๋ ์ฑ๊ฒฉ ๋ณ์ ๋ฐ์)
|
| 579 |
+
new_contradictions = persona_generator.generate_contradictions(
|
| 580 |
+
object_analysis,
|
| 581 |
+
adjusted_persona["์ฑ๊ฒฉํน์ฑ"]
|
| 582 |
+
)
|
| 583 |
+
|
| 584 |
+
# ์
๋ฐ์ดํธ
|
| 585 |
+
if new_flaws:
|
| 586 |
+
adjusted_persona["๋งค๋ ฅ์ ๊ฒฐํจ"] = new_flaws
|
| 587 |
+
if new_contradictions:
|
| 588 |
+
adjusted_persona["๋ชจ์์ ํน์ฑ"] = new_contradictions
|
| 589 |
+
|
| 590 |
+
print(f"๐ญ AI๊ฐ ์๋ก์ด ์ฑ๊ฒฉ์ ๋ง๋ ๊ฒฐํจ/๋ชจ์ ์์ฑ: {len(new_flaws)}๊ฐ ๊ฒฐํจ, {len(new_contradictions)}๊ฐ ๋ชจ์")
|
| 591 |
+
|
| 592 |
+
except Exception as ai_error:
|
| 593 |
+
print(f"โ ๏ธ AI ๊ฒฐํจ/๋ชจ์ ์์ฑ ์คํจ: {ai_error}")
|
| 594 |
+
# ์คํจํด๋ ๊ธฐ๋ณธ ์กฐ์ ์ ๊ณ์ ์งํ
|
| 595 |
|
| 596 |
# ์กฐ์ ๋ ๋ณ์๋ค์ DataFrame์ผ๋ก ์์ฑ
|
| 597 |
variables_df = []
|
|
|
|
| 672 |
# ๋ณํ๋ ๋ถ์ ์์ฑ
|
| 673 |
change_analysis = show_variable_changes(original_persona, adjusted_persona)
|
| 674 |
|
| 675 |
+
# ๋ณํ๋ ๋งค๋ ฅ์ ๊ฒฐํจ๊ณผ ๋ชจ์์ ํน์ฑ ๋ถ์
|
| 676 |
+
flaws_changed = len(adjusted_persona.get("๋งค๋ ฅ์ ๊ฒฐํจ", [])) != len(original_persona.get("๋งค๋ ฅ์ ๊ฒฐํจ", []))
|
| 677 |
+
contradictions_changed = len(adjusted_persona.get("๋ชจ์์ ํน์ฑ", [])) != len(original_persona.get("๋ชจ์์ ํน์ฑ", []))
|
| 678 |
+
|
| 679 |
+
additional_changes = ""
|
| 680 |
+
if flaws_changed or contradictions_changed:
|
| 681 |
+
additional_changes = "\n\n๐ญ **AI๊ฐ ์๋ก ์์ฑํ ๋ด์ฉ:**\n"
|
| 682 |
+
if flaws_changed:
|
| 683 |
+
new_flaws = adjusted_persona.get("๋งค๋ ฅ์ ๊ฒฐํจ", [])
|
| 684 |
+
additional_changes += f"โข ๋งค๋ ฅ์ ๊ฒฐํจ: {len(new_flaws)}๊ฐ ์๋ก ์์ฑ๋จ\n"
|
| 685 |
+
for i, flaw in enumerate(new_flaws[:2], 1): # ์ฒ์ 2๊ฐ๋ง ๋ฏธ๋ฆฌ๋ณด๊ธฐ
|
| 686 |
+
additional_changes += f" {i}. {flaw}\n"
|
| 687 |
+
if len(new_flaws) > 2:
|
| 688 |
+
additional_changes += f" ... ์ธ {len(new_flaws) - 2}๊ฐ\n"
|
| 689 |
+
|
| 690 |
+
if contradictions_changed:
|
| 691 |
+
new_contradictions = adjusted_persona.get("๋ชจ์์ ํน์ฑ", [])
|
| 692 |
+
additional_changes += f"โข ๋ชจ์์ ํน์ฑ: {len(new_contradictions)}๊ฐ ์๋ก ์์ฑ๋จ\n"
|
| 693 |
+
for i, contradiction in enumerate(new_contradictions, 1):
|
| 694 |
+
additional_changes += f" {i}. {contradiction}\n"
|
| 695 |
+
|
| 696 |
adjustment_message = f"""
|
| 697 |
### ๐ญ {persona_name}์ ์ฑ๊ฒฉ์ด ์กฐ์ ๋์์ต๋๋ค!
|
| 698 |
|
|
|
|
| 705 |
|
| 706 |
๐งฌ **๋ฐฑ๊ทธ๋ผ์ด๋**: 152๊ฐ ์ธ๋ถ ๋ณ์๊ฐ ์ด ์ค์ ์ ๋ง์ถฐ ์๋ ์กฐ์ ๋์์ต๋๋ค.
|
| 707 |
|
| 708 |
+
{change_analysis}{additional_changes}
|
| 709 |
"""
|
| 710 |
|
| 711 |
+
# ์กฐ์ ๋ ๋งค๋ ฅ์ ๊ฒฐํจ๊ณผ ๋ชจ์์ ํน์ฑ์ DataFrame์ผ๋ก ์์ฑ
|
| 712 |
+
flaws_df = []
|
| 713 |
+
if "๋งค๋ ฅ์ ๊ฒฐํจ" in adjusted_persona:
|
| 714 |
+
flaws = adjusted_persona["๋งค๋ ฅ์ ๊ฒฐํจ"]
|
| 715 |
+
for i, flaw in enumerate(flaws, 1):
|
| 716 |
+
# ์ฌ๋ฌผ ํน์ฑ vs ์ฑ๊ฒฉ์ ํน์ฑ ๊ตฌ๋ถ
|
| 717 |
+
if any(keyword in flaw for keyword in ["๋จผ์ง", "ํ๋ณ", "์์ด", "์ถฉ๊ฒฉ", "์ต๋", "๋์", "๋ชจ์๋ฆฌ", "๋ฌด๊ฒ", "ํฌ๊ธฐ"]):
|
| 718 |
+
flaw_type = "์ฌ๋ฌผ ํน์ฑ ๊ธฐ๋ฐ"
|
| 719 |
+
else:
|
| 720 |
+
flaw_type = "์ฑ๊ฒฉ์ ํน์ฑ"
|
| 721 |
+
flaws_df.append([f"{i}. {flaw}", flaw_type])
|
| 722 |
+
|
| 723 |
+
contradictions_df = []
|
| 724 |
+
if "๋ชจ์์ ํน์ฑ" in adjusted_persona:
|
| 725 |
+
contradictions = adjusted_persona["๋ชจ์์ ํน์ฑ"]
|
| 726 |
+
for i, contradiction in enumerate(contradictions, 1):
|
| 727 |
+
contradictions_df.append([f"{i}. {contradiction}", "๋ณตํฉ์ ๋งค๋ ฅ"])
|
| 728 |
+
|
| 729 |
+
return adjusted_persona, adjustment_message, adjusted_info, variables_df, flaws_df, contradictions_df
|
| 730 |
|
| 731 |
except Exception as e:
|
| 732 |
import traceback
|
| 733 |
traceback.print_exc()
|
| 734 |
+
return persona, f"์กฐ์ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}", {}, [], [], []
|
| 735 |
|
| 736 |
def finalize_persona(persona):
|
| 737 |
"""ํ๋ฅด์๋ ์ต์ข
ํ์ - ํ๊ฒฝ๋ณ์ API ์ค์ ์ฌ์ฉ"""
|
|
|
|
| 1818 |
adjust_btn.click(
|
| 1819 |
fn=adjust_persona_traits,
|
| 1820 |
inputs=[current_persona, warmth_slider, competence_slider, extraversion_slider, humor_style_radio],
|
| 1821 |
+
outputs=[current_persona, adjustment_result, adjusted_info_output, personality_variables_output, attractive_flaws_output, contradictions_output]
|
| 1822 |
).then(
|
| 1823 |
# ๋ฐ์ ํ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๋ ์
๋ฐ์ดํธ
|
| 1824 |
fn=generate_realtime_preview,
|