Geraldine commited on
Commit
1517d22
·
verified ·
1 Parent(s): 3db7169

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -18,7 +18,11 @@ display_app_header()
18
  # UI sidebar parameters ####################################
19
  st.sidebar.header("Loging")
20
  if hg_token :=st.sidebar.text_input('Enter your HG token'):
21
- st.sidebar.info('Logged', icon="ℹ️")
 
 
 
 
22
  else:
23
  st.sidebar.warning("enter your token")
24
 
@@ -199,9 +203,9 @@ if selected_task :
199
  response = None
200
  task = dict_hg_tasks[selected_task]
201
  if model:
202
- client = InferenceClient(model=model,token=hg_token)
203
  else:
204
- client = InferenceClient(token=hg_token)
205
  uploaded_input,url_input,text_input = display_inputs(task)
206
  prompt_input = display_prompt(task)
207
  context_input = display_context(task)
 
18
  # UI sidebar parameters ####################################
19
  st.sidebar.header("Loging")
20
  if hg_token :=st.sidebar.text_input('Enter your HG token'):
21
+ try:
22
+ subprocess.check_call(["huggingface-cli", "login", "--token", hg_token])
23
+ st.sidebar.info('Logged', icon="ℹ️")
24
+ except subprocess.CalledProcessError:
25
+ st.sidebar.error('Error with token, try again', icon="⚠️")
26
  else:
27
  st.sidebar.warning("enter your token")
28
 
 
203
  response = None
204
  task = dict_hg_tasks[selected_task]
205
  if model:
206
+ client = InferenceClient(model=model)
207
  else:
208
+ client = InferenceClient()
209
  uploaded_input,url_input,text_input = display_inputs(task)
210
  prompt_input = display_prompt(task)
211
  context_input = display_context(task)