vpcom commited on
Commit
9aa4575
·
1 Parent(s): 3172a1f

fix: get the username and fix ui

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -20,6 +20,7 @@ PUSH_FREQUENCY = 60 # every minute
20
  HISTORY = ""
21
  PROMPT = ""
22
  USERNAME = ""
 
23
 
24
  DATA_FILENAME = "data.jsonl"
25
  DATA_FILE = os.path.join("data", DATA_FILENAME)
@@ -230,6 +231,7 @@ def vote(data: gr.LikeData):
230
  {
231
  "time_stamp": time.time(),
232
  "model_version":MODEL_VERSION,
 
233
  "username":USERNAME,
234
  "prompt": PROMPT,
235
  "history": HISTORY,
@@ -247,10 +249,13 @@ def vote(data: gr.LikeData):
247
 
248
  def hello(profile: gr.OAuthProfile | None) -> str:
249
  global USERNAME
 
250
  if profile is None:
251
  USERNAME = "guest"
 
252
  return "I don't know you. Please login:"
253
- USERNAME = profile.name
 
254
  return f"Hello {profile.name}"
255
 
256
  with gr.Blocks(css=CSS) as demo:
@@ -262,8 +267,11 @@ with gr.Blocks(css=CSS) as demo:
262
  PERSIAN GPT Trained by Mojtaba Valipour @ Data Analytics Lab
263
  """
264
  )
 
 
265
  gr.LoginButton()
266
  #gr.LogoutButton()
 
267
  gr.Markdown().attach_load_event(hello, None)
268
 
269
  chatbot.like(vote, None, None)
 
20
  HISTORY = ""
21
  PROMPT = ""
22
  USERNAME = ""
23
+ NAME = ""
24
 
25
  DATA_FILENAME = "data.jsonl"
26
  DATA_FILE = os.path.join("data", DATA_FILENAME)
 
231
  {
232
  "time_stamp": time.time(),
233
  "model_version":MODEL_VERSION,
234
+ "name":NAME,
235
  "username":USERNAME,
236
  "prompt": PROMPT,
237
  "history": HISTORY,
 
249
 
250
  def hello(profile: gr.OAuthProfile | None) -> str:
251
  global USERNAME
252
+ print(dir(profile))
253
  if profile is None:
254
  USERNAME = "guest"
255
+ NAME = "guest"
256
  return "I don't know you. Please login:"
257
+ NAME = profile.name
258
+ USERNAME = profile.username
259
  return f"Hello {profile.name}"
260
 
261
  with gr.Blocks(css=CSS) as demo:
 
267
  PERSIAN GPT Trained by Mojtaba Valipour @ Data Analytics Lab
268
  """
269
  )
270
+ with gr.Row():
271
+ with gr.Column():
272
  gr.LoginButton()
273
  #gr.LogoutButton()
274
+ with gr.Column():
275
  gr.Markdown().attach_load_event(hello, None)
276
 
277
  chatbot.like(vote, None, None)