lamgamepro1 commited on
Commit
1065657
·
verified ·
1 Parent(s): faf6cf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -4,7 +4,7 @@ import os
4
  import uuid
5
  import json
6
 
7
- # Thư viện bổ trợ
8
  try: from duckduckgo_search import DDGS
9
  except: DDGS = None
10
  try: from gtts import gTTS
@@ -26,7 +26,7 @@ def save_db(data):
26
  with open(DB_FILE, "w", encoding="utf-8") as f:
27
  json.dump(data, f, ensure_ascii=False, indent=4)
28
 
29
- # 2. GUI DESIGN (Fix Layout & Orange Button)
30
  custom_css = """
31
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Plus+Jakarta+Sans:wght@400;600&display=swap');
32
 
@@ -43,7 +43,7 @@ custom_css = """
43
  background: #0d0d12 !important;
44
  border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
45
  z-index: 1000 !important;
46
- padding: 25px !important;
47
  }
48
 
49
  .logo-text {
@@ -51,15 +51,16 @@ custom_css = """
51
  background: linear-gradient(90deg, #00f2fe, #4facfe);
52
  -webkit-background-clip: text;
53
  -webkit-text-fill-color: transparent;
54
- font-size: 24px; text-align: center; margin-bottom: 30px;
55
  }
56
 
57
- /* Nút New Workspace Màu Cam */
58
  .orange-btn {
59
  background: linear-gradient(90deg, #ff7e5f, #feb47b) !important;
60
  border: none !important;
61
  color: white !important;
62
  font-weight: bold !important;
 
63
  }
64
 
65
  /* Chat Area */
@@ -67,14 +68,14 @@ custom_css = """
67
  margin-left: 260px !important;
68
  width: calc(100% - 260px) !important;
69
  height: 100vh !important;
70
- padding: 20px 50px !important;
71
  }
72
 
73
  .gr-chatbot {
74
  background: transparent !important;
75
  border: none !important;
76
  height: 75vh !important;
77
- margin-bottom: 110px !important;
78
  }
79
 
80
  /* Thanh nhập liệu cố định */
@@ -86,7 +87,7 @@ custom_css = """
86
  background: #16161e !important;
87
  border: 1px solid rgba(0, 242, 254, 0.2) !important;
88
  border-radius: 16px !important;
89
- padding: 10px !important;
90
  z-index: 2000 !important;
91
  }
92
 
@@ -135,10 +136,15 @@ with gr.Blocks(title="NodeAI Genesis") as demo:
135
  chat_store = gr.State(load_db())
136
  session_id = gr.State(str(uuid.uuid4()))
137
 
 
138
  with gr.Column(elem_classes="sidebar-node"):
139
- gr.HTML("<div class='logo-text'>NODEAI</div>")
140
- # Nút cam chuyên nghiệp
 
 
 
141
  new_btn = gr.Button("+ NEW WORKSPACE", variant="primary", elem_classes="orange-btn")
 
142
  with gr.Column():
143
  @gr.render(inputs=chat_store)
144
  def render_history(store):
@@ -146,15 +152,15 @@ with gr.Blocks(title="NodeAI Genesis") as demo:
146
  btn = gr.Button(f"◈ {store[sid]['title']}", variant="ghost")
147
  btn.click(lambda s=sid: (store[s]["history"], s), None, [chatbot, session_id])
148
 
 
149
  with gr.Column(elem_classes="chat-main"):
150
- # Đã xóa bubble_full_width để fix lỗi
151
  chatbot = gr.Chatbot(show_label=False)
152
  audio_out = gr.Audio(autoplay=True, visible=False)
153
 
154
  with gr.Row(elem_classes="input-fixed-bottom"):
155
  msg_input = gr.MultimodalTextbox(
156
  show_label=False,
157
- placeholder="Message NodeAI Genesis...",
158
  container=False
159
  )
160
 
@@ -165,5 +171,5 @@ with gr.Blocks(title="NodeAI Genesis") as demo:
165
  new_btn.click(lambda: ([], str(uuid.uuid4())), None, [chatbot, session_id])
166
 
167
  if __name__ == "__main__":
168
- # Đăng nhập bằng Hugging Face (auth=None + login_button=True)
169
- demo.launch(auth=None, login_button=True, css=custom_css)
 
4
  import uuid
5
  import json
6
 
7
+ # Thư viện hỗ trợ
8
  try: from duckduckgo_search import DDGS
9
  except: DDGS = None
10
  try: from gtts import gTTS
 
26
  with open(DB_FILE, "w", encoding="utf-8") as f:
27
  json.dump(data, f, ensure_ascii=False, indent=4)
28
 
29
+ # 2. GUI DESIGN (Fix Layout & Orange Theme)
30
  custom_css = """
31
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Plus+Jakarta+Sans:wght@400;600&display=swap');
32
 
 
43
  background: #0d0d12 !important;
44
  border-right: 1px solid rgba(255, 255, 255, 0.05) !important;
45
  z-index: 1000 !important;
46
+ padding: 20px !important;
47
  }
48
 
49
  .logo-text {
 
51
  background: linear-gradient(90deg, #00f2fe, #4facfe);
52
  -webkit-background-clip: text;
53
  -webkit-text-fill-color: transparent;
54
+ font-size: 22px; text-align: center; margin-bottom: 20px;
55
  }
56
 
57
+ /* Nút Cam Pro */
58
  .orange-btn {
59
  background: linear-gradient(90deg, #ff7e5f, #feb47b) !important;
60
  border: none !important;
61
  color: white !important;
62
  font-weight: bold !important;
63
+ margin-top: 10px !important;
64
  }
65
 
66
  /* Chat Area */
 
68
  margin-left: 260px !important;
69
  width: calc(100% - 260px) !important;
70
  height: 100vh !important;
71
+ padding: 20px 40px !important;
72
  }
73
 
74
  .gr-chatbot {
75
  background: transparent !important;
76
  border: none !important;
77
  height: 75vh !important;
78
+ margin-bottom: 100px !important;
79
  }
80
 
81
  /* Thanh nhập liệu cố định */
 
87
  background: #16161e !important;
88
  border: 1px solid rgba(0, 242, 254, 0.2) !important;
89
  border-radius: 16px !important;
90
+ padding: 5px 15px !important;
91
  z-index: 2000 !important;
92
  }
93
 
 
136
  chat_store = gr.State(load_db())
137
  session_id = gr.State(str(uuid.uuid4()))
138
 
139
+ # Sidebar
140
  with gr.Column(elem_classes="sidebar-node"):
141
+ gr.HTML("<div class='logo-text'>NODEAI GENESIS</div>")
142
+
143
+ # ĐĂNG NHẬP CHÍNH CHỦ HUGGING FACE
144
+ gr.LoginButton(value="Đăng nhập HF")
145
+
146
  new_btn = gr.Button("+ NEW WORKSPACE", variant="primary", elem_classes="orange-btn")
147
+
148
  with gr.Column():
149
  @gr.render(inputs=chat_store)
150
  def render_history(store):
 
152
  btn = gr.Button(f"◈ {store[sid]['title']}", variant="ghost")
153
  btn.click(lambda s=sid: (store[s]["history"], s), None, [chatbot, session_id])
154
 
155
+ # Main area
156
  with gr.Column(elem_classes="chat-main"):
 
157
  chatbot = gr.Chatbot(show_label=False)
158
  audio_out = gr.Audio(autoplay=True, visible=False)
159
 
160
  with gr.Row(elem_classes="input-fixed-bottom"):
161
  msg_input = gr.MultimodalTextbox(
162
  show_label=False,
163
+ placeholder="Hỏi NodeAI bất cứ điều gì...",
164
  container=False
165
  )
166
 
 
171
  new_btn.click(lambda: ([], str(uuid.uuid4())), None, [chatbot, session_id])
172
 
173
  if __name__ == "__main__":
174
+ # Đã xóa login_button ở đây vì đã dùng gr.LoginButton() ở trên
175
+ demo.launch(css=custom_css)