Onyxl commited on
Commit
ae7ef48
·
verified ·
1 Parent(s): a003686

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +85 -0
app.py CHANGED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # --- 🧠 THE KNOWLEDGE: FED TO GEMMA 3 ---
4
+ def gemma_3_concierge(query):
5
+ query = query.lower()
6
+ if "icard" in query:
7
+ return "Gemma 3: Tera ICards™ are currently being forged. Your identity is secure."
8
+ elif "group" in query or "squad" in query:
9
+ return "Gemma 3: Global-Main is active. Private squads can be built in Settings."
10
+ return "Gemma 3: Welcome to TeraBites™ Core. I am your guide through the mountain."
11
+
12
+ # --- 💬 THE CHAT: LOCAL LOGIC ---
13
+ def chat_response(message, history):
14
+ # Pure local session chat - No external connections
15
+ return history + [[message, "📡 [TeraBites-Core]: Message received. Protocol: Isolated."]]
16
+
17
+ # --- 🏗️ THE ARCHITECTURE ---
18
+ # Indigo and Gray theme accents to match your README metadata
19
+ with gr.Blocks(theme=gr.themes.Monochrome(), css="""
20
+ .chat-window { height: 65vh !important; border: 2px solid #4f46e5 !important; background: #050505 !important; }
21
+ .sidebar-box { border: 1px solid #4f46e5 !important; background: #000 !important; }
22
+ .support-box { border: 1px solid #4f46e5 !important; background: #111 !important; }
23
+ h1 { color: #4f46e5 !important; text-shadow: 1px 1px #000; }
24
+ .primary-btn { background: #4f46e5 !important; color: white !important; }
25
+ """) as demo:
26
+
27
+ # --- 1. THE HEADER (Identity & Support) ---
28
+ with gr.Row():
29
+ # TOP LEFT: IDENTITY
30
+ with gr.Column(scale=1, variant="panel", elem_classes="sidebar-box"):
31
+ gr.Markdown("👤 **TERA-IDENTITY**")
32
+ profile_name = gr.Textbox(value="Authenticating...", interactive=True, show_label=False)
33
+ gr.Markdown("🏆 **RANK:** RECRUIT")
34
+
35
+ # TOP CENTER: BRANDING
36
+ with gr.Column(scale=2):
37
+ gr.Markdown("<h1 style='text-align: center;'>🪐 TERABITES™ CORE</h1>")
38
+ gr.Markdown("<p style='text-align: center;'>STATUS: <b>ISOLATED SANDBOX</b></p>")
39
+
40
+ # TOP RIGHT: CUSTOMER SERVICE (Gemma 3)
41
+ with gr.Column(scale=1, variant="panel", elem_classes="support-box"):
42
+ gr.Markdown("🎧 **GEMMA 3 SERVICE**")
43
+ support_in = gr.Textbox(placeholder="Ask the Empire...", show_label=False)
44
+ support_out = gr.Markdown("*Sentinel Standing By*")
45
+
46
+ gr.Markdown("---")
47
+
48
+ # --- 2. THE BODY (Groups & The Big Gap) ---
49
+ with gr.Row():
50
+ # LEFT SIDEBAR: GROUPS
51
+ with gr.Column(scale=1):
52
+ gr.Markdown("### 📡 FREQUENCIES")
53
+ group_select = gr.Radio(
54
+ ["🌐 GLOBAL-MAIN", "📢 ANNOUNCEMENTS"],
55
+ value="🌐 GLOBAL-MAIN",
56
+ label=None
57
+ )
58
+
59
+ with gr.Accordion("⚙️ SQUAD SETTINGS", open=False):
60
+ gr.Button("Invite Link (Testing)")
61
+ gr.Button("Create New Squad", variant="secondary")
62
+
63
+ # THE BIG MIDDLE GAP (The Chat)
64
+ with gr.Column(scale=4):
65
+ chat_display = gr.Chatbot(label=None, show_label=False, elem_classes="chat-window")
66
+
67
+ # CENTER BOTTOM: THE PROMPT
68
+ with gr.Row():
69
+ msg_input = gr.Textbox(placeholder="Message TeraBites™...", scale=9, show_label=False)
70
+ send_btn = gr.Button("SUI", scale=1, variant="primary", elem_classes="primary-btn")
71
+
72
+ # --- ⚡ THE ACTIONS ---
73
+ # Sync Profile Name from Hugging Face
74
+ def sync_user(profile: gr.OAuthProfile | None):
75
+ if profile: return profile.name
76
+ return "Guest_Warrior"
77
+
78
+ demo.load(sync_user, None, profile_name)
79
+
80
+ # Support & Chat Logic
81
+ support_in.submit(gemma_3_concierge, support_in, support_out)
82
+ send_btn.click(chat_response, [msg_input, chat_display], [chat_display])
83
+ msg_input.submit(chat_response, [msg_input, chat_display], [chat_display])
84
+
85
+ demo.launch()