Omnibus commited on
Commit
9cf40df
·
verified ·
1 Parent(s): 810db6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -10,6 +10,7 @@ import datetime
10
  import xmltodict
11
 
12
  from prompts import (
 
13
  COMPRESS_HISTORY_PROMPT,
14
  COMPRESS_DATA_PROMPT,
15
  COMPRESS_DATA_PROMPT_SMALL,
@@ -141,8 +142,36 @@ def compress_data(c,purpose, task, history):
141
 
142
 
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  def summarize(inp,history,data=None):
145
 
 
146
  json_box=[]
147
  if inp == "":
148
  inp = "Process this data"
@@ -305,6 +334,7 @@ def find_rss():
305
  )
306
  yield out_box,[(None,f'Source is current as of:\n{timestamp} UTC\n\nThe current Date and Time is:\n{timestamp} UTC')]
307
 
 
308
  def load_data():
309
  yield None,[(None,f'Loading data source, please wait')]
310
 
@@ -330,10 +360,12 @@ with gr.Blocks() as app:
330
  sub_btn=gr.Button("Submit")
331
  with gr.Row():
332
  load_btn = gr.Button("Load RSS")
333
- u_btn=gr.Button("Update [RSS Data]")
 
334
  with gr.Row():
335
  out_json = gr.JSON()
336
  fil = gr.Textbox()
 
337
  load_btn.click(load_data,None,[out_json,cb])
338
  u_btn.click(find_rss,None,[out_json,cb])
339
  sub_btn.click(summarize,[inst,cb,out_json],[inst,cb])
 
10
  import xmltodict
11
 
12
  from prompts import (
13
+ GET_KEYWORD,
14
  COMPRESS_HISTORY_PROMPT,
15
  COMPRESS_DATA_PROMPT,
16
  COMPRESS_DATA_PROMPT_SMALL,
 
142
 
143
 
144
 
145
+ def get_key(inp,data):
146
+ key_box=[]
147
+ seed=random.randint(1,1000000000)
148
+ key_w = run_gpt(
149
+ GET_KEYWORD,
150
+ stop_tokens=[],
151
+ max_tokens=56,
152
+ seed=seed,
153
+ purpose=inp,
154
+ task=inp,
155
+ )
156
+ print(f'key_w::{key_w}')
157
+ if " " in key_w:
158
+ key_w=key_w.split(" ")[-1]
159
+ for i,ea in enumerate(data):
160
+ try:
161
+ if ea['title'] and key_w in ea['title']:
162
+ key_box.append(ea)
163
+ elif ea['description'] and key_w in ea['description']:
164
+ key_box.append(ea)
165
+ elif ea['link'] and key_w in ea['link']:
166
+ key_box.append(ea)
167
+ except Exception as e:
168
+ print(e)
169
+ print(key_box)
170
+
171
+
172
  def summarize(inp,history,data=None):
173
 
174
+
175
  json_box=[]
176
  if inp == "":
177
  inp = "Process this data"
 
334
  )
335
  yield out_box,[(None,f'Source is current as of:\n{timestamp} UTC\n\nThe current Date and Time is:\n{timestamp} UTC')]
336
 
337
+
338
  def load_data():
339
  yield None,[(None,f'Loading data source, please wait')]
340
 
 
360
  sub_btn=gr.Button("Submit")
361
  with gr.Row():
362
  load_btn = gr.Button("Load RSS")
363
+ u_btn=gr.Button("Update [RSS Data]")
364
+ keyw = gr.Button("Use Keyword [Experimental]")
365
  with gr.Row():
366
  out_json = gr.JSON()
367
  fil = gr.Textbox()
368
+ keyw.click(get_key,[inst,out_json],None)
369
  load_btn.click(load_data,None,[out_json,cb])
370
  u_btn.click(find_rss,None,[out_json,cb])
371
  sub_btn.click(summarize,[inst,cb,out_json],[inst,cb])