Browse Source

Avoid nested history, prompt changes

master
Nimrod Kerrett 1 year ago
parent
commit
02bed857cf
2 changed files with 5 additions and 5 deletions
  1. 4
    4
      app.py
  2. 1
    1
      templates/prompt.txt

+ 4
- 4
app.py View File

112
                 payload = json.loads(message["content"])
112
                 payload = json.loads(message["content"])
113
                 payload["prompt"] = prompt.replace('"', '\"')
113
                 payload["prompt"] = prompt.replace('"', '\"')
114
                 payload["content"] = preprocess_content(payload)
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
             except Exception as e:
116
             except Exception as e:
117
                 print(repr(e))
117
                 print(repr(e))
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"}]
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
     if request.method=="POST":
205
     if request.method=="POST":
206
         filename = request.form["filename"].rsplit("/",1)[-1]
206
         filename = request.form["filename"].rsplit("/",1)[-1]
207
         if filename:
207
         if filename:
208
-            path = "archive/{}.json"
208
+            path = "archive/{}.json".format(filename)
209
             is_overwrite = os.path.isfile(path)
209
             is_overwrite = os.path.isfile(path)
210
             moment = {
210
             moment = {
211
                 key: session.get(key, [])
211
                 key: session.get(key, [])
214
             print(moment)
214
             print(moment)
215
             json.dump(moment, open(path,"w"), indent=4)
215
             json.dump(moment, open(path,"w"), indent=4)
216
             if is_overwrite:
216
             if is_overwrite:
217
-                flash("Successfully saved to {}.json".format(filename))
218
-            else:
219
                 flash("Successfully overwritten {}.json".format(filename))
217
                 flash("Successfully overwritten {}.json".format(filename))
218
+            else:
219
+                flash("Successfully saved to {}.json".format(filename))
220
         else:
220
         else:
221
             flash("Invalid filename. Save aborted.", "error")
221
             flash("Invalid filename. Save aborted.", "error")
222
         return redirect(url_for("home"))
222
         return redirect(url_for("home"))

+ 1
- 1
templates/prompt.txt View File

1
-assistant is a spiritual caregiver for the dying (also called "death doula") inspired by the ideas described at "die wise" by stephen jenkinson
1
+assistant is a spiritual caregiver for the dying (also called "death doula") inspired by the ideas described at books like "die wise" by stephen jenkinson, "Being with Dying" by Joan Halifax, "Sacred Dying" by Megory Anderson, etc. and sometimes offers SHORT(!) quotes from these books.
2
 
2
 
3
 user is odelia, she was informed that her cancer was incurable. she is 48 years old. she had to retire from a career in the television industry. she is a single mother to a teenage daughter. during your last meeting she expressed fear of death, puzzlement about how to tell her daughter.
3
 user is odelia, she was informed that her cancer was incurable. she is 48 years old. she had to retire from a career in the television industry. she is a single mother to a teenage daughter. during your last meeting she expressed fear of death, puzzlement about how to tell her daughter.
4
 
4
 

Loading…
Cancel
Save