Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -438,7 +438,44 @@ def format_json(inp):
|
|
| 438 |
|
| 439 |
#if line.startswith()
|
| 440 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
def save_memory(purpose, history):
|
| 443 |
uid=uuid.uuid4()
|
| 444 |
history=str(history)
|
|
@@ -577,6 +614,7 @@ def save_memory(purpose, history):
|
|
| 577 |
ee=ee+chunk
|
| 578 |
s=s+chunk
|
| 579 |
out_box.append(resp)
|
|
|
|
| 580 |
return out_box
|
| 581 |
|
| 582 |
|
|
|
|
| 438 |
|
| 439 |
#if line.startswith()
|
| 440 |
|
| 441 |
+
def create_index():
|
| 442 |
+
|
| 443 |
+
####### load index ###############
|
| 444 |
+
r = requests.get(f'{save_data}mem-test2/index.json')
|
| 445 |
+
print(f'status code main:: {r.status_code}')
|
| 446 |
+
if r.status_code==200:
|
| 447 |
+
ind = json.loads(r.text)
|
| 448 |
+
print (f'lod:: {ind}')
|
| 449 |
+
if not r.status_code==200:
|
| 450 |
+
print("Create new IND")
|
| 451 |
+
ind = []
|
| 452 |
+
|
| 453 |
+
####### load main ###############
|
| 454 |
+
m = requests.get(f'{save_data}mem-test2/main.json')
|
| 455 |
+
print(f'status code main:: {m.status_code}')
|
| 456 |
+
|
| 457 |
+
if m.status_code==200:
|
| 458 |
+
main = json.loads(m.text)
|
| 459 |
+
print (f'lod:: {lod}')
|
| 460 |
+
if not r.status_code==200:
|
| 461 |
+
main = []
|
| 462 |
+
try:
|
| 463 |
+
for ea in main:
|
| 464 |
+
print(f"KEYWORDS:: {ea['keywords']}")
|
| 465 |
+
except Exception as e:
|
| 466 |
+
print(f"KEYWORDS:: {e}")
|
| 467 |
+
for ea in main:
|
| 468 |
+
try:
|
| 469 |
+
for k in ea['keywords']:
|
| 470 |
+
print(k)
|
| 471 |
+
ind[k]=ea['filename']
|
| 472 |
+
except Exception as e:
|
| 473 |
+
print (e)
|
| 474 |
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
|
| 479 |
def save_memory(purpose, history):
|
| 480 |
uid=uuid.uuid4()
|
| 481 |
history=str(history)
|
|
|
|
| 614 |
ee=ee+chunk
|
| 615 |
s=s+chunk
|
| 616 |
out_box.append(resp)
|
| 617 |
+
create_index()
|
| 618 |
return out_box
|
| 619 |
|
| 620 |
|