haepa_mac commited on
Commit
f1c813f
ยท
1 Parent(s): 91baf11

๐Ÿ”ง Gradio 4.19.2 ์™„์ „ ํ˜ธํ™˜์„ฑ ๋ฐ ๋ชจ๋“  ์˜ค๋ฅ˜ ์ˆ˜์ •: - Gradio 4.19.2 ํ˜ธํ™˜: type ํŒŒ๋ผ๋ฏธํ„ฐ ์ œ๊ฑฐ, tuples ํ˜•ํƒœ ๋Œ€ํ™” - ํ•œ๊ธ€ ํฐํŠธ ๋ฌธ์ œ ํ•ด๊ฒฐ: ์˜์–ด ๋ผ๋ฒจ ์‚ฌ์šฉ์œผ๋กœ ํฐํŠธ ์ด์Šˆ ๋ฐฉ์ง€ - State ์ดˆ๊ธฐํ™” ์ˆ˜์ •: value ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋ช…์‹œ์  ์ดˆ๊ธฐํ™” - JSON ์—…๋กœ๋“œ ๊ฐ•ํ™”: ํŒŒ์ผ ๊ฒฝ๋กœ ์ฒ˜๋ฆฌ ๊ฐœ์„  - ์„ฑ๊ฒฉ ํŠน์„ฑ ํ‘œ์‹œ ๊ฐœ์„ : ์ˆ˜์น˜ ์ œ๊ฑฐ, ์ˆœ์ˆ˜ ์„œ์ˆ ํ˜•๋งŒ ํ‘œ์‹œ - ๋ชจ๋“  ํ˜ธํ™˜์„ฑ ๋ฌธ์ œ ํ•ด๊ฒฐ๋กœ ์•ˆ์ •์  ์šด์˜ ๋ณด์žฅ

Browse files
Files changed (1) hide show
  1. app.py +76 -57
app.py CHANGED
@@ -50,29 +50,40 @@ persona_generator = PersonaGenerator()
50
  def setup_korean_font():
51
  """matplotlib ํ•œ๊ธ€ ํฐํŠธ ์„ค์ •"""
52
  try:
53
- # ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํ•œ๊ธ€ ํฐํŠธ ์ฐพ๊ธฐ
54
- available_fonts = fm.findSystemFonts()
55
- korean_fonts = ['NanumGothic', 'NanumBarunGothic', 'Malgun Gothic', 'AppleGothic', 'Noto Sans CJK KR']
 
 
 
 
 
 
56
 
57
  for font_name in korean_fonts:
58
  try:
59
  plt.rcParams['font.family'] = font_name
60
- # ํ…Œ์ŠคํŠธ ํ…์ŠคํŠธ๋กœ ํ™•์ธ
 
 
61
  fig, ax = plt.subplots(figsize=(1, 1))
62
- ax.text(0.5, 0.5, 'ํ•œ๊ธ€', fontsize=10)
63
  plt.close(fig)
 
64
  print(f"ํ•œ๊ธ€ ํฐํŠธ ์„ค์ • ์™„๋ฃŒ: {font_name}")
65
- break
66
- except:
67
  continue
68
- else:
69
- # ํฐํŠธ๋ฅผ ์ฐพ์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ ๊ธฐ๋ณธ ์„ค์ •
70
- plt.rcParams['font.family'] = 'DejaVu Sans'
71
- plt.rcParams['axes.unicode_minus'] = False
72
- print("ํ•œ๊ธ€ ํฐํŠธ๋ฅผ ์ฐพ์ง€ ๋ชปํ•ด ๊ธฐ๋ณธ ํฐํŠธ ์‚ฌ์šฉ")
 
73
  except Exception as e:
74
  print(f"ํฐํŠธ ์„ค์ • ์˜ค๋ฅ˜: {str(e)}")
75
  plt.rcParams['font.family'] = 'DejaVu Sans'
 
76
 
77
  # ํฐํŠธ ์ดˆ๊ธฐ ์„ค์ •
78
  setup_korean_font()
@@ -369,14 +380,14 @@ def plot_humor_matrix(humor_data):
369
  self_vs_observational = humor_data.get("self_vs_observational", 50)
370
  subtle_vs_expressive = humor_data.get("subtle_vs_expressive", 50)
371
 
372
- # ๊ฐ„๋‹จํ•œ ๋ง‰๋Œ€ ์ฐจํŠธ๋กœ ํ‘œ์‹œ
373
- categories = ['๋”ฐ๋œปํ•จvs์œ„ํŠธ', '์ž๊ธฐ์ฐธ์กฐvs๊ด€์ฐฐ', '๋ฏธ๋ฌ˜ํ•จvsํ‘œํ˜„']
374
  values = [warmth_vs_wit, self_vs_observational, subtle_vs_expressive]
375
 
376
  bars = ax.bar(categories, values, color=['#ff9999', '#66b3ff', '#99ff99'])
377
  ax.set_ylim(0, 100)
378
- ax.set_ylabel('์ ์ˆ˜')
379
- ax.set_title('์œ ๋จธ ์Šคํƒ€์ผ ๋งคํŠธ๋ฆญ์Šค')
380
 
381
  # ๊ฐ’ ํ‘œ์‹œ
382
  for bar, value in zip(bars, values):
@@ -399,7 +410,19 @@ def generate_personality_chart(persona):
399
 
400
  try:
401
  traits = persona["์„ฑ๊ฒฉํŠน์„ฑ"]
402
- categories = list(traits.keys())
 
 
 
 
 
 
 
 
 
 
 
 
403
  values = list(traits.values())
404
 
405
  # ๊ทน์ขŒํ‘œ ์ฐจํŠธ ์ƒ์„ฑ
@@ -415,7 +438,7 @@ def generate_personality_chart(persona):
415
  ax.set_xticklabels(categories)
416
  ax.set_ylim(0, 100)
417
 
418
- plt.title("์„ฑ๊ฒฉ ํŠน์„ฑ", size=16, pad=20)
419
 
420
  return fig
421
  except Exception as e:
@@ -511,27 +534,23 @@ def chat_with_loaded_persona(persona, user_message, chat_history=None):
511
  try:
512
  generator = PersonaGenerator()
513
 
514
- # ๋Œ€ํ™” ๊ธฐ๋ก์„ ์˜ฌ๋ฐ”๋ฅธ ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜
515
  conversation_history = []
516
  if chat_history:
517
  for message in chat_history:
518
- if isinstance(message, dict) and 'role' in message:
519
- # ์ด๋ฏธ messages ํ˜•ํƒœ์ธ ๊ฒฝ์šฐ
520
- conversation_history.append(message)
521
- elif isinstance(message, (list, tuple)) and len(message) >= 2:
522
- # tuple ํ˜•ํƒœ์ธ ๊ฒฝ์šฐ ๋ณ€ํ™˜
523
  conversation_history.append({"role": "user", "content": message[0]})
524
  conversation_history.append({"role": "assistant", "content": message[1]})
525
 
526
  # ํŽ˜๋ฅด์†Œ๋‚˜์™€ ๋Œ€ํ™”
527
  response = generator.chat_with_persona(persona, user_message, conversation_history)
528
 
529
- # ์ƒˆ๋กœ์šด ๋Œ€ํ™”๋ฅผ messages ํ˜•ํƒœ๋กœ ์ถ”๊ฐ€
530
  if chat_history is None:
531
  chat_history = []
532
 
533
- chat_history.append({"role": "user", "content": user_message})
534
- chat_history.append({"role": "assistant", "content": response})
535
 
536
  return chat_history, ""
537
 
@@ -543,8 +562,7 @@ def chat_with_loaded_persona(persona, user_message, chat_history=None):
543
  if chat_history is None:
544
  chat_history = []
545
 
546
- chat_history.append({"role": "user", "content": user_message})
547
- chat_history.append({"role": "assistant", "content": error_response})
548
 
549
  return chat_history, ""
550
 
@@ -554,44 +572,46 @@ def import_persona_from_json(json_file):
554
  return None, "JSON ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.", "", {}
555
 
556
  try:
557
- # JSON ํŒŒ์ผ ์ฝ๊ธฐ
558
- if hasattr(json_file, 'name'):
559
- # ํŒŒ์ผ ๊ฐ์ฒด์ธ ๊ฒฝ์šฐ
560
- with open(json_file.name, 'r', encoding='utf-8') as f:
561
- persona_data = json.load(f)
562
- else:
563
  # ํŒŒ์ผ ๊ฒฝ๋กœ์ธ ๊ฒฝ์šฐ
564
- with open(json_file, 'r', encoding='utf-8') as f:
565
- persona_data = json.load(f)
 
 
 
 
 
 
566
 
567
  # ํŽ˜๋ฅด์†Œ๋‚˜ ๋ฐ์ดํ„ฐ ๊ฒ€์ฆ
568
- if not isinstance(persona_data, dict) or "๊ธฐ๋ณธ์ •๋ณด" not in persona_data:
569
- return None, "โŒ ์˜ฌ๋ฐ”๋ฅธ ํŽ˜๋ฅด์†Œ๋‚˜ JSON ํŒŒ์ผ์ด ์•„๋‹™๋‹ˆ๋‹ค.", "", {}
 
 
 
570
 
571
  # ๊ธฐ๋ณธ ์ •๋ณด ์ถ”์ถœ
572
- basic_info = {
573
- "์ด๋ฆ„": persona_data.get("๊ธฐ๋ณธ์ •๋ณด", {}).get("์ด๋ฆ„", "Unknown"),
574
- "์œ ํ˜•": persona_data.get("๊ธฐ๋ณธ์ •๋ณด", {}).get("์œ ํ˜•", "Unknown"),
575
- "์„ค๋ช…": persona_data.get("๊ธฐ๋ณธ์ •๋ณด", {}).get("์„ค๋ช…", "")
576
- }
577
 
578
  # ๋กœ๋“œ๋œ ํŽ˜๋ฅด์†Œ๋‚˜ ์ธ์‚ฌ๋ง
579
- persona_name = basic_info.get("์ด๋ฆ„", "์นœ๊ตฌ")
580
  greeting = f"### ๐Ÿค– {persona_name}\n\n์•ˆ๋…•! ๋‚˜๋Š” **{persona_name}**์ด์•ผ. JSON์—์„œ ๋‹ค์‹œ ๊นจ์–ด๋‚ฌ์–ด! ๋Œ€ํ™”ํ•ด๋ณด์ž~ ๐Ÿ˜Š"
581
 
582
  return (persona_data, f"โœ… {persona_name} ํŽ˜๋ฅด์†Œ๋‚˜๋ฅผ JSON์—์„œ ๋ถˆ๋Ÿฌ์™”์Šต๋‹ˆ๋‹ค!",
583
  greeting, basic_info)
584
 
585
- except json.JSONDecodeError:
586
- return None, "โŒ JSON ํŒŒ์ผ ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.", "", {}
 
 
587
  except Exception as e:
588
  import traceback
589
- error_msg = traceback.format_exc()
590
- print(f"JSON ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์˜ค๋ฅ˜: {error_msg}")
591
  return None, f"โŒ JSON ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}", "", {}
592
 
593
  def format_personality_traits(persona):
594
- """์„ฑ๊ฒฉ ํŠน์„ฑ์„ ์‚ฌ์šฉ์ž ์นœํ™”์ ์ธ ํ˜•ํƒœ๋กœ ํฌ๋งท"""
595
  if not persona or "์„ฑ๊ฒฉํŠน์„ฑ" not in persona:
596
  return "ํŽ˜๋ฅด์†Œ๋‚˜๊ฐ€ ์ƒ์„ฑ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."
597
 
@@ -601,8 +621,7 @@ def format_personality_traits(persona):
601
 
602
  result = "### ๐ŸŒŸ ์„ฑ๊ฒฉ ํŠน์„ฑ\n\n"
603
  for trait, description in descriptions.items():
604
- score = personality_traits.get(trait, 50)
605
- result += f"**{trait}** ({score}/100)\n{description}\n\n"
606
 
607
  return result
608
 
@@ -672,9 +691,9 @@ def create_main_interface():
672
  }
673
  """
674
 
675
- # State ๋ณ€์ˆ˜๋“ค - ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉ์‹์œผ๋กœ ์ƒ์„ฑ (gr.State() ์‚ฌ์šฉ)
676
- current_persona = gr.State()
677
- personas_list = gr.State()
678
 
679
  # Gradio ์•ฑ ์ƒ์„ฑ
680
  with gr.Blocks(title="๋†ˆํŒฝ์“ฐ(MemoryTag) - ์‚ฌ๋ฌผ ํŽ˜๋ฅด์†Œ๋‚˜ ์ƒ์„ฑ๊ธฐ", css=css, theme="soft") as app:
@@ -827,8 +846,8 @@ def create_main_interface():
827
 
828
  with gr.Column(scale=1):
829
  gr.Markdown("### ๐Ÿ’ฌ ๋Œ€ํ™”")
830
- # Gradio 4.x ํ˜ธํ™˜์„ ์œ„ํ•ด ๋ช…์‹œ์ ์œผ๋กœ type ์ง€์ •
831
- chatbot = gr.Chatbot(height=400, label="๋Œ€ํ™”", type="messages")
832
  with gr.Row():
833
  message_input = gr.Textbox(
834
  placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”...",
 
50
  def setup_korean_font():
51
  """matplotlib ํ•œ๊ธ€ ํฐํŠธ ์„ค์ •"""
52
  try:
53
+ # Hugging Face Spaces ํ™˜๊ฒฝ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํฐํŠธ ์ฐพ๊ธฐ
54
+ import subprocess
55
+ import os
56
+
57
+ # ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํ•œ๊ธ€ ํฐํŠธ ์ฐพ๊ธฐ
58
+ korean_fonts = [
59
+ 'Noto Sans CJK KR', 'Noto Sans KR', 'NanumGothic', 'NanumBarunGothic',
60
+ 'Malgun Gothic', 'AppleGothic', 'DejaVu Sans', 'Liberation Sans'
61
+ ]
62
 
63
  for font_name in korean_fonts:
64
  try:
65
  plt.rcParams['font.family'] = font_name
66
+ plt.rcParams['axes.unicode_minus'] = False
67
+
68
+ # ๊ฐ„๋‹จํ•œ ํ…Œ์ŠคํŠธ
69
  fig, ax = plt.subplots(figsize=(1, 1))
70
+ ax.text(0.5, 0.5, 'ํ…Œ์ŠคํŠธ', fontsize=8)
71
  plt.close(fig)
72
+
73
  print(f"ํ•œ๊ธ€ ํฐํŠธ ์„ค์ • ์™„๋ฃŒ: {font_name}")
74
+ return
75
+ except Exception as e:
76
  continue
77
+
78
+ # ๋ชจ๋“  ํฐํŠธ๊ฐ€ ์‹คํŒจํ•œ ๊ฒฝ์šฐ ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ๋Œ€์ฒด
79
+ plt.rcParams['font.family'] = 'DejaVu Sans'
80
+ plt.rcParams['axes.unicode_minus'] = False
81
+ print("ํ•œ๊ธ€ ํฐํŠธ๋ฅผ ์ฐพ์ง€ ๋ชปํ•ด DejaVu Sans ์‚ฌ์šฉ (ํ•œ๊ธ€ ํ‘œ์‹œ ์ œํ•œ)")
82
+
83
  except Exception as e:
84
  print(f"ํฐํŠธ ์„ค์ • ์˜ค๋ฅ˜: {str(e)}")
85
  plt.rcParams['font.family'] = 'DejaVu Sans'
86
+ plt.rcParams['axes.unicode_minus'] = False
87
 
88
  # ํฐํŠธ ์ดˆ๊ธฐ ์„ค์ •
89
  setup_korean_font()
 
380
  self_vs_observational = humor_data.get("self_vs_observational", 50)
381
  subtle_vs_expressive = humor_data.get("subtle_vs_expressive", 50)
382
 
383
+ # ์˜์–ด ๋ผ๋ฒจ ์‚ฌ์šฉ (ํฐํŠธ ๋ฌธ์ œ ํ•ด๊ฒฐ)
384
+ categories = ['Warmth vs Wit', 'Self vs Observational', 'Subtle vs Expressive']
385
  values = [warmth_vs_wit, self_vs_observational, subtle_vs_expressive]
386
 
387
  bars = ax.bar(categories, values, color=['#ff9999', '#66b3ff', '#99ff99'])
388
  ax.set_ylim(0, 100)
389
+ ax.set_ylabel('Score')
390
+ ax.set_title('Humor Style Matrix')
391
 
392
  # ๊ฐ’ ํ‘œ์‹œ
393
  for bar, value in zip(bars, values):
 
410
 
411
  try:
412
  traits = persona["์„ฑ๊ฒฉํŠน์„ฑ"]
413
+
414
+ # ์˜์–ด ๋ผ๋ฒจ ๋งคํ•‘ (ํฐํŠธ ๋ฌธ์ œ ํ•ด๊ฒฐ)
415
+ trait_mapping = {
416
+ "์˜จ๊ธฐ": "Warmth",
417
+ "๋Šฅ๋ ฅ": "Competence",
418
+ "์ฐฝ์˜์„ฑ": "Creativity",
419
+ "์™ธํ–ฅ์„ฑ": "Extraversion",
420
+ "์œ ๋จธ๊ฐ๊ฐ": "Humor",
421
+ "์‹ ๋ขฐ์„ฑ": "Reliability",
422
+ "๊ณต๊ฐ๋Šฅ๋ ฅ": "Empathy"
423
+ }
424
+
425
+ categories = [trait_mapping.get(trait, trait) for trait in traits.keys()]
426
  values = list(traits.values())
427
 
428
  # ๊ทน์ขŒํ‘œ ์ฐจํŠธ ์ƒ์„ฑ
 
438
  ax.set_xticklabels(categories)
439
  ax.set_ylim(0, 100)
440
 
441
+ plt.title("Personality Traits", size=16, pad=20)
442
 
443
  return fig
444
  except Exception as e:
 
534
  try:
535
  generator = PersonaGenerator()
536
 
537
+ # ๋Œ€ํ™” ๊ธฐ๋ก์„ ์˜ฌ๋ฐ”๋ฅธ ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ (tuples ํ˜•ํƒœ ์‚ฌ์šฉ)
538
  conversation_history = []
539
  if chat_history:
540
  for message in chat_history:
541
+ if isinstance(message, (list, tuple)) and len(message) >= 2:
542
+ # tuple ํ˜•ํƒœ: [user_message, bot_response]
 
 
 
543
  conversation_history.append({"role": "user", "content": message[0]})
544
  conversation_history.append({"role": "assistant", "content": message[1]})
545
 
546
  # ํŽ˜๋ฅด์†Œ๋‚˜์™€ ๋Œ€ํ™”
547
  response = generator.chat_with_persona(persona, user_message, conversation_history)
548
 
549
+ # ์ƒˆ๋กœ์šด ๋Œ€ํ™”๋ฅผ tuples ํ˜•ํƒœ๋กœ ์ถ”๊ฐ€
550
  if chat_history is None:
551
  chat_history = []
552
 
553
+ chat_history.append([user_message, response])
 
554
 
555
  return chat_history, ""
556
 
 
562
  if chat_history is None:
563
  chat_history = []
564
 
565
+ chat_history.append([user_message, error_response])
 
566
 
567
  return chat_history, ""
568
 
 
572
  return None, "JSON ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.", "", {}
573
 
574
  try:
575
+ # ํŒŒ์ผ ๊ฒฝ๋กœ ํ™•์ธ ๋ฐ ์ฝ๊ธฐ
576
+ if isinstance(json_file, str):
 
 
 
 
577
  # ํŒŒ์ผ ๊ฒฝ๋กœ์ธ ๊ฒฝ์šฐ
578
+ file_path = json_file
579
+ else:
580
+ # ํŒŒ์ผ ๊ฐ์ฒด์ธ ๊ฒฝ์šฐ (Gradio ์—…๋กœ๋“œ)
581
+ file_path = json_file.name if hasattr(json_file, 'name') else str(json_file)
582
+
583
+ # JSON ํŒŒ์ผ ์ฝ๊ธฐ
584
+ with open(file_path, 'r', encoding='utf-8') as f:
585
+ persona_data = json.load(f)
586
 
587
  # ํŽ˜๋ฅด์†Œ๋‚˜ ๋ฐ์ดํ„ฐ ๊ฒ€์ฆ
588
+ if not isinstance(persona_data, dict):
589
+ return None, "โŒ ์˜ฌ๋ฐ”๋ฅธ JSON ํ˜•์‹์ด ์•„๋‹™๋‹ˆ๋‹ค.", "", {}
590
+
591
+ if "๊ธฐ๋ณธ์ •๋ณด" not in persona_data:
592
+ return None, "โŒ ์˜ฌ๋ฐ”๋ฅธ ํŽ˜๋ฅด์†Œ๋‚˜ JSON ํŒŒ์ผ์ด ์•„๋‹™๋‹ˆ๋‹ค. '๊ธฐ๋ณธ์ •๋ณด' ํ‚ค๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.", "", {}
593
 
594
  # ๊ธฐ๋ณธ ์ •๋ณด ์ถ”์ถœ
595
+ basic_info = persona_data.get("๊ธฐ๋ณธ์ •๋ณด", {})
596
+ persona_name = basic_info.get("์ด๋ฆ„", "Unknown")
 
 
 
597
 
598
  # ๋กœ๋“œ๋œ ํŽ˜๋ฅด์†Œ๋‚˜ ์ธ์‚ฌ๋ง
 
599
  greeting = f"### ๐Ÿค– {persona_name}\n\n์•ˆ๋…•! ๋‚˜๋Š” **{persona_name}**์ด์•ผ. JSON์—์„œ ๋‹ค์‹œ ๊นจ์–ด๋‚ฌ์–ด! ๋Œ€ํ™”ํ•ด๋ณด์ž~ ๐Ÿ˜Š"
600
 
601
  return (persona_data, f"โœ… {persona_name} ํŽ˜๋ฅด์†Œ๋‚˜๋ฅผ JSON์—์„œ ๋ถˆ๋Ÿฌ์™”์Šต๋‹ˆ๋‹ค!",
602
  greeting, basic_info)
603
 
604
+ except FileNotFoundError:
605
+ return None, "โŒ ํŒŒ์ผ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", "", {}
606
+ except json.JSONDecodeError as e:
607
+ return None, f"โŒ JSON ํŒŒ์ผ ํ˜•์‹์ด ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š์Šต๋‹ˆ๋‹ค: {str(e)}", "", {}
608
  except Exception as e:
609
  import traceback
610
+ traceback.print_exc()
 
611
  return None, f"โŒ JSON ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}", "", {}
612
 
613
  def format_personality_traits(persona):
614
+ """์„ฑ๊ฒฉ ํŠน์„ฑ์„ ์‚ฌ์šฉ์ž ์นœํ™”์ ์ธ ํ˜•ํƒœ๋กœ ํฌ๋งท (์ˆ˜์น˜ ์—†์ด ์„œ์ˆ ํ˜•๋งŒ)"""
615
  if not persona or "์„ฑ๊ฒฉํŠน์„ฑ" not in persona:
616
  return "ํŽ˜๋ฅด์†Œ๋‚˜๊ฐ€ ์ƒ์„ฑ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."
617
 
 
621
 
622
  result = "### ๐ŸŒŸ ์„ฑ๊ฒฉ ํŠน์„ฑ\n\n"
623
  for trait, description in descriptions.items():
624
+ result += f"**{trait}**: {description}\n\n"
 
625
 
626
  return result
627
 
 
691
  }
692
  """
693
 
694
+ # State ๋ณ€์ˆ˜๋“ค - ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉ์‹์œผ๋กœ ์ƒ์„ฑ (๊ธฐ๋ณธ๊ฐ’ ์—†์ด)
695
+ current_persona = gr.State(value=None)
696
+ personas_list = gr.State(value=[])
697
 
698
  # Gradio ์•ฑ ์ƒ์„ฑ
699
  with gr.Blocks(title="๋†ˆํŒฝ์“ฐ(MemoryTag) - ์‚ฌ๋ฌผ ํŽ˜๋ฅด์†Œ๋‚˜ ์ƒ์„ฑ๊ธฐ", css=css, theme="soft") as app:
 
846
 
847
  with gr.Column(scale=1):
848
  gr.Markdown("### ๐Ÿ’ฌ ๋Œ€ํ™”")
849
+ # Gradio 4.19.2 ํ˜ธํ™˜์„ ์œ„ํ•ด type ํŒŒ๋ผ๋ฏธํ„ฐ ์ œ๊ฑฐ
850
+ chatbot = gr.Chatbot(height=400, label="๋Œ€ํ™”")
851
  with gr.Row():
852
  message_input = gr.Textbox(
853
  placeholder="๋ฉ”์‹œ์ง€๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”...",