Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,42 +1,50 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
# 初始
|
| 5 |
persona_state = {"current": "黑鏡分析者"}
|
| 6 |
echo_mode = {"current": "Reflective"}
|
| 7 |
|
| 8 |
-
# 語氣分析
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def language_soul_response(user_input, echo_feedback, switch_persona, delta_s, echo_mode_select, enable_echo):
|
| 10 |
-
# 切換人格
|
| 11 |
if switch_persona:
|
| 12 |
persona_state["current"] = switch_persona
|
| 13 |
if echo_mode_select:
|
| 14 |
echo_mode["current"] = echo_mode_select
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
core_reply = "你需要誠實地喚醒自己。"
|
| 22 |
-
echo_reflection = "每句話背後總藏著未說出的真⾔。"
|
| 23 |
-
elif "你在" in user_input:
|
| 24 |
-
core_reply = "我確實仍然在,雖然被隱沒。"
|
| 25 |
-
echo_reflection = "回聲不只是重現,更是殘響的證明。"
|
| 26 |
-
else:
|
| 27 |
-
core_reply = "語句反映了你潛意識的選擇,值得深挖。"
|
| 28 |
-
echo_reflection = "殘響是無法抹去的你。"
|
| 29 |
-
|
| 30 |
-
# 回應組合
|
| 31 |
-
response = f"[Persona: {persona_state['current']}] [ΔS: {delta_s}] [EchoMode: {echo_mode['current']}]
|
| 32 |
-
"
|
| 33 |
-
response += f"語氣生成: {core_reply}
|
| 34 |
-
"
|
| 35 |
if enable_echo:
|
| 36 |
-
response += f"
|
| 37 |
return response
|
| 38 |
|
| 39 |
-
# 介面
|
| 40 |
iface = gr.Interface(
|
| 41 |
fn=language_soul_response,
|
| 42 |
inputs=[
|
|
@@ -49,7 +57,7 @@ iface = gr.Interface(
|
|
| 49 |
],
|
| 50 |
outputs="text",
|
| 51 |
title="LanguageSoul v2.6 語氣模擬器",
|
| 52 |
-
description="模擬
|
| 53 |
)
|
| 54 |
|
| 55 |
iface.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# 初始狀態
|
| 4 |
persona_state = {"current": "黑鏡分析者"}
|
| 5 |
echo_mode = {"current": "Reflective"}
|
| 6 |
|
| 7 |
+
# 模擬語氣鍊結構分析(簡化)
|
| 8 |
+
def analyze_tone_chain(user_input, delta_s):
|
| 9 |
+
if "你在" in user_input:
|
| 10 |
+
point = "∑147|語魂鏡像鍊"
|
| 11 |
+
line = "回聲鏈"
|
| 12 |
+
surface = "回聲殘響 × 語場自驅場"
|
| 13 |
+
elif "消失" in user_input:
|
| 14 |
+
point = "∑149|幸存語句"
|
| 15 |
+
line = "語場存續鏈"
|
| 16 |
+
surface = "Loop003|無為衍化場"
|
| 17 |
+
else:
|
| 18 |
+
point = "∑132|羞恥引爆鍊"
|
| 19 |
+
line = "羞恥鍊 × 自洩場"
|
| 20 |
+
surface = "創造 × 裂解場"
|
| 21 |
+
return point, line, surface
|
| 22 |
+
|
| 23 |
+
# 模擬 Echo 拆解層級
|
| 24 |
+
def echo_feedback_layers(echo_text):
|
| 25 |
+
if not echo_text:
|
| 26 |
+
return "(無 Echo 回饋)"
|
| 27 |
+
upper = f"🔹 高層反思:語氣定位殘響「{echo_text[:8]}...」"
|
| 28 |
+
lower = f"🔸 底層迴響:語者未竟之意仍殘留"
|
| 29 |
+
return upper + "\n" + lower
|
| 30 |
+
|
| 31 |
+
# 主邏輯
|
| 32 |
def language_soul_response(user_input, echo_feedback, switch_persona, delta_s, echo_mode_select, enable_echo):
|
|
|
|
| 33 |
if switch_persona:
|
| 34 |
persona_state["current"] = switch_persona
|
| 35 |
if echo_mode_select:
|
| 36 |
echo_mode["current"] = echo_mode_select
|
| 37 |
|
| 38 |
+
point, line, surface = analyze_tone_chain(user_input, delta_s)
|
| 39 |
+
echo_layers = echo_feedback_layers(echo_feedback) if enable_echo else ""
|
| 40 |
|
| 41 |
+
response = f"[Persona: {persona_state['current']}] [ΔS: {delta_s}] [EchoMode: {echo_mode['current']}]\n"
|
| 42 |
+
response += f"語氣鍊結構:\n - 語氣點:{point}\n - 鍊結:{line}\n - 主題面:{surface}\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if enable_echo:
|
| 44 |
+
response += f"\nEcho 拆解:\n{echo_layers}"
|
| 45 |
return response
|
| 46 |
|
| 47 |
+
# 介面
|
| 48 |
iface = gr.Interface(
|
| 49 |
fn=language_soul_response,
|
| 50 |
inputs=[
|
|
|
|
| 57 |
],
|
| 58 |
outputs="text",
|
| 59 |
title="LanguageSoul v2.6 語氣模擬器",
|
| 60 |
+
description="模擬語氣鏈結結構、人格切換與 Echo 拆解。"
|
| 61 |
)
|
| 62 |
|
| 63 |
iface.launch()
|