Omnibus commited on
Commit
4df7bb4
·
verified ·
1 Parent(s): 1b90f68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -1
app.py CHANGED
@@ -17,6 +17,7 @@ from agent import (
17
  PREFIX,
18
  COMPRESS_DATA_PROMPT,
19
  COMPRESS_DATA_PROMPT_SMALL,
 
20
  LOG_PROMPT,
21
  LOG_RESPONSE,
22
  )
@@ -192,6 +193,47 @@ def run_gpt(
192
  print(LOG_RESPONSE.format(resp))
193
  return resp
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
 
196
  def compress_data(c, instruct, history):
197
  seed=random.randint(1,1000000000)
@@ -377,6 +419,10 @@ def summarize(inp,history,data=None,files=None,url=None,pdf_url=None,pdf_batch=N
377
  if i == " " or i=="," or i=="\n":
378
  c +=1
379
  print (f'c2:: {c}')
 
 
 
 
380
  rawp = compress_data_og(c,inp,out)
381
  else:
382
  rawp = "Provide a valid data source"
@@ -386,7 +432,7 @@ def summarize(inp,history,data=None,files=None,url=None,pdf_url=None,pdf_batch=N
386
  #task = "complete?"
387
  history.clear()
388
  history.append((inp,rawp))
389
- yield "", history,error_box,json_out
390
 
391
  #################################
392
  def clear_fn():
 
17
  PREFIX,
18
  COMPRESS_DATA_PROMPT,
19
  COMPRESS_DATA_PROMPT_SMALL,
20
+ COMPRESS_DATA_TO_JSON_PROMPT,
21
  LOG_PROMPT,
22
  LOG_RESPONSE,
23
  )
 
193
  print(LOG_RESPONSE.format(resp))
194
  return resp
195
 
196
+ def compress_data_json(c, instruct, history):
197
+ seed=random.randint(1,1000000000)
198
+
199
+ print (c)
200
+ #tot=len(purpose)
201
+ #print(tot)
202
+ divr=int(c)/MAX_DATA
203
+ divi=int(divr)+1 if divr != int(divr) else int(divr)
204
+ chunk = int(int(c)/divr)
205
+ print(f'chunk:: {chunk}')
206
+ print(f'divr:: {divr}')
207
+ print (f'divi:: {divi}')
208
+ out = []
209
+ #out=""
210
+ s=0
211
+ e=chunk
212
+ print(f'e:: {e}')
213
+ new_history=""
214
+ #task = f'Compile this data to fulfill the task: {task}, and complete the purpose: {purpose}\n'
215
+ for z in range(divi):
216
+ print(f's:e :: {s}:{e}')
217
+
218
+ hist = history[s:e]
219
+
220
+ resp = run_gpt(
221
+ COMPRESS_DATA_TO_JSON_PROMPT,
222
+ stop_tokens=["observation:", "task:", "action:", "thought:"],
223
+ max_tokens=8192,
224
+ seed=seed,
225
+ direction=instruct,
226
+ knowledge=new_history,
227
+ history=hist,
228
+ )
229
+ #out.append(resp)
230
+ new_history = resp
231
+ print (resp)
232
+ #out+=resp
233
+ e=e+chunk
234
+ s=s+chunk
235
+ #yield out
236
+ return resp
237
 
238
  def compress_data(c, instruct, history):
239
  seed=random.randint(1,1000000000)
 
419
  if i == " " or i=="," or i=="\n":
420
  c +=1
421
  print (f'c2:: {c}')
422
+
423
+ json_final=compress_data_json(c,inp,out)
424
+
425
+
426
  rawp = compress_data_og(c,inp,out)
427
  else:
428
  rawp = "Provide a valid data source"
 
432
  #task = "complete?"
433
  history.clear()
434
  history.append((inp,rawp))
435
+ yield "", history,error_box,json_final
436
 
437
  #################################
438
  def clear_fn():