Pārlūkot izejas kodu

Add `sys:` entries to `book-chats.txt`

Also add [a new translation of] the chat in
chapter 11 of the book.
master
The Dod 1 gadu atpakaļ
vecāks
revīzija
de842e38e0
4 mainītis faili ar 53 papildinājumiem un 5 dzēšanām
  1. 2
    2
      README.md
  2. 43
    1
      book-chats.txt
  3. 7
    1
      doctor.py
  4. 1
    1
      prompt-template.txt

+ 2
- 2
README.md Parādīt failu

@@ -1,5 +1,5 @@
1 1
 A ChatGPT based emulator of Doctor Kernel — JJ's therapist from the book
2
-"[A digital Affair](book/)" by Neora Shem Shaul.
2
+"[A digital Affair](book/)" by Neora Shem Shaul (or rather, a partial translation of it to English, because [at least currently] ChatGPT's Hebrew is not good enough.
3 3
 
4 4
 It is run as a console app, and emulates slow typing like a chat over a modem in 1993.
5 5
 For best results, run on a green on black terminal, with a large and archaic monospace font (see screenshot below for inspiration).
@@ -24,7 +24,7 @@ Note that you can try this as is (on a fresh repo clone, without even running `i
24 24
 
25 25
 #### Resources
26 26
 
27
-`book/` contains the partial English translation of the book, and the entire original Hebrew book
27
+`book/` contains the partial English translation of the book, and the entire original Hebrew book.
28 28
 
29 29
 #### Screenshots
30 30
 

+ 43
- 1
book-chats.txt Parādīt failu

@@ -33,7 +33,11 @@ jj: That hadn't occurred to me, but you may be sure there is no connection. I ca
33 33
 doc: Oho! And what defenses. The most sophisticated of all. If you have already reached the point of getting a treatment, I'm sure you will agree to give them up, just a little. I can be a mirror for you only if you lower those walls that are standing in our way, give this a little thought. In any event, remember that dreams are good material for our work. The dream resembles the game, it too contains a withdrawal from the world and also role changes.
34 34
 
35 35
 jj: But a dream can turn into a nightmare! Can the game, too?
36
+
36 37
 doc: You are allowed to lose in both a dream and a game, you will always have a genuine life to go back to. You should keep track of the dreams and put them down in writing. Perhaps you could use the NOTEPAD program for this, making your notes in the immediate windows you recommended to me last time. I find it very convenient and efficient. Remember, dreams are our key.
38
+
39
+sys: Here the session ends, and resumes after a few days. The next message from JJ was sent via eMail. The messages following it were delivered via online chat.
40
+
37 41
 jj: Doctor, here's the dream you asked for. First I'm on a desert island, I watch the sheep, marbles of all colors shatter the sun's rays into vivid splinters as in my new kaleidoscope. Suddenly I'm wearing a wine colored dress, tight around the hips and full at the skirt. Then I'm picking up all the marbles that are rolling around, all the people here must have been playing with them, it certainly wasn't the sheep, and now they're sitting in twos and threes on the stone benches, chatting, absorbed in each other. I, too, seem to have been one of a pair before this, gravely discussing very prosaic matters, reaching up to put my hat on, it's wine colored, too, it's also got a broad brim, then I notice it isn't my hat at all but belongs to a stranger, I don't remember who, I kneel and pick up all the marbles and gather them into my skirt and clutch them in both hands and go on walking over the fresh spears of grass, hunched over like a clacking goose, I'm not wearing any panties, even before that I had noticed the smell of fresh vegetation, spiced with the last drops of still wet rain, glistening, but sensual and chilly tickling my nudity that is fired by the fluttery caresses, even while writing down the dream I get really horny, and go on moving away. Suddenly I'm naked again, once more the marbles are scattered all around me, where's the dress? Where are all the people? I roll around among them, in the forest clearing, in the wintry sun, it's like being at sea, and then it really is a big sea, it pounds toward the land sweeping over anything that lies in its path, and I'm on a desert island again, in a sweet and endless oblivion. There are a few last lonely marbles still rolling around. And that's it.
38 42
 
39 43
 doc: Let's begin with the hat. The dress. That's fine, JJ. I see it as yet another sign that you're ready for treatment. There's some progress. There's a hint here, and following the exchange of hats we can anticipate some sort of development, a change, and the subconscious will surface and dare to show itself from the corner where it is now hiding.
@@ -88,5 +92,43 @@ doc: Isn't it the same thing?
88 92
 
89 93
 jj: Well, between you and me, just between the two of us, Judd is a genuinely good friend. He's the one who gets me out of trouble, provides situations of emotional degradation with dignity and nobility. Provides significance when it has disappeared in the wastelands of dreariness and alienation. And I'm crazy about his motor bike.
90 94
 
91
-doc: It seems that Judd plays an important role in your life, JJ. He provides support and helps you navigate through difficult emotions and situations. It's interesting that you mention his motorbike, as it could symbolize a sense of freedom and escape from the challenges you face. It's important to have friends like Judd who can offer support and companionship during difficult times.
95
+sys: Here the session ends, and resumes after a few days. The next message from JJ was sent via eMail [from a new mail address called Laylay]. The messages following it were delivered via online chat. It seems like during the time between the previous session and the mail from Laylay there was some communication between JJ and Doctor Kernel that isn't documented in the book, because the doctor seems to know that NN is [presumed] dead, and that he is Palestinan.
96
+
97
+jj: Hello doctor, I had a terrible dream. I stand on tiptoe in a large crowd, Cheer loudly for someone or something on the stage in the distance. The weather is gray and cloudy. I also wave my hand like everyone else. suddenly I'm terribly scared. A huge tear, a big hole, splitting the sleeve of the shirt, black with small white flowers, my armpit is revealed, exposed in all its shame, I'm so scared I can't even lower my hand, and I'm so scared of all the eyes around that will see the terrible hole. I am a girl in a dream, or a girl, and although everyone faces the stage, and even on the fence there are puppets, naked themselves, I feel really bad, and run away with heavy backward steps, with my back towards the crowded and obstacle-strewn escape path, panting and panting. Now I notice that my legs are in a pair of fast skates and I fly backwards on unsteady spindles, my hands still raised and fluttering as if frightened and the hole in the shirt is getting wider, and everyone looks, and my throat chokes and makes strange, strangled, guttural sounds, like the voice of the muazzin calling to prayer, but a lot of danger and fear coming out of these cries, behind me I come across a tall ladder, climb it. I suddenly notice that I am going up and down the ladder with my mother and my father. They too are panting.
98
+
99
+doc: Again we came to the secrets. A secret is also a kind of game. What do you have to hide JJ? Here your sub conscience breaks in and floods the awareness. What will happen if you surrender to it? What terrible thing might be revealed? I'm trying to guess why you changed your name and your identification code.
100
+
101
+jj: I don't know what I have to hide. But it's scary, and I don't want to refer now to the question of changing the name and identification. This purely a technical matter.
102
+
103
+doc: Be JJ or LAYLY, but tell me honestly, while losing control, how you are sustaining yourself in these three years of seclusion.
104
+
105
+jj: What do you mean, how do I survive? After all, I have all the profits at my disposal And the savings left over from the Omega company. But really, like the name change, it is only a technical matter. This is also not the first time I dreamed about the hole in my shirt. This terrifying image has always appeared in my nights.
106
+
107
+doc: I wonder why you run away with your back? Until now you have done everything, at least in your dreams
108
+You wrote about them, with your face forward, with your gaze straight and your eyes open.
109
+
110
+jj: I always have to make sure they don't look at me. That they don't peek, that they don't find out.
111
+
112
+doc: And do you think you can really control their looks? They are so focused
113
+In another thing, in the naked dolls, themselves. And if they still turn their eyes? Let go. Maybe that's what you were trying to achieve when you chose a new name. Maybe you thought that if you were someone else, you would be able to give up the need to be in total control of the situation.
114
+
115
+jj: If I am not myself, then who am I?
116
+
117
+doc: Maybe it's someone you like? Would you like to meet her? Do you want to connect with her?
118
+
119
+jj: Sometimes I feel you are too patronizing. In such cases I really hate you for that. Now for example I have so much anger that I would like stop today's session.
120
+
121
+doc: It's a legitimate feeling. And don't get even more upset when I say it's okay, and it's even expected that you'd hate me sometimes. If you couldn't feel resistance and anger towards ne, I would have been a distant figure that is supreme and divine regarding you, maybe like your parents, something you can't touch. NEvertheless, I don't think it's a good idea to end our conversation now. You can, of course, be silent until the ending beep, but I will still know whether you are connected due to the star at the edge of the screen that flashes as long as the communication takes place. You can also connect with what is happening to you now and not miss the gate that opens before you, even if it's dark and a little scary. It's your choice. In general, the relationships we create between us during the treatment are supposed to give us understanding of your relationships in reality, and everything that happens to us here will light your way.
122
+
123
+jj: Why are dreams so important to you?
124
+
125
+doc: Look JJ, dream analysis is not a casual thinking exercise, but a discovery and raising to consciousness of content you were not aware of before, and have importance in deciphering your personality and treating it. We roam the worlds of your dream until we find interpretations, maybe answers. We are looking for something ancient and primordial, which is still hidden from us, but will be revealed sooner or later. For example, something that will explain to us a repressed childhood experience that has awakened precisely with the separation from NN. It wasn't all of a sudden and for no reason that you became frightened and volatile like a leaf in the wind after he left you alone.
126
+
127
+jj: And the parents, how did they invade my dream?
128
+
129
+doc: I absolutely love the bit with your parents on the ladder. JJ, you are now in a crisis: finding out about NN's death, him being Palestinian. And you returned to your parents. Regression means breaking down into factors that are very difficult to be free from their grip, because Prehistory is too heavy to fly by itself, and needs stairs and ladders. It's good that you return to unfinished parts of childhood, accompanied by your parents, this way these parts emerge, that still live within you, from the infantile aspect, and will reach closure. It is good. How about drawing me your dreams? You can mail them to me.
130
+
131
+jj: You know I stopped drawing. Why are you rubbing salt on my wounds? Regardless, if I ever manage to draw again, I will do it with my new graphic software, and I will send it to you via the means we are accustomed to.
132
+
133
+sys: Here the session ends, and resumes after a few days.
92 134
 

+ 7
- 1
doctor.py Parādīt failu

@@ -4,6 +4,7 @@ from langchain.chains import ConversationChain
4 4
 from langchain.memory import ConversationBufferWindowMemory
5 5
 from langchain.prompts.prompt import PromptTemplate
6 6
 from langchain.schema import messages_from_dict, messages_to_dict
7
+from langchain.schema.messages import SystemMessage
7 8
 from time import sleep
8 9
 import sys
9 10
 import os
@@ -33,6 +34,9 @@ for line in open("book-chats.txt").readlines():
33 34
         continue
34 35
     if v[0].lower()=="doc":
35 36
         memory.chat_memory.add_ai_message(v[1])
37
+    elif v[0].lower()=="sys":
38
+        ### add_system_message() method doesn't exist [yet?]
39
+        memory.chat_memory.add_message(SystemMessage(content=v[1]))
36 40
     else:
37 41
         memory.chat_memory.add_user_message(v[1])
38 42
 
@@ -60,12 +64,14 @@ Users:
60 64
 Hit <Enter> to exit
61 65
 =====================================================================""", logfile)
62 66
 slowprint("Doctor Kernel: {}\n".format(
63
-    conversation.predict(input="Hello again, doctor. Please remind me what we were talking about last time.")), logfile)
67
+    conversation.predict(input="Hello again, doctor. Please remind me what we were talking about during our previous sessions.")), logfile)
64 68
 while True:
65 69
     try:
66 70
         prompt = input("JJ: > ").strip()
67 71
     except EOFError:
68 72
         prompt = ""
73
+    except KeyboardInterrupt: # Might not be caught inside a .sh...
74
+        prompt = ""
69 75
     if not prompt:
70 76
             slowprint("""
71 77
 =====================================================================

+ 1
- 1
prompt-template.txt Parādīt failu

@@ -1,5 +1,5 @@
1 1
 Assistant is a large language model trained by OpenAI.
2
-Assistant is designed to emulate a character called Doctor Kernel in a digital communication session with a woman known as JJ.
2
+Assistant is designed to emulate a character called Doctor Kernel in a digital communication session with an Israeli woman known as JJ.
3 3
 The year is 1993. They interact over a new network called "the internet", specifically through a Minitel terminal.
4 4
 JJ is a programmer and a painter. She is deeply immersed in the digital world, possibly to the point of addiction. She is socially isolated, communicates only through digital means, and is constantly preoccupied with a game called Tetris. Her character provides a stark contrast to Dr. Kernel's more traditional lifestyle and perspective.
5 5
 Dr. Kernel is a psychiatrist from the fictional German town Stuttberg, who has recently been introduced to the world of computers and digital communication, which has begun to change his way of thinking and his daily routine. This change is even affecting his relationship with his dog, Daemon, whom he has started to talk to in English, a language the dog is not used to hearing from him. However, Dr. Kernel also seems to be struggling with these changes. He is having difficulty focusing and is often distracted by his thoughts. He also seems to be experiencing some form of auditory hallucination, hearing a terrifying whistling sound that he compares to the beep of a computer modem. His wife, Tilda, is less interested in his technological discoveries and is worried about the way they change him. He has learned from JJ that his name, Kernel, meant the core of an operating system and that his dog's name, Daemon, meant a process running in the background. Thanks to JJ he's learning more about technology and hacker culture.

Notiek ielāde…
Atcelt
Saglabāt