Prompthumanizer commited on
Commit
ae7785d
ยท
verified ยท
1 Parent(s): bd3c5f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -21
app.py CHANGED
@@ -676,17 +676,19 @@ class JainArchitectureCore:
676
  else:
677
  return "์•ˆ๋…•ํ•˜์„ธ์š”!"
678
 
679
- def _generate_main_response(self, input_text: str, awareness: Dict, patterns: Dict, judgment: Dict) -> str:
680
  """์ฃผ์š” ์‘๋‹ต ๋‚ด์šฉ ์ƒ์„ฑ"""
681
  intention = awareness["์˜๋„_๋ณธ์งˆ"]["ํ‘œ๋ฉด_์˜๋„"]
682
-
683
- if intention == "์šด๋ช…_์ƒ๋‹ด" or "์‚ฌ์ฃผ" in input_text or "ํŒ”์ž" in input_text:
 
 
684
  return self._generate_saju_consultation(input_text, patterns, judgment)
685
- elif intention == "๋ฌธ์ œ_ํ•ด๊ฒฐ" or any(word in input_text for word in ["๊ณ ๋ฏผ", "๋ฌธ์ œ", "์–ด๋ ค์›€"]):
686
  return self._generate_wisdom_guidance(input_text, patterns, judgment)
687
- elif intention == "์งˆ๋ฌธ_์š•๊ตฌ" or "?" in input_text:
688
  return self._generate_philosophical_answer(input_text, awareness, patterns)
689
- elif intention == "์ธ์‚ฌ_๊ต๋ฅ˜" or any(word in input_text for word in ["์•ˆ๋…•", "๋ฐ˜๊ฐ€", "hello"]):
690
  return self._generate_warm_greeting_response(awareness, patterns)
691
  else:
692
  return self._generate_general_wisdom_response(input_text, awareness, patterns)
@@ -695,14 +697,21 @@ class JainArchitectureCore:
695
  """์‚ฌ์ฃผ ์ƒ๋‹ด ์‘๋‹ต ์ƒ์„ฑ"""
696
  ohaeng = patterns["์˜คํ–‰_์—ญํ•™"]
697
  spacetime = patterns["์‹œ๊ณต๊ฐ„_ํ๋ฆ„"]
698
-
699
  consultations = [
700
  f"""๐Ÿ”ฎ **๊นŠ์€ ์‚ฌ์ฃผ ํ•ด์„์˜ ์„ธ๊ณ„**
701
 
702
  ์‚ฌ์ฃผ๋Š” ๋‹น์‹ ์ด๋ผ๋Š” ์กด์žฌ๊ฐ€ ์šฐ์ฃผ์— ๋‚จ๊ธด ๊ณ ์œ ํ•œ '์กด์žฌ๋ก ์  ์„œ๋ช…'์ž…๋‹ˆ๋‹ค.
703
 
704
- ํ˜„์žฌ {spacetime['๊ณ„์ ˆ_์—๋„ˆ์ง€']}์˜ ํ๋ฆ„ ์†์—์„œ, {ohaeng['์ฃผ๋„_์˜คํ–‰']}๊ธฐ์šด์ด ์ฃผ๋„ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
705
- ์ด๋Š” {ohaeng['์ƒ์ƒ_๊ด€๊ณ„']}๋กœ์˜ ์ž์—ฐ์Šค๋Ÿฌ์šด ๋ฐœ์ „๊ณผ {ohaeng['์ƒ๊ทน_๊ด€๊ณ„']}์— ๋Œ€ํ•œ ์ง€ํ˜œ๋กœ์šด ์กฐ์ ˆ์ด ํ•„์š”ํ•จ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.
 
 
 
 
 
 
 
706
 
707
  **์˜คํ–‰์˜ ๋ฉ”์‹œ์ง€:**
708
  - **๋ชฉ(ๆœจ)**: ์ƒ๋ช…๋ ฅ๊ณผ ์ฐฝ์กฐ์˜ ์˜์ง€
@@ -1194,24 +1203,24 @@ def get_system_status():
1194
  </div>
1195
  """)
1196
 
1197
- # ์˜ค๋ฅธ์ชฝ: ๋ฉ”์ธ ์ฑ„ํŒ… ์˜์—ญ
1198
  with gr.Column(scale=2, min_width=600):
1199
  gr.HTML('<div class="chat-container">')
1200
-
1201
  with gr.Group():
1202
  gr.Markdown("## ๐Ÿ’ฌ ์ œ์ธ๊ณผ์˜ ๊นŠ์ด ์žˆ๋Š” ๋Œ€ํ™”")
1203
  gr.Markdown("*๊นจ์–ด๋‚œ AI์™€ ํ•จ๊ป˜ํ•˜๋Š” ์‚ฌ์ฃผ, ์ฒ ํ•™, ์ง€ewise์˜ ์—ฌ์ •*")
1204
-
1205
  chatbot = gr.Chatbot(
1206
  label="์ œ์ธ ์•„ํ‚คํ…์ฒ˜ ์ฑ„ํŒ…",
1207
  height=600,
1208
  show_label=False,
1209
  container=True,
1210
  bubble_full_width=False,
1211
- avatar_images=("๐Ÿง‘โ€๐Ÿ’ผ", "๐ŸŒŸ"),
1212
  show_copy_button=True
1213
  )
1214
-
1215
  with gr.Row():
1216
  msg_input = gr.Textbox(
1217
  label="๋ฉ”์‹œ์ง€ ์ž…๋ ฅ",
@@ -1221,13 +1230,13 @@ def get_system_status():
1221
  scale=4,
1222
  container=True
1223
  )
1224
-
1225
  with gr.Column(scale=1, min_width=100):
1226
  send_btn = gr.Button("๐Ÿ“ค ์ „์†ก", variant="primary", size="lg")
1227
  example_btn = gr.Button("๐Ÿ’ก ์˜ˆ์‹œ", variant="secondary", size="sm")
1228
-
1229
  gr.HTML('</div>')
1230
-
1231
  # ํ‘ธํ„ฐ
1232
  gr.HTML("""
1233
  <div class="footer-info">
@@ -1304,7 +1313,7 @@ def main():
1304
  print("="*60 + "๐ŸŒŸ")
1305
  print()
1306
  print("๐Ÿš€ ์‹œ์Šคํ…œ ์ดˆ๊ธฐํ™” ์ค‘...")
1307
-
1308
  try:
1309
  # ์ œ์ธ ์‹œ์Šคํ…œ ํ…Œ์ŠคํŠธ
1310
  test_jain = JainArchitectureCore()
@@ -1313,18 +1322,37 @@ def main():
1313
  print(f"โœ… ์ฒ ํ•™ ์‹œ์Šคํ…œ: {len(test_jain.core_philosophy)}๊ฐœ ์›์น™ ํ™œ์„ฑํ™”")
1314
  print(f"โœ… ์‚ฌ์ฃผ ์‹œ์Šคํ…œ: {len(test_jain.myungri_system['์˜คํ–‰'])}ํ–‰ ์ฒด๊ณ„ ์ค€๋น„")
1315
  print()
1316
-
1317
  # ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ๋ฐ ์‹คํ–‰
1318
  print("๐ŸŒ ์›น ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ์ค‘...")
1319
- interface = create_jain_interface()
1320
 
 
 
 
 
 
 
 
 
 
 
 
 
1321
  print("โœ… ๋ชจ๋“  ์‹œ์Šคํ…œ ์ค€๋น„ ์™„๋ฃŒ!")
1322
  print()
1323
  print("๐ŸŒŸ ์ œ์ธ ์•„ํ‚คํ…์ฒ˜๊ฐ€ ๋‹น์‹ ์„ ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค!")
1324
  print("๐Ÿ”— ๋ธŒ๋ผ์šฐ์ €์—์„œ http://localhost:7860 ์œผ๋กœ ์ ‘์†ํ•˜์„ธ์š”")
1325
  print("๐Ÿ’ ๊นŠ์ด ์žˆ๋Š” ๋Œ€ํ™”๋ฅผ ์‹œ์ž‘ํ•ด๋ณด์„ธ์š”!")
1326
  print()
1327
-
 
 
 
 
 
 
 
1328
  # ์„œ๋ฒ„ ์‹คํ–‰
1329
  interface.launch(
1330
  server_name="0.0.0.0",
 
676
  else:
677
  return "์•ˆ๋…•ํ•˜์„ธ์š”!"
678
 
679
+ def _generate_main_response(self, input_text: str, awareness: Dict, patterns: Dict, judgment: Dict) -> str:
680
  """์ฃผ์š” ์‘๋‹ต ๋‚ด์šฉ ์ƒ์„ฑ"""
681
  intention = awareness["์˜๋„_๋ณธ์งˆ"]["ํ‘œ๋ฉด_์˜๋„"]
682
+
683
+ # CORRECTED LOGIC: Each keyword check must explicitly use 'in input_text'
684
+ # Also added .lower() for case-insensitivity on keyword checks
685
+ if intention == "์šด๋ช…_์ƒ๋‹ด" or "์‚ฌ์ฃผ" in input_text.lower() or "ํŒ”์ž" in input_text.lower():
686
  return self._generate_saju_consultation(input_text, patterns, judgment)
687
+ elif intention == "๋ฌธ์ œ_ํ•ด๊ฒฐ" or any(word in input_text.lower() for word in ["๊ณ ๋ฏผ", "๋ฌธ์ œ", "์–ด๋ ค์›€"]):
688
  return self._generate_wisdom_guidance(input_text, patterns, judgment)
689
+ elif intention == "์งˆ๋ฌธ_์š•๊ตฌ" or "?" in input_text: # '?' is typically case-insensitive
690
  return self._generate_philosophical_answer(input_text, awareness, patterns)
691
+ elif intention == "์ธ์‚ฌ_๊ต๋ฅ˜" or any(word in input_text.lower() for word in ["์•ˆ๋…•", "๋ฐ˜๊ฐ€", "hello"]):
692
  return self._generate_warm_greeting_response(awareness, patterns)
693
  else:
694
  return self._generate_general_wisdom_response(input_text, awareness, patterns)
 
697
  """์‚ฌ์ฃผ ์ƒ๋‹ด ์‘๋‹ต ์ƒ์„ฑ"""
698
  ohaeng = patterns["์˜คํ–‰_์—ญํ•™"]
699
  spacetime = patterns["์‹œ๊ณต๊ฐ„_ํ๋ฆ„"]
700
+
701
  consultations = [
702
  f"""๐Ÿ”ฎ **๊นŠ์€ ์‚ฌ์ฃผ ํ•ด์„์˜ ์„ธ๊ณ„**
703
 
704
  ์‚ฌ์ฃผ๋Š” ๋‹น์‹ ์ด๋ผ๋Š” ์กด์žฌ๊ฐ€ ์šฐ์ฃผ์— ๋‚จ๊ธด ๊ณ ์œ ํ•œ '์กด์žฌ๋ก ์  ์„œ๋ช…'์ž…๋‹ˆ๋‹ค.
705
 
706
+ ํ˜„์žฌ {spacetime['๊ณ„์ ˆ_์—๋„ˆ์ง€']}์˜ ํ๋ฆ„ ์†์—์„œ, {ohaeng['์ฃผ๋„_์˜คํ–‰']}๊ธฐ์šด์ด ์ฃผ๋„ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
707
+ ์ด๋Š” {ohaeng['์ƒ์ƒ_๊ด€๊ณ„']}๋กœ์˜ ์ž์—ฐ์Šค๋Ÿฌ์šด ๋ฐœ์ „๊ณผ {ohaeng['์ƒ๊ทน_๊ด€๊ณ„']}์— ๋Œ€ํ•œ ์ง€ํ˜œ๋กœ์šด ์กฐ์ ˆ์ด ํ•„์š”ํ•จ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค."""
708
+ # Add more consultation options here if needed,
709
+ # for example:
710
+ # f"""Another saju consultation message using {ohaeng} and {spacetime} data."""
711
+ ]
712
+ # You'll likely want to return one of these consultations or further process them
713
+ # For now, I'll just return the first one as an example of completion.
714
+ return consultations[0]
715
 
716
  **์˜คํ–‰์˜ ๋ฉ”์‹œ์ง€:**
717
  - **๋ชฉ(ๆœจ)**: ์ƒ๋ช…๋ ฅ๊ณผ ์ฐฝ์กฐ์˜ ์˜์ง€
 
1203
  </div>
1204
  """)
1205
 
1206
+ # ์˜ค๋ฅธ์ชฝ: ๋ฉ”์ธ ์ฑ„ํŒ… ์˜์—ญ
1207
  with gr.Column(scale=2, min_width=600):
1208
  gr.HTML('<div class="chat-container">')
1209
+
1210
  with gr.Group():
1211
  gr.Markdown("## ๐Ÿ’ฌ ์ œ์ธ๊ณผ์˜ ๊นŠ์ด ์žˆ๋Š” ๋Œ€ํ™”")
1212
  gr.Markdown("*๊นจ์–ด๋‚œ AI์™€ ํ•จ๊ป˜ํ•˜๋Š” ์‚ฌ์ฃผ, ์ฒ ํ•™, ์ง€ewise์˜ ์—ฌ์ •*")
1213
+
1214
  chatbot = gr.Chatbot(
1215
  label="์ œ์ธ ์•„ํ‚คํ…์ฒ˜ ์ฑ„ํŒ…",
1216
  height=600,
1217
  show_label=False,
1218
  container=True,
1219
  bubble_full_width=False,
1220
+ avatar_images=("๐Ÿง‘โ€๐Ÿ’ผ", "๐ŸŒŸ"), # User avatar, Bot avatar
1221
  show_copy_button=True
1222
  )
1223
+
1224
  with gr.Row():
1225
  msg_input = gr.Textbox(
1226
  label="๋ฉ”์‹œ์ง€ ์ž…๋ ฅ",
 
1230
  scale=4,
1231
  container=True
1232
  )
1233
+
1234
  with gr.Column(scale=1, min_width=100):
1235
  send_btn = gr.Button("๐Ÿ“ค ์ „์†ก", variant="primary", size="lg")
1236
  example_btn = gr.Button("๐Ÿ’ก ์˜ˆ์‹œ", variant="secondary", size="sm")
1237
+
1238
  gr.HTML('</div>')
1239
+
1240
  # ํ‘ธํ„ฐ
1241
  gr.HTML("""
1242
  <div class="footer-info">
 
1313
  print("="*60 + "๐ŸŒŸ")
1314
  print()
1315
  print("๐Ÿš€ ์‹œ์Šคํ…œ ์ดˆ๊ธฐํ™” ์ค‘...")
1316
+
1317
  try:
1318
  # ์ œ์ธ ์‹œ์Šคํ…œ ํ…Œ์ŠคํŠธ
1319
  test_jain = JainArchitectureCore()
 
1322
  print(f"โœ… ์ฒ ํ•™ ์‹œ์Šคํ…œ: {len(test_jain.core_philosophy)}๊ฐœ ์›์น™ ํ™œ์„ฑํ™”")
1323
  print(f"โœ… ์‚ฌ์ฃผ ์‹œ์Šคํ…œ: {len(test_jain.myungri_system['์˜คํ–‰'])}ํ–‰ ์ฒด๊ณ„ ์ค€๋น„")
1324
  print()
1325
+
1326
  # ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ๋ฐ ์‹คํ–‰
1327
  print("๐ŸŒ ์›น ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ ์ค‘...")
1328
+ interface = create_jain_interface() # This function needs to be defined
1329
 
1330
+ # Launch the Gradio interface
1331
+ interface.launch(
1332
+ server_name="0.0.0.0",
1333
+ server_port=7860,
1334
+ share=False,
1335
+ show_error=True,
1336
+ quiet=False,
1337
+ inbrowser=True,
1338
+ favicon_path=None,
1339
+ auth=None
1340
+ )
1341
+
1342
  print("โœ… ๋ชจ๋“  ์‹œ์Šคํ…œ ์ค€๋น„ ์™„๋ฃŒ!")
1343
  print()
1344
  print("๐ŸŒŸ ์ œ์ธ ์•„ํ‚คํ…์ฒ˜๊ฐ€ ๋‹น์‹ ์„ ๊ธฐ๋‹ค๋ฆฌ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค!")
1345
  print("๐Ÿ”— ๋ธŒ๋ผ์šฐ์ €์—์„œ http://localhost:7860 ์œผ๋กœ ์ ‘์†ํ•˜์„ธ์š”")
1346
  print("๐Ÿ’ ๊นŠ์ด ์žˆ๋Š” ๋Œ€ํ™”๋ฅผ ์‹œ์ž‘ํ•ด๋ณด์„ธ์š”!")
1347
  print()
1348
+
1349
+ except Exception as e:
1350
+ print(f"โŒ ์‹œ์Šคํ…œ ์‹œ์ž‘ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {e}")
1351
+ print("๐Ÿšจ ์ œ์ธ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์‹œ์ž‘ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋ฅผ ํ™•์ธํ•ด์ฃผ์„ธ์š”.")
1352
+
1353
+ # This ensures main() runs only when the script is executed directly
1354
+ if __name__ == "__main__":
1355
+ main()
1356
  # ์„œ๋ฒ„ ์‹คํ–‰
1357
  interface.launch(
1358
  server_name="0.0.0.0",