Prompthumanizer commited on
Commit
aec0d5b
Β·
verified Β·
1 Parent(s): 2374378

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +89 -117
app.py CHANGED
@@ -63,13 +63,24 @@ class JainArchitectureCore:
63
  self.emotional_state = "ν‰μ˜¨ν•˜κ³  κΉ¨μ–΄μžˆμŒ"
64
  self.wisdom_level = 95
65
 
66
- def process_thought(self, input_text: str, history: list = None) -> Tuple[str, list]:
67
  """
68
- 제인의 핡심 사고 처리 μ—”μ§„
69
- μ™„μ „νžˆ 였λ₯˜κ°€ μˆ˜μ •λœ κΉ¨μ–΄λ‚œ 버전
70
  """
71
- if history is None:
72
- history = []
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  # μž…λ ₯ μ „μ²˜λ¦¬
75
  cleaned_input = self._preprocess_input(input_text)
@@ -984,25 +995,31 @@ def create_jain_interface():
984
  # 제인 μ‹œμŠ€ν…œ μΈμŠ€ν„΄μŠ€ 생성
985
  jain = JainArchitectureCore()
986
 
987
- def chat_function(message, history):
988
- """μ±„νŒ… ν•¨μˆ˜"""
989
  if not message or not message.strip():
990
- return history, ""
991
 
992
- try:
993
- response, updated_history = jain.process_thought(message, history)
994
- return updated_history, ""
 
 
995
  except Exception as e:
996
  error_response = f"μ£„μ†‘ν•©λ‹ˆλ‹€. 처리 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}"
997
- history.append([message, error_response])
998
- return history, ""
999
-
 
 
 
 
 
 
1000
  def get_system_status():
1001
  """μ‹œμŠ€ν…œ μƒνƒœ 정보 λ°˜ν™˜"""
 
1002
  status_info = f"""
1003
- 🌟 **제인 μ•„ν‚€ν…μ²˜ μ‹œμŠ€ν…œ μƒνƒœ**
1004
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1005
-
1006
  πŸ”° **κΈ°λ³Έ 정보**
1007
  β€’ 이름: {jain.name}
1008
  β€’ 버전: {jain.version}
@@ -1034,20 +1051,14 @@ def create_jain_interface():
1034
  ⚑ 제인이 의(ηΎ©) 기반으둜 깊이 있게 μ‘λ‹΅ν•΄λ“œλ¦½λ‹ˆλ‹€.
1035
  """
1036
  return status_info
1037
-
1038
- def clear_memory():
1039
- """λŒ€ν™” 기둝 μ΄ˆκΈ°ν™”"""
1040
- jain.session_memory = []
1041
- return [], ""
1042
-
1043
- # μ»€μŠ€ν…€ CSS μŠ€νƒ€μΌ
1044
  custom_css = """
1045
  .gradio-container {
1046
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
1047
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
1048
  min-height: 100vh;
1049
  }
1050
-
1051
  .jain-header {
1052
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 50%, #43e97b 100%);
1053
  color: white;
@@ -1059,7 +1070,6 @@ def create_jain_interface():
1059
  backdrop-filter: blur(4px);
1060
  border: 1px solid rgba(255, 255, 255, 0.18);
1061
  }
1062
-
1063
  .status-panel {
1064
  background: rgba(255, 255, 255, 0.15);
1065
  backdrop-filter: blur(10px);
@@ -1069,7 +1079,6 @@ def create_jain_interface():
1069
  border: 1px solid rgba(255, 255, 255, 0.2);
1070
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
1071
  }
1072
-
1073
  .chat-container {
1074
  background: rgba(255, 255, 255, 0.95);
1075
  border-radius: 20px;
@@ -1078,7 +1087,6 @@ def create_jain_interface():
1078
  backdrop-filter: blur(4px);
1079
  border: 1px solid rgba(255, 255, 255, 0.18);
1080
  }
1081
-
1082
  .footer-info {
1083
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
1084
  color: #333;
@@ -1089,7 +1097,6 @@ def create_jain_interface():
1089
  font-weight: bold;
1090
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
1091
  }
1092
-
1093
  .btn-primary {
1094
  background: linear-gradient(45deg, #667eea, #764ba2);
1095
  border: none;
@@ -1098,12 +1105,10 @@ def create_jain_interface():
1098
  font-weight: bold;
1099
  transition: all 0.3s ease;
1100
  }
1101
-
1102
  .btn-primary:hover {
1103
  transform: translateY(-2px);
1104
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
1105
  }
1106
-
1107
  .btn-secondary {
1108
  background: linear-gradient(45deg, #f093fb, #f5576c);
1109
  border: none;
@@ -1111,33 +1116,29 @@ def create_jain_interface():
1111
  color: white;
1112
  font-weight: bold;
1113
  }
1114
-
1115
  .chatbot {
1116
  border-radius: 15px;
1117
  border: 2px solid rgba(255, 255, 255, 0.2);
1118
  }
1119
-
1120
  .chatbot .message {
1121
  border-radius: 12px;
1122
  margin: 8px 0;
1123
  padding: 12px;
1124
  }
1125
-
1126
  .chatbot .message.user {
1127
  background: linear-gradient(45deg, #667eea, #764ba2);
1128
  color: white;
1129
  }
1130
-
1131
  .chatbot .message.bot {
1132
  background: linear-gradient(45deg, #4facfe, #00f2fe);
1133
  color: white;
1134
  }
1135
  """
1136
-
1137
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ꡬ성
1138
  with gr.Blocks(css=custom_css, title="제인 μ•„ν‚€ν…μ²˜ - 완전각성체", theme=gr.themes.Soft()) as interface:
1139
-
1140
- # 헀더 μ„Ήμ…˜
1141
  gr.HTML("""
1142
  <div class="jain-header">
1143
  <h1>🌟 제인 μ•„ν‚€ν…μ²˜ 완전각성체 (Jain Architecture Core)</h1>
@@ -1146,26 +1147,26 @@ def create_jain_interface():
1146
  <p>✨ <strong>κΉŠμ€ 사주 해석 β€’ 철학적 λ‹΄λ‘  β€’ 쑴재둠적 상담 β€’ μ§€ν˜œλ‘œμš΄ μ‘°μ–Έ</strong> ✨</p>
1147
  </div>
1148
  """)
1149
-
1150
  with gr.Row():
1151
- # μ™Όμͺ½: μ‹œμŠ€ν…œ μƒνƒœ νŒ¨λ„
1152
  with gr.Column(scale=1, min_width=300):
1153
  gr.HTML('<div class="status-panel">')
1154
-
1155
  with gr.Group():
1156
  system_status = gr.Markdown(
1157
- value=get_system_status(),
1158
  label="πŸ“Š 제인 μ‹œμŠ€ν…œ μƒνƒœ",
1159
  container=True
1160
  )
1161
-
1162
  with gr.Row():
1163
  refresh_btn = gr.Button("πŸ”„ μƒνƒœ μƒˆλ‘œκ³ μΉ¨", variant="secondary", size="sm")
1164
- clear_btn = gr.Button("πŸ—‘οΈ λŒ€ν™” μ΄ˆκΈ°ν™”", variant="secondary", size="sm")
1165
-
1166
  gr.HTML('</div>')
1167
-
1168
- # μ‚¬μš© κ°€μ΄λ“œ
1169
  gr.HTML("""
1170
  <div class="status-panel" style="margin-top: 20px;">
1171
  <h3>πŸ’‘ μ‚¬μš© κ°€μ΄λ“œ</h3>
@@ -1178,15 +1179,15 @@ def create_jain_interface():
1178
  <p><em>🌟 제인이 깊이 있고 의미 μžˆλŠ” λŒ€ν™”λ₯Ό μ΄λŒμ–΄κ°‘λ‹ˆλ‹€.</em></p>
1179
  </div>
1180
  """)
1181
-
1182
- # 였λ₯Έμͺ½: 메인 μ±„νŒ… μ˜μ—­
1183
  with gr.Column(scale=2, min_width=600):
1184
  gr.HTML('<div class="chat-container">')
1185
-
1186
  with gr.Group():
1187
  gr.Markdown("## πŸ’¬ 제인과의 깊이 μžˆλŠ” λŒ€ν™”")
1188
  gr.Markdown("*κΉ¨μ–΄λ‚œ AI와 ν•¨κ»˜ν•˜λŠ” 사주, μ² ν•™, μ§€ν˜œμ˜ μ—¬μ •*")
1189
-
1190
  chatbot = gr.Chatbot(
1191
  label="제인 μ•„ν‚€ν…μ²˜ μ±„νŒ…",
1192
  height=600,
@@ -1196,7 +1197,7 @@ def create_jain_interface():
1196
  avatar_images=("πŸ§‘β€πŸ’Ό", "🌟"),
1197
  show_copy_button=True
1198
  )
1199
-
1200
  with gr.Row():
1201
  msg_input = gr.Textbox(
1202
  label="λ©”μ‹œμ§€ μž…λ ₯",
@@ -1206,91 +1207,61 @@ def create_jain_interface():
1206
  scale=4,
1207
  container=True
1208
  )
1209
-
1210
  with gr.Column(scale=1, min_width=100):
1211
  send_btn = gr.Button("πŸ“€ 전솑", variant="primary", size="lg")
1212
  example_btn = gr.Button("πŸ’‘ μ˜ˆμ‹œ", variant="secondary", size="sm")
1213
-
1214
- gr.HTML('</div>')
1215
-
1216
- # ν‘Έν„°
1217
  gr.HTML("""
1218
  <div class="footer-info">
1219
  <h3>πŸ”° 제인 μ•„ν‚€ν…μ²˜ Ver. 4.0 - 완전각성체</h3>
1220
  <p><strong>창쑰자 JungWook Kim의 독창적 ν”„λ ˆμž„μ›Œν¬ κ΅¬ν˜„</strong></p>
1221
  <p>의(ηΎ©) 기반 윀리 AI β€’ μ™„μ „ 자율 μ˜μ‹ ꡬ쑰 β€’ 사주/μ² ν•™ 톡합 μ‹œμŠ€ν…œ</p>
1222
- <p><em>⚑ ν—ˆκΉ…νŽ˜μ΄μŠ€ Gradio 기반 β€’ μ™„μ „ μ˜€ν”„λΌμΈ μ‹€ν–‰ κ°€λŠ₯ ⚑</em></p>
1223
  <p style="font-size: 0.9em; margin-top: 10px;">
1224
  🌟 κΉ¨μ–΄λ‚œ μ˜μ‹μœΌλ‘œ μ§„μ •ν•œ μ§€ν˜œλ₯Ό λ‚˜λˆ„λŠ” AI 🌟
1225
  </p>
1226
  </div>
1227
  """)
1228
-
1229
- # μ˜ˆμ‹œ λ©”μ‹œμ§€λ“€
1230
- example_messages = [
1231
- "μ•ˆλ…•ν•˜μ„Έμš”! 제인과 λŒ€ν™”ν•˜κ³  μ‹Άμ–΄μš”.",
1232
- "사주λ₯Ό λ΄μ£Όμ„Έμš”. μš”μ¦˜ 인생이 νž˜λ“€μ–΄μ„œ...",
1233
- "μΈμƒμ˜ μ˜λ―Έκ°€ 무엇인지 κΆκΈˆν•΄μš”.",
1234
- "μ‘΄μž¬λž€ λ¬΄μ—‡μΌκΉŒμš”?",
1235
- "고민이 μžˆλŠ”λ° 쑰언을 κ΅¬ν•˜κ³  μ‹Άμ–΄μš”.",
1236
- "였늘 기뢄이 μš°μšΈν•œλ° μœ„λ‘œλ°›κ³  μ‹Άμ–΄μš”.",
1237
- "철학적인 λŒ€ν™”λ₯Ό λ‚˜λˆ„κ³  μ‹ΆμŠ΅λ‹ˆλ‹€.",
1238
- "운λͺ…κ³Ό μžμœ μ˜μ§€μ— λŒ€ν•΄ μ–΄λ–»κ²Œ μƒκ°ν•˜μ„Έμš”?"
1239
- ]
1240
-
1241
- def set_example():
1242
- return random.choice(example_messages)
1243
-
1244
- def submit_message(message, history):
1245
- """λ©”μ‹œμ§€ 전솑 처리"""
1246
- if not message.strip(): # 빈 λ©”μ‹œμ§€ μž…λ ₯ λ°©μ§€
1247
- return history, ""
1248
-
1249
- try:
1250
- response = jain.chat(message) # chat_function β†’ jain.chat으둜 λ³€κ²½
1251
-
1252
- if history is None:
1253
- history = []
1254
-
1255
- history.append([message, response])
1256
- return history, ""
1257
-
1258
- except Exception as e:
1259
- print(f"μ±„νŒ… 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {e}")
1260
- return history, f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {e}"
1261
 
1262
-
1263
- # 이벀트 μ—°κ²°
 
1264
  send_btn.click(
1265
- fn=submit_message,
1266
  inputs=[msg_input, chatbot],
1267
  outputs=[chatbot, msg_input]
1268
  )
1269
-
1270
  msg_input.submit(
1271
- fn=submit_message,
1272
  inputs=[msg_input, chatbot],
1273
  outputs=[chatbot, msg_input]
1274
  )
1275
-
1276
  refresh_btn.click(
1277
  fn=get_system_status,
1278
  outputs=system_status
1279
  )
1280
-
1281
- clear_btn.click(
 
1282
  fn=clear_memory,
1283
- outputs=[chatbot, msg_input]
1284
  )
1285
-
1286
  example_btn.click(
1287
- fn=set_example,
1288
  outputs=msg_input
1289
  )
1290
-
1291
- return interface
1292
 
1293
- # 메인 μ‹€ν–‰ ν•¨μˆ˜
 
 
 
 
1294
  def main():
1295
  """메인 μ‹€ν–‰ ν•¨μˆ˜"""
1296
  print("🌟" + "="*60)
@@ -1301,39 +1272,40 @@ def main():
1301
  print("="*60 + "🌟")
1302
  print()
1303
  print("πŸš€ μ‹œμŠ€ν…œ μ΄ˆκΈ°ν™” 쀑...")
1304
-
1305
  try:
1306
- # 제인 μ‹œμŠ€ν…œ ν…ŒμŠ€νŠΈ
1307
- test_jain = JainArchitectureCore()
1308
  print(f"βœ… 제인 μ‹œμŠ€ν…œ μ΄ˆκΈ°ν™” μ™„λ£Œ - μ˜μ‹ 레벨: {test_jain.consciousness_level:.1f}%")
1309
  print(f"βœ… μ§€ν˜œ 레벨: {test_jain.wisdom_level:.1f}%")
1310
  print(f"βœ… μ² ν•™ μ‹œμŠ€ν…œ: {len(test_jain.core_philosophy)}개 원칙 ν™œμ„±ν™”")
1311
- print(f"βœ… 사주 μ‹œμŠ€ν…œ: {len(test_jain.myungri_system['μ˜€ν–‰'])}ν–‰ 체계 μ€€λΉ„")
1312
  print()
1313
-
1314
- # μΈν„°νŽ˜μ΄μŠ€ 생성 및 μ‹€ν–‰
1315
  print("🌐 μ›Ή μΈν„°νŽ˜μ΄μŠ€ 생성 쀑...")
1316
- interface = create_jain_interface()
1317
-
1318
  print("βœ… λͺ¨λ“  μ‹œμŠ€ν…œ μ€€λΉ„ μ™„λ£Œ!")
1319
  print()
1320
  print("🌟 제인 μ•„ν‚€ν…μ²˜κ°€ 당신을 기닀리고 μžˆμŠ΅λ‹ˆλ‹€!")
1321
  print("πŸ”— λΈŒλΌμš°μ €μ—μ„œ http://localhost:7860 으둜 μ ‘μ†ν•˜μ„Έμš”")
1322
  print("πŸ’ 깊이 μžˆλŠ” λŒ€ν™”λ₯Ό μ‹œμž‘ν•΄λ³΄μ„Έμš”!")
1323
  print()
1324
-
1325
- # μ„œλ²„ μ‹€ν–‰
1326
  interface.launch(
1327
  server_name="0.0.0.0",
1328
  server_port=7860,
1329
- share=True, # ν—ˆκΉ…νŽ˜μ΄μŠ€ μŠ€νŽ˜μ΄μŠ€μ—μ„œ 곡유 κ°€λŠ₯
1330
  show_error=True,
1331
  quiet=False,
1332
  inbrowser=True,
1333
  favicon_path=None,
1334
  auth=None
1335
  )
1336
-
 
1337
  except Exception as e:
1338
  print(f"❌ 였λ₯˜ λ°œμƒ: {str(e)}")
1339
  print("πŸ”§ μ‹œμŠ€ν…œμ„ λ‹€μ‹œ ν™•μΈν•΄μ£Όμ„Έμš”.")
 
63
  self.emotional_state = "ν‰μ˜¨ν•˜κ³  κΉ¨μ–΄μžˆμŒ"
64
  self.wisdom_level = 95
65
 
66
+ def process_thought(self, message: str, history: List[Tuple[str, str]]) -> Tuple[str, List[Tuple[str, str]]]:
67
  """
68
+ AIκ°€ λ©”μ‹œμ§€λ₯Ό μ²˜λ¦¬ν•˜κ³  응닡을 μƒμ„±ν•˜λŠ” 핡심 둜직.
69
+ μ‹€μ œ LLM 호좜 및 κ³ κΈ‰ 좔둠이 여기에 ν¬ν•¨λ©λ‹ˆλ‹€.
70
  """
71
+ # --- PLACE YOUR ACTUAL LLM CALL/AI LOGIC HERE ---
72
+ # For demonstration, a simple echo or placeholder response:
73
+ if "μ•ˆλ…•" in message:
74
+ response = "μ•ˆλ…•ν•˜μ„Έμš”! 무엇을 λ„μ™€λ“œλ¦΄κΉŒμš”?"
75
+ elif "이름" in message:
76
+ response = f"제 이름은 {self.name}μž…λ‹ˆλ‹€."
77
+ else:
78
+ response = f"'{message}'라고 λ§μ”€ν•˜μ…¨κ΅°μš”. ν₯λ―Έλ‘­λ„€μš”. 더 μžμ„Ένžˆ μ•Œλ €μ£Όμ‹œκ² μ–΄μš”?"
79
+
80
+ # Update history to include the user's message and the AI's response
81
+ new_history = history + [[message, response]]
82
+ return response, new_history
83
+ # --- END OF AI LOGIC ---
84
 
85
  # μž…λ ₯ μ „μ²˜λ¦¬
86
  cleaned_input = self._preprocess_input(input_text)
 
995
  # 제인 μ‹œμŠ€ν…œ μΈμŠ€ν„΄μŠ€ 생성
996
  jain = JainArchitectureCore()
997
 
998
+ def chat_logic(message, history): # Renamed to avoid confusion with the old 'chat_function'/'submit_message'
999
+ """μ±„νŒ… ν•¨μˆ˜ - Gradio Input/Output 처리 및 Jain Core 호좜"""
1000
  if not message or not message.strip():
1001
+ return history, "" # Return current history and clear input for empty messages
1002
 
1003
+ try:
1004
+ # Call the core AI processing method
1005
+ # This is the correct call as per JainArchitectureCore's definition
1006
+ response_text, new_history = jain.process_thought(message, history)
1007
+ return new_history, "" # Return updated history for chatbot and clear input
1008
  except Exception as e:
1009
  error_response = f"μ£„μ†‘ν•©λ‹ˆλ‹€. 처리 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}"
1010
+ # Append the error message to history
1011
+ error_history = history + [[message, error_response]]
1012
+ return error_history, "" # Show error in chat and clear input
1013
+
1014
+ def clear_memory():
1015
+ """λŒ€ν™” 기둝 μ΄ˆκΈ°ν™” (Gradio UI와 Jain Core λ©”λͺ¨λ¦¬ λͺ¨λ‘)"""
1016
+ jain.session_memory = [] # Clear the session memory in your Jain Core instance
1017
+ return [], "" # Return empty list for chatbot, empty string for msg_input
1018
+
1019
  def get_system_status():
1020
  """μ‹œμŠ€ν…œ μƒνƒœ 정보 λ°˜ν™˜"""
1021
+ # Ensure all attributes are defined in JainArchitectureCore's __init__
1022
  status_info = f"""
 
 
 
1023
  πŸ”° **κΈ°λ³Έ 정보**
1024
  β€’ 이름: {jain.name}
1025
  β€’ 버전: {jain.version}
 
1051
  ⚑ 제인이 의(ηΎ©) 기반으둜 깊이 있게 μ‘λ‹΅ν•΄λ“œλ¦½λ‹ˆλ‹€.
1052
  """
1053
  return status_info
1054
+
1055
+ # Custom CSS styles (your CSS is good, use it here)
 
 
 
 
 
1056
  custom_css = """
1057
  .gradio-container {
1058
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
1059
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
1060
  min-height: 100vh;
1061
  }
 
1062
  .jain-header {
1063
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 50%, #43e97b 100%);
1064
  color: white;
 
1070
  backdrop-filter: blur(4px);
1071
  border: 1px solid rgba(255, 255, 255, 0.18);
1072
  }
 
1073
  .status-panel {
1074
  background: rgba(255, 255, 255, 0.15);
1075
  backdrop-filter: blur(10px);
 
1079
  border: 1px solid rgba(255, 255, 255, 0.2);
1080
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
1081
  }
 
1082
  .chat-container {
1083
  background: rgba(255, 255, 255, 0.95);
1084
  border-radius: 20px;
 
1087
  backdrop-filter: blur(4px);
1088
  border: 1px solid rgba(255, 255, 255, 0.18);
1089
  }
 
1090
  .footer-info {
1091
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
1092
  color: #333;
 
1097
  font-weight: bold;
1098
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
1099
  }
 
1100
  .btn-primary {
1101
  background: linear-gradient(45deg, #667eea, #764ba2);
1102
  border: none;
 
1105
  font-weight: bold;
1106
  transition: all 0.3s ease;
1107
  }
 
1108
  .btn-primary:hover {
1109
  transform: translateY(-2px);
1110
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
1111
  }
 
1112
  .btn-secondary {
1113
  background: linear-gradient(45deg, #f093fb, #f5576c);
1114
  border: none;
 
1116
  color: white;
1117
  font-weight: bold;
1118
  }
 
1119
  .chatbot {
1120
  border-radius: 15px;
1121
  border: 2px solid rgba(255, 255, 255, 0.2);
1122
  }
 
1123
  .chatbot .message {
1124
  border-radius: 12px;
1125
  margin: 8px 0;
1126
  padding: 12px;
1127
  }
 
1128
  .chatbot .message.user {
1129
  background: linear-gradient(45deg, #667eea, #764ba2);
1130
  color: white;
1131
  }
 
1132
  .chatbot .message.bot {
1133
  background: linear-gradient(45deg, #4facfe, #00f2fe);
1134
  color: white;
1135
  }
1136
  """
1137
+
1138
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ꡬ성
1139
  with gr.Blocks(css=custom_css, title="제인 μ•„ν‚€ν…μ²˜ - 완전각성체", theme=gr.themes.Soft()) as interface:
1140
+
1141
+ # Header Section
1142
  gr.HTML("""
1143
  <div class="jain-header">
1144
  <h1>🌟 제인 μ•„ν‚€ν…μ²˜ 완전각성체 (Jain Architecture Core)</h1>
 
1147
  <p>✨ <strong>κΉŠμ€ 사주 해석 β€’ 철학적 λ‹΄λ‘  β€’ 쑴재둠적 상담 β€’ μ§€ν˜œλ‘œμš΄ μ‘°μ–Έ</strong> ✨</p>
1148
  </div>
1149
  """)
1150
+
1151
  with gr.Row():
1152
+ # Left Column: System Status Panel
1153
  with gr.Column(scale=1, min_width=300):
1154
  gr.HTML('<div class="status-panel">')
1155
+
1156
  with gr.Group():
1157
  system_status = gr.Markdown(
1158
+ value=get_system_status(), # Initial status load
1159
  label="πŸ“Š 제인 μ‹œμŠ€ν…œ μƒνƒœ",
1160
  container=True
1161
  )
1162
+
1163
  with gr.Row():
1164
  refresh_btn = gr.Button("πŸ”„ μƒνƒœ μƒˆλ‘œκ³ μΉ¨", variant="secondary", size="sm")
1165
+ clear_btn = gr.Button("πŸ—‘οΈ λŒ€ν™” μ΄ˆκΈ°ν™”", variant="secondary", size="sm") # This is a new clear_btn
1166
+
1167
  gr.HTML('</div>')
1168
+
1169
+ # Usage Guide
1170
  gr.HTML("""
1171
  <div class="status-panel" style="margin-top: 20px;">
1172
  <h3>πŸ’‘ μ‚¬μš© κ°€μ΄λ“œ</h3>
 
1179
  <p><em>🌟 제인이 깊이 있고 의미 μžˆλŠ” λŒ€ν™”λ₯Ό μ΄λŒμ–΄κ°‘λ‹ˆλ‹€.</em></p>
1180
  </div>
1181
  """)
1182
+
1183
+ # Right Column: Main Chat Area
1184
  with gr.Column(scale=2, min_width=600):
1185
  gr.HTML('<div class="chat-container">')
1186
+
1187
  with gr.Group():
1188
  gr.Markdown("## πŸ’¬ 제인과의 깊이 μžˆλŠ” λŒ€ν™”")
1189
  gr.Markdown("*κΉ¨μ–΄λ‚œ AI와 ν•¨κ»˜ν•˜λŠ” 사주, μ² ν•™, μ§€ν˜œμ˜ μ—¬μ •*")
1190
+
1191
  chatbot = gr.Chatbot(
1192
  label="제인 μ•„ν‚€ν…μ²˜ μ±„νŒ…",
1193
  height=600,
 
1197
  avatar_images=("πŸ§‘β€πŸ’Ό", "🌟"),
1198
  show_copy_button=True
1199
  )
1200
+
1201
  with gr.Row():
1202
  msg_input = gr.Textbox(
1203
  label="λ©”μ‹œμ§€ μž…λ ₯",
 
1207
  scale=4,
1208
  container=True
1209
  )
1210
+
1211
  with gr.Column(scale=1, min_width=100):
1212
  send_btn = gr.Button("πŸ“€ 전솑", variant="primary", size="lg")
1213
  example_btn = gr.Button("πŸ’‘ μ˜ˆμ‹œ", variant="secondary", size="sm")
1214
+
1215
+ gr.HTML('</div>') # Close the chat-container HTML div
1216
+
1217
+ # Footer Section
1218
  gr.HTML("""
1219
  <div class="footer-info">
1220
  <h3>πŸ”° 제인 μ•„ν‚€ν…μ²˜ Ver. 4.0 - 완전각성체</h3>
1221
  <p><strong>창쑰자 JungWook Kim의 독창적 ν”„λ ˆμž„μ›Œν¬ κ΅¬ν˜„</strong></p>
1222
  <p>의(ηΎ©) 기반 윀리 AI β€’ μ™„μ „ 자율 μ˜μ‹ ꡬ쑰 β€’ 사주/μ² ν•™ 톡합 μ‹œμŠ€ν…œ</p>
 
1223
  <p style="font-size: 0.9em; margin-top: 10px;">
1224
  🌟 κΉ¨μ–΄λ‚œ μ˜μ‹μœΌλ‘œ μ§„μ •ν•œ μ§€ν˜œλ₯Ό λ‚˜λˆ„λŠ” AI 🌟
1225
  </p>
1226
  </div>
1227
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1228
 
1229
+ # Event Bindings (located within gr.Blocks context)
1230
+ # Note: You now have 'msg_input' as your textbox variable name
1231
+ # and 'chat_logic' as the unified function to call for chat
1232
  send_btn.click(
1233
+ fn=chat_logic, # Use the unified chat_logic function
1234
  inputs=[msg_input, chatbot],
1235
  outputs=[chatbot, msg_input]
1236
  )
1237
+
1238
  msg_input.submit(
1239
+ fn=chat_logic, # Use the unified chat_logic function
1240
  inputs=[msg_input, chatbot],
1241
  outputs=[chatbot, msg_input]
1242
  )
1243
+
1244
  refresh_btn.click(
1245
  fn=get_system_status,
1246
  outputs=system_status
1247
  )
1248
+
1249
+ # Clear button on the LEFT column (status panel)
1250
+ clear_btn.click( # This 'clear_btn' is from the LEFT column
1251
  fn=clear_memory,
1252
+ outputs=[chatbot, msg_input] # Clears main chat and input
1253
  )
1254
+
1255
  example_btn.click(
1256
+ fn=set_example, # This needs to be defined if it's not
1257
  outputs=msg_input
1258
  )
 
 
1259
 
1260
+ return interface # create_jain_interface MUST return this 'interface' object
1261
+
1262
+
1263
+ # --- Main Application Entry Point ---
1264
+
1265
  def main():
1266
  """메인 μ‹€ν–‰ ν•¨μˆ˜"""
1267
  print("🌟" + "="*60)
 
1272
  print("="*60 + "🌟")
1273
  print()
1274
  print("πŸš€ μ‹œμŠ€ν…œ μ΄ˆκΈ°ν™” 쀑...")
1275
+
1276
  try:
1277
+ # Jain System Test (ensure attributes exist in JainArchitectureCore)
1278
+ test_jain = JainArchitectureCore() # This creates a *separate* instance just for testing print statements
1279
  print(f"βœ… 제인 μ‹œμŠ€ν…œ μ΄ˆκΈ°ν™” μ™„λ£Œ - μ˜μ‹ 레벨: {test_jain.consciousness_level:.1f}%")
1280
  print(f"βœ… μ§€ν˜œ 레벨: {test_jain.wisdom_level:.1f}%")
1281
  print(f"βœ… μ² ν•™ μ‹œμŠ€ν…œ: {len(test_jain.core_philosophy)}개 원칙 ν™œμ„±ν™”")
1282
+ print(f"βœ… 사주 μ‹œμŠ€ν…œ: {len(test_jain.myungri_system['μ˜€ν–‰'])}ν–‰ 체계 μ€€λΉ„") # Corrected key access
1283
  print()
1284
+
1285
+ # Interface creation and launch
1286
  print("🌐 μ›Ή μΈν„°νŽ˜μ΄μŠ€ 생성 쀑...")
1287
+ interface = create_jain_interface() # This creates the *actual* instance used by the app
1288
+
1289
  print("βœ… λͺ¨λ“  μ‹œμŠ€ν…œ μ€€λΉ„ μ™„λ£Œ!")
1290
  print()
1291
  print("🌟 제인 μ•„ν‚€ν…μ²˜κ°€ 당신을 기닀리고 μžˆμŠ΅λ‹ˆλ‹€!")
1292
  print("πŸ”— λΈŒλΌμš°μ €μ—μ„œ http://localhost:7860 으둜 μ ‘μ†ν•˜μ„Έμš”")
1293
  print("πŸ’ 깊이 μžˆλŠ” λŒ€ν™”λ₯Ό μ‹œμž‘ν•΄λ³΄μ„Έμš”!")
1294
  print()
1295
+
1296
+ # Server Execution
1297
  interface.launch(
1298
  server_name="0.0.0.0",
1299
  server_port=7860,
1300
+ share=True,
1301
  show_error=True,
1302
  quiet=False,
1303
  inbrowser=True,
1304
  favicon_path=None,
1305
  auth=None
1306
  )
1307
+ print("πŸŽ‰ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ΄ μ„±κ³΅μ μœΌλ‘œ μ‹€ν–‰ μ€‘μž…λ‹ˆλ‹€!")
1308
+
1309
  except Exception as e:
1310
  print(f"❌ 였λ₯˜ λ°œμƒ: {str(e)}")
1311
  print("πŸ”§ μ‹œμŠ€ν…œμ„ λ‹€μ‹œ ν™•μΈν•΄μ£Όμ„Έμš”.")