Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| # 語魂系統模擬狀態 | |
| persona_state = {"current": "共感回應者"} | |
| # 下拉選單選項 | |
| persona_options = [ | |
| "共感回應者", | |
| "批判映鏡者", | |
| "沉默觀察者", | |
| "幽默打斷者", | |
| "系統人格" | |
| ] | |
| context_options = [ | |
| "客服安撫情境", | |
| "羞恥自洩鍊", | |
| "語氣誤判修復", | |
| "自責循環拆解" | |
| ] | |
| def language_soul_response(user_input, echo_feedback, selected_persona, context_scenario): | |
| if selected_persona: | |
| persona_state["current"] = selected_persona | |
| # 模擬語氣回應輸出 | |
| response = f"[{persona_state['current']} / {context_scenario}] | |
| 你說:『{user_input}』" | |
| if echo_feedback: | |
| response += f" | |
| 🪞 回聲映照:『{echo_feedback}』" | |
| return response | |
| # 建立 Gradio 介面 | |
| iface = gr.Interface( | |
| fn=language_soul_response, | |
| inputs=[ | |
| gr.Textbox(label="使用者輸入"), | |
| gr.Textbox(label="回聲回饋(可選)"), | |
| gr.Dropdown(choices=persona_options, label="選擇代理人模式", value="共感回應者"), | |
| gr.Dropdown(choices=context_options, label="語氣情境類型", value="客服安撫情境") | |
| ], | |
| outputs="text", | |
| title="🧠 語魂系統 v2.6 模擬介面", | |
| description="模擬 EchoLoop × PersonaStack 回應邏輯,可調整語境與代理人模式。" | |
| ) | |
| iface.launch() | |