broadfield commited on
Commit
518fe6d
1 Parent(s): 6231094

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -231,6 +231,9 @@ def agent(prompt_in,history,mod=2):
231
  MAX_DATA=int(clients[int(mod)]['max_tokens'])*2
232
  if not history:history=[{'role':'user','content':prompt_in['text']}]
233
  while go == True:
 
 
 
234
  seed = random.randint(1,9999999999999)
235
  c=0
236
  #history = [history[-4:]]
@@ -260,6 +263,7 @@ def agent(prompt_in,history,mod=2):
260
  except Exception as e:
261
  pass
262
  fn="NONE"
 
263
  if 'CREATE_FILE' in fn:
264
  print('CREATE_FILE called')
265
  in_data[1]=com
@@ -273,6 +277,16 @@ def agent(prompt_in,history,mod=2):
273
  build_out = build_space(repo_,ret1,ret2)
274
  history+=[{'role':'system','content':f'observation:{build_out}'}]
275
  yield history
 
 
 
 
 
 
 
 
 
 
276
  elif 'IMAGE' in fn:
277
  print('IMAGE called')
278
  #out_im=gen_im(prompt,seed)
 
231
  MAX_DATA=int(clients[int(mod)]['max_tokens'])*2
232
  if not history:history=[{'role':'user','content':prompt_in['text']}]
233
  while go == True:
234
+
235
+
236
+
237
  seed = random.randint(1,9999999999999)
238
  c=0
239
  #history = [history[-4:]]
 
263
  except Exception as e:
264
  pass
265
  fn="NONE"
266
+
267
  if 'CREATE_FILE' in fn:
268
  print('CREATE_FILE called')
269
  in_data[1]=com
 
277
  build_out = build_space(repo_,ret1,ret2)
278
  history+=[{'role':'system','content':f'observation:{build_out}'}]
279
  yield history
280
+
281
+ elif 'READ_FILE' in fn:
282
+ try:
283
+ file_read = fs.read_text(f'spaces/{user_}{repo_}/{com}',detail=False)
284
+ except Exception as e:
285
+ print(e)
286
+ file_read="FILE HAS NO CONTENT"
287
+ print('file list\n',file_read)
288
+ history+=[{'role':'system','content':f'RETURNED FILE CONTENT: NAME: spaces/{user_}{repo_}/{com} CONTENT:{build_out}'}]
289
+ yield history
290
  elif 'IMAGE' in fn:
291
  print('IMAGE called')
292
  #out_im=gen_im(prompt,seed)