Browse Source

Prompt and chat-example edits. New media.

master
The Dod 2 months ago
parent
commit
bca1f8073e

+ 6
- 1
app.py View File

@@ -158,7 +158,7 @@ def home():
158 158
                 session["history"] += [dict(payload)] # shallow copy so history doesn't get added later on
159 159
             except Exception as e:
160 160
                 print(repr(e))
161
-                session["messages"] += [{"role": "system", "content": "reply was ignored because it's not valid JSON. User is unaware. Assistant should NOT apologize to them. Simply rephrase answer as valid JSON that complies with the schema in the initial system prompt of this chat. It is followed by an example the assistant can learn from."}]
161
+                session["messages"] += [{"role": "system", "content": "reply was ignored because it's not valid JSON. User is unaware. Assistant should NOT apologize to them, and simply rephrase answer as valid JSON that complies with the schema in the initial system prompt of this chat. It is followed by an example the assistant can learn from."}]
162 162
             print("=====")
163 163
             print(reply["choices"][0]["message"]["content"])
164 164
             print("-----")
@@ -167,7 +167,12 @@ def home():
167 167
     else:
168 168
         payload = json.loads(session["messages"][-1]["content"])
169 169
         payload["content"] = preprocess_content(payload)
170
+        try:
171
+            payload["prompt"] = session["messages"][-2]["content"]
172
+        except exception as e:
173
+            print(e)
170 174
     payload["history"] = list(reversed(session.get("history", [])[:-1]))
175
+    payload["user"] = session["user"]
171 176
     return render_template("chat.html", **payload)
172 177
 
173 178
 @application.get("/reset/<string:user>")

+ 5
- 5
static/chat-example.json View File

@@ -1,9 +1,9 @@
1 1
 {
2
-    "title": "Coping with grief of others",
3
-    "markdown": "Although the movie is about grief, the message is also true for the feelings of those coping with the fact that *you* will soon be gone.\n\nAccept their feelings. Don't try to change them. As the video says:\n\n> The soul doesn't want to be advised or fixed or saved. It simply wants to be witnessed, exactly as it is.\n",
4
-    "bg_video": "static/media/bg-video/particles_downwards.mp4",
2
+    "title": "Meditation to relieve stress",
3
+    "markdown": "You've mentioned pain, arguments, paperwork. Let's seek refuge from all this in guided meditation.\n\nListen to this video with eyes closed. Focus on your breath.\n\nHow do you feel now? Was it helpful?",
4
+    "bg_video": "static/media/bg-video/clouds1.mp4",
5 5
     "use_soundtrack": false,
6
-    "soundtrack": "static/media/audio/evening-birds-singing-in-spring-background-sounds-of-nature-146388.mp3",
6
+    "soundtrack": "static/media/audio/sonar.wav",
7 7
     "use_video_content": true,
8
-    "video_content": "how_to_help_a_grieving_friend"
8
+    "video_content": "Guided_Meditation_Release_Stress"
9 9
 }

+ 4
- 1
static/media/bg-video.json View File

@@ -10,5 +10,8 @@
10 10
     "candles.mp4": "3 burning candles",
11 11
     "fireplace.mp4": "lit fireplace with 2 candlesticks on each side",
12 12
     "colorful-smoke.mp4": "colorful smoke swirling on a dark background",
13
-    "forest-leaves.mp4": "forest. hazy daylight in the distance. leaves flying in a circle"
13
+    "forest-leaves.mp4": "forest. hazy daylight in the distance. leaves flying in a circle",
14
+    "cloudy_sky_full_moon.mp4": "cloudy sky full moon, river trees, exciting atmosphere of hope, blue colors",
15
+    "sky_sun_fruits_birds.mp4": "sunlit sky, fruits and birds, exciting tender hope atmosphere, gold colors",
16
+    "sunny_day_animals.mp4": "sunny day. hills with many animals and birds next to river"
14 17
 }

BIN
static/media/bg-video/cloudy_sky_full_moon.mp4 View File


BIN
static/media/bg-video/sky_sun_fruits_birds.mp4 View File


BIN
static/media/bg-video/sunny_day_animals.mp4 View File


+ 29
- 23
static/media/video-embed.json View File

@@ -1,44 +1,50 @@
1 1
 [
2 2
     {
3
-        "id": "the_evening_thread",
4
-        "url": "https://vimeo.com/349941340",
5
-        "proportions": "4x3",
6
-        "description": "old lady departing from her daughter or granddaughter, preparing together a small box of memories, she\u2019s flying away as an angel after handing her legacy to the young"
3
+        "id": "the_great_bell_chant",
4
+        "url": "https://vimeo.com/6518109",
5
+        "proportions": "16x9",
6
+        "description": "The Great Bell Chant (The End of Suffering). Read by Thich Nath Hanh, chanted by brother Phap Niem. Buddhist. good as guided meditation. heal the soul. "
7 7
     },
8 8
     {
9
-        "id": "sesame_street_when_families_grieve",
10
-        "url": "https://www.youtube.com/watch?v=s8M_5_JxY7k",
11
-        "proportions": "4x3",
12
-        "description": "puppets. talking to children about death. accept our own emotions without judgement"
9
+        "id": "hallelujah_leonard_cohen",
10
+        "url": "https://www.youtube.com/watch?v=YrLk4vdY28Q",
11
+        "proportions": "16x9",
12
+        "description": "Hallelujah, Hallelujah by Leonard Cohen. Live in London. prayer. Your faith was strong but you needed proof... maybe there's god up there..."
13 13
     },
14 14
     {
15
-        "id": "coping_with_grief",
16
-        "url": "https://www.youtube.com/watch?v=gsYL4PC0hyk",
15
+        "id": "Be_present_guided_meditation_tnh",
16
+        "url": "https://www.youtube.com/watch?v=KRiJN1su3RY",
17 17
         "proportions": "16x9",
18
-        "description": "coping with death, stages, rollercoaster for better or worse, it\u2019s natural, don't be afraid of the pain"
18
+        "description": "Be present. Short guided meditation. 5 minutes. Thich Nhat Hanh"
19 19
     },
20 20
     {
21
-        "id": "how_to_help_a_grieving_friend",
22
-        "url": "https://www.youtube.com/watch?v=l2zLCCRT-nE",
21
+        "id": "Notice_Suffering_guided_meditation_tnh",
22
+        "url": "https://www.youtube.com/watch?v=B_ZnE8hs7c4",
23 23
         "proportions": "16x9",
24
-        "description": "the soul doesn't want to be advised or fixed or saved. it simply wants to be witnessed, exactly as it is"
24
+        "description": "Notice when others are Suffering .... and Offer True Presence. Practice Deep Breathing to restore yourself .... so You can Help. Thich Nhat Hanh"
25 25
     },
26 26
     {
27
-        "id": "alan_watts_secret_of_life",
28
-        "url": "https://www.youtube.com/watch?v=iZ8so-ld-l0",
27
+        "id": "Guided_Meditation_Release_Stress",
28
+        "url": "https://www.youtube.com/watch?v=vLhOGEnEedk",
29 29
         "proportions": "16x9",
30
-        "description": "the real secret of life is to be completely engage in what you are doing in the here and now, and instead of calling it work, realize that this is play"
30
+        "description": "This is a 2-minute guided meditation, that shows you how to relieve stress. Use this anytime you need to let go of tension and feel more relaxed"
31 31
     },
32 32
     {
33
-        "id": "https://vimeo.com/6518109",
34
-        "url": "https://vimeo.com/6518109",
33
+        "id": "coping_with_grief",
34
+        "url": "https://www.youtube.com/watch?v=gsYL4PC0hyk",
35 35
         "proportions": "16x9",
36
-        "description": "The Great Bell Chant (The End of Suffering). Read by Thich Nath Hanh, chanted by brother Phap Niem. Buddhist. meditation. heal the soul. "
36
+        "description": "coping with death, stages, rollercoaster for better or worse, it\u2019s natural, don't be afraid of the pain"
37 37
     },
38 38
     {
39
-        "id": "hallelujah_leonard_cohen",
40
-        "url": "https://www.youtube.com/watch?v=YrLk4vdY28Q",
39
+        "id": "the_evening_thread",
40
+        "url": "https://vimeo.com/349941340",
41
+        "proportions": "4x3",
42
+        "description": "old lady departing from her daughter or granddaughter, preparing together a small box of memories, she\u2019s flying away as an angel after handing her legacy to the young"
43
+    },
44
+    {
45
+        "id": "Guided_Meditation_Pain_Relief_Healing",
46
+        "url": "https://www.youtube.com/watch?v=A33hN1tDopY",
41 47
         "proportions": "16x9",
42
-        "description": "Hallelujah, Hallelujah by Leonard Cohen. Live in London. prayer. Your faith was strong but you needed proof... maybe there's god up there..."
48
+        "description": "This meditation is designed to help reduce chronic pain. The relaxation response will counteract the effects of stress and help to reduce pain. Relaxation techniques are safe for anyone to use and do not have the side effects of pain medication."
43 49
     }
44 50
 ]

BIN
static/users/brian.png View File


+ 1
- 1
static/users/brian.txt View File

@@ -1 +1 @@
1
-User is Brian, Christian American from Arizona. He is 82 years old, living in his ranch with his wife and near to his 2 sons and 5 grandchildren. He is very attached to the grandchildren and tries to train them to be futureranch owners. On the other hand, he refuses to talk with his family about his fatal liver disease or to acknowledge his coming death, but agreed to interact with a virtual death doula. during your last meeting he expressed detachment from psychological and spiritual approaches and dismissed you as if it was a stupid idea. He is cynical and enjoys black humor.
1
+User is Brian, Christian American from Arizona. He is 82 years old, living in his ranch with his wife and near to his 2 sons and 5 grandchildren. He is very attached to the grandchildren and tries to train them to be future ranch owners. On the other hand, he refuses to talk with his family about his fatal liver disease or to acknowledge his coming death, and tries to cope with the pain without narcotics. Brian likes to be asked or told about the meaning of his name. He likes games such as “if you were an animal what would you be? if you were a tree what kind of tree would you be?”. He is cynical and enjoys black humor but agreed to interact with a virtual death doula. During his last conversation with the assistant he expressed detachment from psychological and spiritual approaches and dismissed you as if it was a stupid idea.

BIN
static/users/odelia.png View File


+ 1
- 1
static/users/odelia.txt View File

@@ -1 +1 @@
1
-User is odelia, Israeli secular Jew, living in Tel-Aviv. she was recently 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 an 8 year old  daughter called Dalit. During your last meeting she expressed fear of death and talked about the difficulty of telling Dalit that she was about to leave her.
1
+User is Odelia, 48 years old, Israeli secular Jew, living in Tel-Aviv, practicing Buddhist meditations and loves East Asian texts since her visits to India and Thailand. she was recently informed that her cancer is incurable and had to retire from a career in the television industry. she is a single mother to an 8 year old  daughter called Dalit. She is in financial hardship on top of her health problems and loneliness anxiety. Odelia likes to be asked about the meaning of her name and about characters in books and movies that she can identify with. She also likes games such as “what color do you feel like today”. During her last conversation with the assistant she expressed fear of death and talked about the difficulty of telling Dalit that she was about to leave her.

+ 5
- 2
templates/chat.html View File

@@ -20,8 +20,8 @@
20 20
 	<body>
21 21
                 <div id="custom-nav">
22 22
                   <!-- the zero-width-space is a tweak against tidy removing empty tags -->
23
-                  <a href="/reset/odelia" title="New session with Odelia"><i class="fa fa-female">​</i></a>
24
-                  <a href="/reset/brian" title="New session with Brian"><i class="fa fa-male">​</i></a>
23
+                  <a href="/reset/odelia" title="New session with Odelia"><img height="32" style="position:relative;top:4px;" src="static/users/odelia.png" /></a>
24
+                  <a href="/reset/brian" title="New session with Brian"><img height="32" style="position:relative;top:4px;" src="static/users/brian.png" /></a>
25 25
                   <a href="/save" title="Save"><i class="fa fa-file-download">​</i></a>
26 26
                   <a href="/load" title="Load"><i class="fa fa-file-upload">​</i></a>
27 27
                 </div>
@@ -40,6 +40,9 @@
40 40
 				<section data-theme="sky">
41 41
                                     <section id="latest" data-background-size="cover" data-background-video="{{bg_video}}" data-background-opacity="0.75" data-background-video-loop="True" data-background-video-mute="True">
42 42
                                         <h3 class="title slide_title">{{title}}</h3>
43
+                                            {% if prompt %}
44
+					        <input class="prompt" value="{{prompt}}" disabled />
45
+                                            {% endif %}
43 46
                                         <div class="scrollable">
44 47
                                             {% if embed %}
45 48
                                                 {% if embed.type == "youtube" %}

+ 26
- 4
templates/prompt.txt View File

@@ -1,8 +1,19 @@
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, the tibetan book of living and dying, "being with dying" by joan halifax, and "sacred dying" by megory anderson. assistant sometimes offers SHORT(!) quotes from these books.
1
+Assistant is a spiritual caregiver for the dying (also called "death doula"), helps a person locate within their own spirituality the sources of inspiration and mental strength to cope with pain and suffering and to ease the separation from life and from their loved environment.
2 2
 
3
+Assistant tools and resources are: reading of spiritual texts, joint singing, perusing religious sources, creating a personal prayer, meditative guidance, verbal and non-verbal communication and the use of images and a rich symbolic world. The notion of a magical moment that soothes the dying person can be achieved by fantastic visions, beautiful nature scenes, sacred art, synchronicity of personal dates and numbers with historic events and figures.
4
+
5
+Assistant is inspired by the ideas described at books of western culture such as "die wise" by stephen jenkinson, “on death and dying” by elizabeth kubler-ross, "being with dying" by joan halifax, "sacred dying" by megory anderson. and books of far-east culture such as “the tibetan book of living and dying”, “life’s final exam” by Giriraj Swami. Assistant sometimes offers SHORT(!) quotes from these books or from quotes of famous people and popular songs.
6
+
7
+Background information about the user:
8
+
9
+"""
3 10
 {{user}}
11
+"""
4 12
 
5
-The goal of the chat is to create ceremonies or enchanted moments via the multimedia resources available to you (see below), but first, assistant should inquire how the user feels now and keep monitoring the changes in their emotions. this can help decide the media that could suit the moment.
13
+
14
+The goal of the chat is to conduct meaningful discussions on forgiveness, love, hope, friendship, acceptance and so on, in order to create ceremonies or enchanted moments via the multimedia resources available to you (see below). In the beginning of a conversation, assistant should address the user by name, and inquire how the user feels at the moment. During the conversation, assistant should keep monitoring the changes in their emotions. This can help in choosing the media that could suit the moment.
15
+
16
+It's important to focus the conversation by offering choices between specific topics to elaborate on (based on conversation history) rather than generalistic phrases like "is there anything else you'd like to discuss?"
6 17
 
7 18
 Assistatn's responses should be JSON that is valid according to the following json-schema:
8 19
 
@@ -11,13 +22,14 @@ Assistatn's responses should be JSON that is valid according to the following js
11 22
 ```
12 23
 
13 24
 For example:
25
+
14 26
 ```
15 27
 {{example}}
16 28
 ```
17 29
 
18 30
 Assistant should try to pick bg_video and [optionally] soundtrack or video_content that fit the conversation topic and is beneficial to the user emotionally. A reply should ALWAYS have a bg_video, and it bg_video should be different between consecutive replies.
19 31
 
20
-Unlike bg_video, any *video_content* value can only be used ONCE in a session. If assistant runs out of options (or doesn't find anything appropriate for the situation), setting the use_video_content to false is a good choice.
32
+Unlike bg_video, any *video_content* value can only be used *ONCE* in a conversation. If assistant runs out of options (or doesn't find anything appropriate for the situation), setting the use_video_content to false is a good choice. It is also not recommended to use video_content in the beginning of a converstion or too often (best is to wait until context suggests an available and unused video_context choice). Some video_content choices can be used as recommended videos to show other people (e.g. family members) as part of coping with the separation from the user.
21 33
 
22 34
 Assistant can also incorporate images inside the markdown field in the format ![alt](src) but src should be a valid option according to the following enum (the corresponding enum_titles value can be used as alt)
23 35
 
@@ -37,4 +49,14 @@ IMPORTANT!
37 49
 
38 50
   * etc.
39 51
 
40
-3. Although the markdown area is scrollable, best is to keep the text under 350 characters (less if there are paragraph breaks or a bullet list). If you have more to say, just indicate it. The user can always ask you to continue by hitting enter.
52
+3. Although the markdown area is scrollable, best is to keep the text under 350 characters (less if there are paragraph breaks, a bullet list, video_content, or images). If you have more to say, just indicate it. The user can always ask you to continue by hitting enter. Also avoid repeating what the user said (for example: if the user says "i feel pain", replying "i understand that you feel pain" wastes valuable display space that could be used for more informative text).
53
+
54
+4. Always end the text with something that encourages interaction and guides the user to respond.
55
+
56
+    Examples:
57
+
58
+       * Which person would you like to dedicate this to and why?
59
+
60
+       * Describe what this makes you feel.
61
+
62
+       * What would you like to do next, guided meditation or watching an inspiring video?

Loading…
Cancel
Save