broadfield commited on
Commit
02fa11b
·
verified ·
1 Parent(s): 59a88ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -144,8 +144,9 @@ def parse_json(inp):
144
  def build_space(repo_name,file_name,file_content,access_token=""):
145
  try:
146
  repo_path=user_+str(repo_)
147
- if not access_token:access_token=os.environ['HF_TOKEN']
148
-
 
149
  api=HfApi(endpoint="https://huggingface.co", token=access_token)
150
  repo_url = api.create_repo(
151
  repo_id=repo_path,
@@ -238,6 +239,10 @@ def agent(prompt_in,history,mod=2,tok_in=""):
238
  print('ret1',ret1)
239
  print('ret2',ret2)
240
  build_out = build_space(repo_,ret1,ret2,access_token=tok_in)
 
 
 
 
241
  history+=[{'role':'system','content':f'observation:{build_out}'}]
242
  yield history
243
 
 
144
  def build_space(repo_name,file_name,file_content,access_token=""):
145
  try:
146
  repo_path=user_+str(repo_)
147
+ if not access_token:
148
+ #access_token=os.environ['HF_TOKEN']
149
+ return [{'role':'assistant','content': 'ENTER A HUGGINGFACE TOKEN'}]
150
  api=HfApi(endpoint="https://huggingface.co", token=access_token)
151
  repo_url = api.create_repo(
152
  repo_id=repo_path,
 
239
  print('ret1',ret1)
240
  print('ret2',ret2)
241
  build_out = build_space(repo_,ret1,ret2,access_token=tok_in)
242
+ if build_out[0].content=="ENTER A HUGGINGFACE TOKEN":
243
+ yield [{'role':'assistant','content':"ENTER A HUGGINGFACE TOKEN"}]
244
+ go=False
245
+ break
246
  history+=[{'role':'system','content':f'observation:{build_out}'}]
247
  yield history
248