Xyro123 commited on
Commit
e48d3bb
·
verified ·
1 Parent(s): 9e858ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -17
app.py CHANGED
@@ -62,13 +62,15 @@ def gemini_response(prompt):
62
  # 🌙 CHAT FUNCTION
63
  # ======================
64
 
65
- def chat_fn(prompt, history):
66
- history = history or []
67
- history.append({"role": "user", "content": prompt})
 
68
  time.sleep(0.5) # simulate typing
69
- reply = gemini_response(prompt)
70
- history.append({"role": "bot", "content": reply})
71
- return history, history
 
72
 
73
  # ======================
74
  # 🌟 UI CSS
@@ -90,32 +92,22 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as app:
90
 
91
  gr.Markdown("## 🔐 Welcome to ZeppFusion Login System")
92
 
93
- # ======================
94
  # Tabs: Login / Signup
95
- # ======================
96
  with gr.Tabs() as tabs:
97
 
98
- # -------------------
99
- # LOGIN TAB
100
- # -------------------
101
  with gr.Tab("Login") as login_tab:
102
  log_user = gr.Textbox(label="Username")
103
  log_pw = gr.Textbox(label="Password", type="password")
104
  log_status = gr.Textbox(label="Status", interactive=False)
105
  log_btn = gr.Button("Login")
106
 
107
- # -------------------
108
- # SIGNUP TAB
109
- # -------------------
110
  with gr.Tab("Signup"):
111
  reg_user = gr.Textbox(label="New Username")
112
  reg_pw = gr.Textbox(label="New Password", type="password")
113
  reg_status = gr.Textbox(label="Status", interactive=False)
114
  reg_btn = gr.Button("Signup")
115
 
116
- # ======================
117
  # Chat UI (hidden initially)
118
- # ======================
119
  with gr.Group(visible=False) as chat_ui:
120
  with gr.Row():
121
  gr.Image(value=logo_path, show_label=False)
@@ -141,7 +133,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as app:
141
  def login_action(username, password):
142
  res = login(username, password)
143
  if res == "SUCCESS":
144
- # Hide login/signup tabs & show chat UI
145
  return "✅ Амжилттай нэвтэрлээ!", gr.update(visible=False), gr.update(visible=True)
146
  return res, gr.update(visible=True), gr.update(visible=False)
147
 
 
62
  # 🌙 CHAT FUNCTION
63
  # ======================
64
 
65
+ def chat_fn(message, chat_history):
66
+ chat_history = chat_history or []
67
+ # Хэрэглэгчийн мессеж нэмэх
68
+ chat_history.append({"role": "user", "content": message})
69
  time.sleep(0.5) # simulate typing
70
+ # Gemini reply нэмэх
71
+ reply = gemini_response(message)
72
+ chat_history.append({"role": "assistant", "content": reply})
73
+ return chat_history, chat_history
74
 
75
  # ======================
76
  # 🌟 UI CSS
 
92
 
93
  gr.Markdown("## 🔐 Welcome to ZeppFusion Login System")
94
 
 
95
  # Tabs: Login / Signup
 
96
  with gr.Tabs() as tabs:
97
 
 
 
 
98
  with gr.Tab("Login") as login_tab:
99
  log_user = gr.Textbox(label="Username")
100
  log_pw = gr.Textbox(label="Password", type="password")
101
  log_status = gr.Textbox(label="Status", interactive=False)
102
  log_btn = gr.Button("Login")
103
 
 
 
 
104
  with gr.Tab("Signup"):
105
  reg_user = gr.Textbox(label="New Username")
106
  reg_pw = gr.Textbox(label="New Password", type="password")
107
  reg_status = gr.Textbox(label="Status", interactive=False)
108
  reg_btn = gr.Button("Signup")
109
 
 
110
  # Chat UI (hidden initially)
 
111
  with gr.Group(visible=False) as chat_ui:
112
  with gr.Row():
113
  gr.Image(value=logo_path, show_label=False)
 
133
  def login_action(username, password):
134
  res = login(username, password)
135
  if res == "SUCCESS":
136
+ # Login/signup tab-г hide хийж, chat UI-г гаргах
137
  return "✅ Амжилттай нэвтэрлээ!", gr.update(visible=False), gr.update(visible=True)
138
  return res, gr.update(visible=True), gr.update(visible=False)
139