Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,15 @@ def save_json(data):
|
|
| 15 |
timestamp = int(time.time())
|
| 16 |
filename = f"{timestamp}.json"
|
| 17 |
filepath = f"./requests_from_users/{filename}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
with open(filepath, 'w') as json_file:
|
| 19 |
json.dump(data, json_file)
|
| 20 |
|
|
|
|
| 15 |
timestamp = int(time.time())
|
| 16 |
filename = f"{timestamp}.json"
|
| 17 |
filepath = f"./requests_from_users/{filename}"
|
| 18 |
+
docs = data['context']
|
| 19 |
+
list_docs = []
|
| 20 |
+
for doc in docs:
|
| 21 |
+
dict_doc = {
|
| 22 |
+
'page_content': doc.page_content,
|
| 23 |
+
'metadata': doc.metadata
|
| 24 |
+
}
|
| 25 |
+
list_docs.append(dict_doc)
|
| 26 |
+
data['context'] = list_docs
|
| 27 |
with open(filepath, 'w') as json_file:
|
| 28 |
json.dump(data, json_file)
|
| 29 |
|