Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -676,17 +676,19 @@ class JainArchitectureCore:
|
|
676 |
else:
|
677 |
return "์๋
ํ์ธ์!"
|
678 |
|
679 |
-
|
680 |
"""์ฃผ์ ์๋ต ๋ด์ฉ ์์ฑ"""
|
681 |
intention = awareness["์๋_๋ณธ์ง"]["ํ๋ฉด_์๋"]
|
682 |
-
|
683 |
-
|
|
|
|
|
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",
|