|
@@ -112,7 +112,7 @@ def home():
|
112
|
112
|
payload = json.loads(message["content"])
|
113
|
113
|
payload["prompt"] = prompt.replace('"', '\"')
|
114
|
114
|
payload["content"] = preprocess_content(payload)
|
115
|
|
- session["history"] += [payload]
|
|
115
|
+ session["history"] += [dict(payload)] # shallow copy so history doesn't get added later on
|
116
|
116
|
except Exception as e:
|
117
|
117
|
print(repr(e))
|
118
|
118
|
session["messages"] += [{"role": "system", "content": "reply was ignored because it's not a valid json or doesn't comply with the schema. user is unaware. do not apologize to them"}]
|
|
@@ -205,7 +205,7 @@ def save():
|
205
|
205
|
if request.method=="POST":
|
206
|
206
|
filename = request.form["filename"].rsplit("/",1)[-1]
|
207
|
207
|
if filename:
|
208
|
|
- path = "archive/{}.json"
|
|
208
|
+ path = "archive/{}.json".format(filename)
|
209
|
209
|
is_overwrite = os.path.isfile(path)
|
210
|
210
|
moment = {
|
211
|
211
|
key: session.get(key, [])
|
|
@@ -214,9 +214,9 @@ def save():
|
214
|
214
|
print(moment)
|
215
|
215
|
json.dump(moment, open(path,"w"), indent=4)
|
216
|
216
|
if is_overwrite:
|
217
|
|
- flash("Successfully saved to {}.json".format(filename))
|
218
|
|
- else:
|
219
|
217
|
flash("Successfully overwritten {}.json".format(filename))
|
|
218
|
+ else:
|
|
219
|
+ flash("Successfully saved to {}.json".format(filename))
|
220
|
220
|
else:
|
221
|
221
|
flash("Invalid filename. Save aborted.", "error")
|
222
|
222
|
return redirect(url_for("home"))
|