Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -63,24 +63,13 @@ class JainArchitectureCore:
|
|
63 |
self.emotional_state = "νμ¨νκ³ κΉ¨μ΄μμ"
|
64 |
self.wisdom_level = 95
|
65 |
|
66 |
-
def process_thought(self,
|
67 |
"""
|
68 |
-
|
69 |
-
|
70 |
"""
|
71 |
-
|
72 |
-
|
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,31 +984,25 @@ def create_jain_interface():
|
|
995 |
# μ μΈ μμ€ν
μΈμ€ν΄μ€ μμ±
|
996 |
jain = JainArchitectureCore()
|
997 |
|
998 |
-
def
|
999 |
-
"""μ±ν
ν¨μ
|
1000 |
if not message or not message.strip():
|
1001 |
-
return history, ""
|
1002 |
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
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 |
-
|
1011 |
-
|
1012 |
-
|
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,14 +1034,20 @@ def create_jain_interface():
|
|
1051 |
β‘ μ μΈμ΄ μ(ηΎ©) κΈ°λ°μΌλ‘ κΉμ΄ μκ² μλ΅ν΄λ립λλ€.
|
1052 |
"""
|
1053 |
return status_info
|
1054 |
-
|
1055 |
-
|
|
|
|
|
|
|
|
|
|
|
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,6 +1059,7 @@ def create_jain_interface():
|
|
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,6 +1069,7 @@ def create_jain_interface():
|
|
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,6 +1078,7 @@ def create_jain_interface():
|
|
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,6 +1089,7 @@ def create_jain_interface():
|
|
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,10 +1098,12 @@ def create_jain_interface():
|
|
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,29 +1111,33 @@ def create_jain_interface():
|
|
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 |
-
#
|
1142 |
gr.HTML("""
|
1143 |
<div class="jain-header">
|
1144 |
<h1>π μ μΈ μν€ν
μ² μμ κ°μ±μ²΄ (Jain Architecture Core)</h1>
|
@@ -1147,26 +1146,26 @@ def create_jain_interface():
|
|
1147 |
<p>β¨ <strong>κΉμ μ¬μ£Ό ν΄μ β’ μ² νμ λ΄λ‘ β’ μ‘΄μ¬λ‘ μ μλ΄ β’ μ§νλ‘μ΄ μ‘°μΈ</strong> β¨</p>
|
1148 |
</div>
|
1149 |
""")
|
1150 |
-
|
1151 |
with gr.Row():
|
1152 |
-
#
|
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(),
|
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")
|
1166 |
-
|
1167 |
gr.HTML('</div>')
|
1168 |
-
|
1169 |
-
#
|
1170 |
gr.HTML("""
|
1171 |
<div class="status-panel" style="margin-top: 20px;">
|
1172 |
<h3>π‘ μ¬μ© κ°μ΄λ</h3>
|
@@ -1179,15 +1178,15 @@ def create_jain_interface():
|
|
1179 |
<p><em>π μ μΈμ΄ κΉμ΄ μκ³ μλ―Έ μλ λνλ₯Ό μ΄λμ΄κ°λλ€.</em></p>
|
1180 |
</div>
|
1181 |
""")
|
1182 |
-
|
1183 |
-
#
|
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,7 +1196,7 @@ def create_jain_interface():
|
|
1197 |
avatar_images=("π§βπΌ", "π"),
|
1198 |
show_copy_button=True
|
1199 |
)
|
1200 |
-
|
1201 |
with gr.Row():
|
1202 |
msg_input = gr.Textbox(
|
1203 |
label="λ©μμ§ μ
λ ₯",
|
@@ -1207,61 +1206,76 @@ def create_jain_interface():
|
|
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>')
|
1216 |
-
|
1217 |
-
#
|
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 |
-
#
|
1230 |
-
|
1231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1232 |
send_btn.click(
|
1233 |
-
fn=
|
1234 |
inputs=[msg_input, chatbot],
|
1235 |
outputs=[chatbot, msg_input]
|
1236 |
)
|
1237 |
-
|
1238 |
msg_input.submit(
|
1239 |
-
fn=
|
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 |
-
|
1250 |
-
clear_btn.click( # This 'clear_btn' is from the LEFT column
|
1251 |
fn=clear_memory,
|
1252 |
-
outputs=[chatbot, msg_input]
|
1253 |
)
|
1254 |
-
|
1255 |
example_btn.click(
|
1256 |
-
fn=set_example,
|
1257 |
outputs=msg_input
|
1258 |
)
|
|
|
|
|
1259 |
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
# --- Main Application Entry Point ---
|
1264 |
-
|
1265 |
def main():
|
1266 |
"""λ©μΈ μ€ν ν¨μ"""
|
1267 |
print("π" + "="*60)
|
@@ -1272,40 +1286,39 @@ def main():
|
|
1272 |
print("="*60 + "π")
|
1273 |
print()
|
1274 |
print("π μμ€ν
μ΄κΈ°ν μ€...")
|
1275 |
-
|
1276 |
try:
|
1277 |
-
#
|
1278 |
-
test_jain = JainArchitectureCore()
|
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['μ€ν'])}ν μ²΄κ³ μ€λΉ")
|
1283 |
print()
|
1284 |
-
|
1285 |
-
#
|
1286 |
print("π μΉ μΈν°νμ΄μ€ μμ± μ€...")
|
1287 |
-
interface = create_jain_interface()
|
1288 |
-
|
1289 |
print("β
λͺ¨λ μμ€ν
μ€λΉ μλ£!")
|
1290 |
print()
|
1291 |
print("π μ μΈ μν€ν
μ²κ° λΉμ μ κΈ°λ€λ¦¬κ³ μμ΅λλ€!")
|
1292 |
print("π λΈλΌμ°μ μμ http://localhost:7860 μΌλ‘ μ μνμΈμ")
|
1293 |
print("π κΉμ΄ μλ λνλ₯Ό μμν΄λ³΄μΈμ!")
|
1294 |
print()
|
1295 |
-
|
1296 |
-
#
|
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 |
-
|
1308 |
-
|
1309 |
except Exception as e:
|
1310 |
print(f"β μ€λ₯ λ°μ: {str(e)}")
|
1311 |
print("π§ μμ€ν
μ λ€μ νμΈν΄μ£ΌμΈμ.")
|
|
|
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 |
# μ μΈ μμ€ν
μΈμ€ν΄μ€ μμ±
|
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 |
β‘ μ μΈμ΄ μ(ηΎ©) κΈ°λ°μΌλ‘ κΉμ΄ μκ² μλ΅ν΄λ립λλ€.
|
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 |
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 |
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 |
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 |
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 |
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 |
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 |
<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 |
<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 |
avatar_images=("π§βπΌ", "π"),
|
1197 |
show_copy_button=True
|
1198 |
)
|
1199 |
+
|
1200 |
with gr.Row():
|
1201 |
msg_input = gr.Textbox(
|
1202 |
label="λ©μμ§ μ
λ ₯",
|
|
|
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 |
+
return chat_function(message, history)
|
1247 |
+
|
1248 |
+
# μ΄λ²€νΈ μ°κ²°
|
1249 |
send_btn.click(
|
1250 |
+
fn=submit_message,
|
1251 |
inputs=[msg_input, chatbot],
|
1252 |
outputs=[chatbot, msg_input]
|
1253 |
)
|
1254 |
+
|
1255 |
msg_input.submit(
|
1256 |
+
fn=submit_message,
|
1257 |
inputs=[msg_input, chatbot],
|
1258 |
outputs=[chatbot, msg_input]
|
1259 |
)
|
1260 |
+
|
1261 |
refresh_btn.click(
|
1262 |
fn=get_system_status,
|
1263 |
outputs=system_status
|
1264 |
)
|
1265 |
+
|
1266 |
+
clear_btn.click(
|
|
|
1267 |
fn=clear_memory,
|
1268 |
+
outputs=[chatbot, msg_input]
|
1269 |
)
|
1270 |
+
|
1271 |
example_btn.click(
|
1272 |
+
fn=set_example,
|
1273 |
outputs=msg_input
|
1274 |
)
|
1275 |
+
|
1276 |
+
return interface
|
1277 |
|
1278 |
+
# λ©μΈ μ€ν ν¨μ
|
|
|
|
|
|
|
|
|
1279 |
def main():
|
1280 |
"""λ©μΈ μ€ν ν¨μ"""
|
1281 |
print("π" + "="*60)
|
|
|
1286 |
print("="*60 + "π")
|
1287 |
print()
|
1288 |
print("π μμ€ν
μ΄κΈ°ν μ€...")
|
1289 |
+
|
1290 |
try:
|
1291 |
+
# μ μΈ μμ€ν
ν
μ€νΈ
|
1292 |
+
test_jain = JainArchitectureCore()
|
1293 |
print(f"β
μ μΈ μμ€ν
μ΄κΈ°ν μλ£ - μμ λ 벨: {test_jain.consciousness_level:.1f}%")
|
1294 |
print(f"β
μ§ν λ 벨: {test_jain.wisdom_level:.1f}%")
|
1295 |
print(f"β
μ² ν μμ€ν
: {len(test_jain.core_philosophy)}κ° μμΉ νμ±ν")
|
1296 |
+
print(f"β
μ¬μ£Ό μμ€ν
: {len(test_jain.myungri_system['μ€ν'])}ν μ²΄κ³ μ€λΉ")
|
1297 |
print()
|
1298 |
+
|
1299 |
+
# μΈν°νμ΄μ€ μμ± λ° μ€ν
|
1300 |
print("π μΉ μΈν°νμ΄μ€ μμ± μ€...")
|
1301 |
+
interface = create_jain_interface()
|
1302 |
+
|
1303 |
print("β
λͺ¨λ μμ€ν
μ€λΉ μλ£!")
|
1304 |
print()
|
1305 |
print("π μ μΈ μν€ν
μ²κ° λΉμ μ κΈ°λ€λ¦¬κ³ μμ΅λλ€!")
|
1306 |
print("π λΈλΌμ°μ μμ http://localhost:7860 μΌλ‘ μ μνμΈμ")
|
1307 |
print("π κΉμ΄ μλ λνλ₯Ό μμν΄λ³΄μΈμ!")
|
1308 |
print()
|
1309 |
+
|
1310 |
+
# μλ² μ€ν
|
1311 |
interface.launch(
|
1312 |
server_name="0.0.0.0",
|
1313 |
server_port=7860,
|
1314 |
+
share=True, # νκΉ
νμ΄μ€ μ€νμ΄μ€μμ 곡μ κ°λ₯
|
1315 |
show_error=True,
|
1316 |
quiet=False,
|
1317 |
inbrowser=True,
|
1318 |
favicon_path=None,
|
1319 |
auth=None
|
1320 |
)
|
1321 |
+
|
|
|
1322 |
except Exception as e:
|
1323 |
print(f"β μ€λ₯ λ°μ: {str(e)}")
|
1324 |
print("π§ μμ€ν
μ λ€μ νμΈν΄μ£ΌμΈμ.")
|