Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -241,43 +241,34 @@ def save_memory(purpose, history):
|
|
241 |
token=token_self,
|
242 |
repo_type="dataset",
|
243 |
)
|
|
|
244 |
|
245 |
try:
|
246 |
r = requests.get(f'{save_data}mem-test/main.json')
|
247 |
if r.status_code==200:
|
248 |
lod = json.loads(r.text)
|
249 |
-
lod = eval(lod)
|
250 |
print (lod)
|
251 |
else:
|
252 |
lod = []
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
except Exception as e:
|
255 |
print (e)
|
256 |
-
pass
|
257 |
-
lines = resp.strip().strip("\n").split("\n")
|
258 |
-
keyw_box=[]
|
259 |
-
#skill_dict={}
|
260 |
-
#option_drop=[]
|
261 |
-
for i,line in enumerate(lines):
|
262 |
-
if "keywords" in line[:16]:
|
263 |
-
keyw=line.split(":")[1]
|
264 |
-
#keyw=line
|
265 |
-
print(keyw)
|
266 |
-
lod.append({"file_name":timename,"keywords":keyw})
|
267 |
-
with open(f"tmp2-{uid}.json", "w") as outfile2:
|
268 |
-
outfile2.write(str(lod))
|
269 |
-
api.upload_file(
|
270 |
-
path_or_fileobj=f"tmp2-{uid}.json",
|
271 |
-
path_in_repo=f"/mem-test/main.json",
|
272 |
-
repo_id=reponame,
|
273 |
-
#repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
|
274 |
-
token=token_self,
|
275 |
-
repo_type="dataset",
|
276 |
-
)
|
277 |
-
|
278 |
-
#skills.append(resp)
|
279 |
-
#out=skills
|
280 |
-
#history = "result: {}\n".format(resp)
|
281 |
return [resp]
|
282 |
|
283 |
|
|
|
241 |
token=token_self,
|
242 |
repo_type="dataset",
|
243 |
)
|
244 |
+
lines = resp.strip().strip("\n").split("\n")
|
245 |
|
246 |
try:
|
247 |
r = requests.get(f'{save_data}mem-test/main.json')
|
248 |
if r.status_code==200:
|
249 |
lod = json.loads(r.text)
|
250 |
+
#lod = eval(lod)
|
251 |
print (lod)
|
252 |
else:
|
253 |
lod = []
|
254 |
+
for i,line in enumerate(lines):
|
255 |
+
if "keywords" in line[:16]:
|
256 |
+
keyw=line.split(":")[1].split("[")[1].split["]"][0]
|
257 |
+
#keyw=line
|
258 |
+
print(keyw)
|
259 |
+
lod.append({"file_name":timename,"keywords":keyw})
|
260 |
+
with open(f"tmp2-{uid}.json", "w") as outfile2:
|
261 |
+
outfile2.write(str(lod))
|
262 |
+
api.upload_file(
|
263 |
+
path_or_fileobj=f"tmp2-{uid}.json",
|
264 |
+
path_in_repo=f"/mem-test/main.json",
|
265 |
+
repo_id=reponame,
|
266 |
+
#repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
|
267 |
+
token=token_self,
|
268 |
+
repo_type="dataset",
|
269 |
+
)
|
270 |
except Exception as e:
|
271 |
print (e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
return [resp]
|
273 |
|
274 |
|