ソースを参照

Avoid nested history, prompt changes

master
Nimrod Kerrett 1年前
コミット
02bed857cf
2個のファイルの変更5行の追加5行の削除
  1. 4
    4
      app.py
  2. 1
    1
      templates/prompt.txt

+ 4
- 4
app.py ファイルの表示

@@ -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"))

+ 1
- 1
templates/prompt.txt ファイルの表示

@@ -1,4 +1,4 @@
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 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
 

読み込み中…
キャンセル
保存