Omnibus commited on
Commit
366537d
·
verified ·
1 Parent(s): 9835c49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -2
app.py CHANGED
@@ -162,7 +162,53 @@ def summarize(inp,history,data=None):
162
  c +=1
163
  print (f'c:: {c}')
164
 
165
- json_out = compress_data(c,inp,task,out)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  out = str(json_out)
167
  rawp = out
168
  else:
@@ -241,7 +287,7 @@ def find_rss():
241
  yield out_box,[(None,'Sources are loaded. You can ask a question about them now.')]
242
 
243
  with gr.Blocks() as app:
244
- cb = gr.Chatbot()
245
  with gr.Row():
246
  rss_search = gr.Textbox(label="Instructions")
247
  search_btn=gr.Button("Send")
 
162
  c +=1
163
  print (f'c:: {c}')
164
 
165
+ #json_out = compress_data(c,inp,task,out)
166
+
167
+ #def compress_data(c,purpose, task, history):
168
+ purpose=inp
169
+ seed=random.randint(1,1000000000)
170
+ print (c)
171
+ divr=int(c)/MAX_DATA
172
+ divi=int(divr)+1 if divr != int(divr) else int(divr)
173
+ chunk = int(int(c)/divr)
174
+ print(f'chunk:: {chunk}')
175
+ print(f'divr:: {divr}')
176
+ print (f'divi:: {divi}')
177
+ out = []
178
+ #out=""
179
+ s=0
180
+ e=chunk
181
+ print(f'e:: {e}')
182
+ new_history=""
183
+ task = f'Compile this data to fulfill the task: {task}, and complete the purpose: {purpose}\n'
184
+ for z in range(divi):
185
+ print(f's:e :: {s}:{e}')
186
+ mes= f'Working on data chunk: {s}:{e}'
187
+ hist = out[s:e]
188
+ yield "", (inp,f'{mes}\n{history}')
189
+
190
+ resp = run_gpt(
191
+ COMPRESS_DATA_PROMPT,
192
+ stop_tokens=["observation:", "task:", "action:", "thought:"],
193
+ max_tokens=2048,
194
+ seed=seed,
195
+ purpose=purpose,
196
+ task=task,
197
+ knowledge=new_history,
198
+ history=hist,
199
+ ).strip("\n")
200
+ new_history = resp
201
+ print (resp)
202
+ out+=resp
203
+ e=e+chunk
204
+ s=s+chunk
205
+ history = "preliminary result: {}\n".format(resp)
206
+ yield "", (inp,f'{mes}\n{history}')
207
+ print ("final" + resp)
208
+ history = "result: {}\n".format(resp)
209
+ #return history
210
+ yield "", (inp,history)
211
+
212
  out = str(json_out)
213
  rawp = out
214
  else:
 
287
  yield out_box,[(None,'Sources are loaded. You can ask a question about them now.')]
288
 
289
  with gr.Blocks() as app:
290
+ cb = gr.Chatbot(height=500)
291
  with gr.Row():
292
  rss_search = gr.Textbox(label="Instructions")
293
  search_btn=gr.Button("Send")