Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -243,40 +243,38 @@ def save_memory(purpose, history):
|
|
243 |
repo_type="dataset",
|
244 |
)
|
245 |
lines = resp.strip().strip("\n").split("\n")
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
except Exception as e:
|
279 |
-
print (e)
|
280 |
return [resp]
|
281 |
|
282 |
|
|
|
243 |
repo_type="dataset",
|
244 |
)
|
245 |
lines = resp.strip().strip("\n").split("\n")
|
246 |
+
r = requests.get(f'{save_data}mem-test/main.json')
|
247 |
+
print(f'status code main:: {r.status_code}')
|
248 |
+
if r.status_code==200:
|
249 |
+
|
250 |
+
lod = json.loads(r.text)
|
251 |
+
lod = eval(lod)
|
252 |
+
print (f'lod:: {lod}')
|
253 |
+
else:
|
254 |
+
lod = []
|
255 |
+
for i,line in enumerate(lines):
|
256 |
+
if ":" in line:
|
257 |
+
print(f'line:: {line}')
|
258 |
+
|
259 |
+
if "keywords" in line[:16]:
|
260 |
+
print(f'trying:: {line}')
|
261 |
+
keyw=line.split(":")[1]
|
262 |
+
print (keyw)
|
263 |
+
print (keyw.split("[")[1].split("]")[0])
|
264 |
+
keyw=keyw.split("[")[1].split("]")[0]
|
265 |
+
print(keyw)
|
266 |
+
lod.append({"file_name":timename,"keywords":[str(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 |
return [resp]
|
279 |
|
280 |
|