Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import random
|
|
8 |
import json
|
9 |
import datetime
|
10 |
import xmltodict
|
11 |
-
|
12 |
from prompts import (
|
13 |
COMPRESS_HISTORY_PROMPT,
|
14 |
COMPRESS_DATA_PROMPT,
|
@@ -112,7 +112,7 @@ def compress_data(c,purpose, task, history, result):
|
|
112 |
hist = history[s:e]
|
113 |
|
114 |
resp = run_gpt(
|
115 |
-
|
116 |
stop_tokens=["observation:", "task:", "action:", "thought:"],
|
117 |
max_tokens=2048,
|
118 |
seed=seed,
|
@@ -142,61 +142,46 @@ def compress_data(c,purpose, task, history, result):
|
|
142 |
history = "result: {}\n".format(resp)
|
143 |
return history
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
cnt=0
|
170 |
-
cnt+=len(rawp)
|
171 |
-
out.append(rawp)
|
172 |
-
out = str(out)
|
173 |
rl = len(out)
|
174 |
print(f'rl:: {rl}')
|
175 |
-
c=
|
176 |
for i in str(out):
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
task = "compile report and return action: COMPLETE"
|
190 |
-
return "MAIN", None, history, task, result
|
191 |
-
else:
|
192 |
-
history += "observation: An Error occured\nI need to trigger a search using the following syntax:\naction: READ-RSS action_input=URL\n"
|
193 |
-
return "UPDATE-TASK", None, history, task, result
|
194 |
-
except Exception as e:
|
195 |
-
print (e)
|
196 |
-
history += "observation: I need to trigger a search using the following syntax:\naction: READ-RSS action_input=URL\n"
|
197 |
-
return "UPDATE-TASK", None, history, task, result
|
198 |
-
return "MAIN", None, history, task, result
|
199 |
-
"""
|
200 |
def find_rss():
|
201 |
lod=""
|
202 |
out_box=[]
|
@@ -280,6 +265,6 @@ with gr.Blocks() as app:
|
|
280 |
fil = gr.Textbox()
|
281 |
r_btn.click(find_rss,None,[out_json,cb])
|
282 |
#r_btn.click(read_rss,None,[out_json,fil])
|
283 |
-
|
284 |
#btn.click(get_rss,rss,out_json)
|
285 |
app.launch()
|
|
|
8 |
import json
|
9 |
import datetime
|
10 |
import xmltodict
|
11 |
+
|
12 |
from prompts import (
|
13 |
COMPRESS_HISTORY_PROMPT,
|
14 |
COMPRESS_DATA_PROMPT,
|
|
|
112 |
hist = history[s:e]
|
113 |
|
114 |
resp = run_gpt(
|
115 |
+
COMPRESS_DATA_PROMPT_SMALL,
|
116 |
stop_tokens=["observation:", "task:", "action:", "thought:"],
|
117 |
max_tokens=2048,
|
118 |
seed=seed,
|
|
|
142 |
history = "result: {}\n".format(resp)
|
143 |
return history
|
144 |
|
145 |
+
|
146 |
+
|
147 |
+
def summarize(inp,history,data=None):
|
148 |
+
json_box=[]
|
149 |
+
if inp == "":
|
150 |
+
inp = "Process this data"
|
151 |
+
history.clear()
|
152 |
+
history = [(inp,"Working on it...")]
|
153 |
+
yield "",history
|
154 |
+
|
155 |
+
if data != "Error" and data != "":
|
156 |
+
print(inp)
|
157 |
+
out = str(data)
|
158 |
+
rl = len(out)
|
159 |
+
print(f'rl:: {rl}')
|
160 |
+
c=1
|
161 |
+
for i in str(out):
|
162 |
+
if i == " " or i=="," or i=="\n":
|
163 |
+
c +=1
|
164 |
+
print (f'c:: {c}')
|
165 |
+
|
166 |
+
json_out = compress_data(c,inp,out)
|
167 |
+
out = str(json_out)
|
168 |
+
if report_check:
|
|
|
|
|
|
|
|
|
169 |
rl = len(out)
|
170 |
print(f'rl:: {rl}')
|
171 |
+
c=1
|
172 |
for i in str(out):
|
173 |
+
if i == " " or i=="," or i=="\n":
|
174 |
+
c +=1
|
175 |
+
print (f'c2:: {c}')
|
176 |
+
rawp = compress_data_og(c,inp,out)
|
177 |
+
else:
|
178 |
+
rawp = out
|
179 |
+
else:
|
180 |
+
rawp = "Provide a valid data source"
|
181 |
+
history.append((inp,rawp))
|
182 |
+
yield "", history
|
183 |
+
|
184 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
def find_rss():
|
186 |
lod=""
|
187 |
out_box=[]
|
|
|
265 |
fil = gr.Textbox()
|
266 |
r_btn.click(find_rss,None,[out_json,cb])
|
267 |
#r_btn.click(read_rss,None,[out_json,fil])
|
268 |
+
search_btn.click(summarize,[rss_search,cb,out_json],[rss_search,cb])
|
269 |
#btn.click(get_rss,rss,out_json)
|
270 |
app.launch()
|