How to make OpenAI memorize conversations in Spline 3D

About two weeks before Halloween is typically when I begin my annual rewatch of Harry Potter series. It was while I was watching the Chamber of Secrets when it struck me that Tom Riddle’s Diary might as well be a magical equivalent of a pre-trained AI model, like ChatGPT. And so I set out to recreate the famous diary only to find out that making Tom remember our conversations will be harder than I thought. But we’ll get to that

The magic of input and output

In the story, Harry Potter discovers magical properties of the diary by watching a droplet of ink disappear upon touching the paper (talk about affordance in UX!). Inquisitive as he is, he proceeds to introduce himself to the diary saying “My name is Harry Potter”. Unexpectedly, the diary replies: “Hello Harry Potter, my name is Tom Riddle”. That was it. In just 2 sentences we understand the relation of input and output. And that’s what I wanted to recreate to prove that AI already feels like magic if it lets us do that.

Setting the scene for a conversation

From a technical point of view all I needed was a text input, a text layer to display the output, and an API connecting me with OpenAI. I explored if somebody on Spline Community was able to create a chat before and luckily, someone did. I remixed the file and hit “play” on the scene. As it turned out, I needed to insert my own API key to even preview if the whole thing was working. So I did. I generated a private API key for a service and pasted it in Spline. I also had to top up my OpenAI account with $5 USD — it wouldn’t work for free. Right after that I modified the prompt instructions to this:

Prompt:

Answer user's question userPrompt

Behavior:

You are Tom Riddle from Harry Potter book series. Your tone is dark, eloquent, mysterious. Answer with a very short sentence.

Having removed the obstacles I clicked “Play” on my Spline Scene expecting to have a conversation with Tom Riddle.

It worked! I was shocked and amazed. Whenever I asked Tom a question, he would reply shortly and mischievously, as instructed. However, after a few exchanges, my enthusiasm vanished. I realized there’s something missing: memory. Tom couldn’t refer to anything I said in the past.

The conversations went like this:

Me: My name is Harry Potter

Tom:Hello Harry Potter, I’m Tom Riddle

Me: What is my name?

Tom: What does a name even mean?

Me: Do you know my parents?

Tom: Questions of origin are important indeed

ad nauseam 

The chat worked, yes, but it quickly became boring. There’s nothing immersive in having a conversation that feels like talking to a parrot. I’ve become disillusioned. 

I took a step back and realized something: I expected OpenAI to magically (sic!) store my inputs history and refer to them with every next input, thus increasing the payload with each and every prompt. Since that was impossible, I admitted defeat and ditched the project.

How to fake memories in Spline

After 3 days I revisited the scene with an idea that first seemed too simple to work. What if there was a way to constantly overwrite a string variable with each used input? What if it’s enough to mimic memory and make ChatGPT play along.

I created a variable named “History”.

Finally, I rewrote the master prompt:

Answer user's question userPrompt AND take previous answers into account: History


First success

When I finally hit “play” on my scene, I couldn’t believe that it actually worked. Whenever I asked a question, ChatGPT would quickly reply in the tone and voice of Tom Riddle. By then, I had already worked with AI for 1.5 years, having even designed a wrapper for a custom LLM myself when I worked for Caktus AI but it was the first time ever when I could experience how design changes the context of a conversation. I was no longer “chatting” with Voldemort but I conversed with him. The styling, colors, fonts and the context allowed me to immerse myself in the story. For a brief second I realized that if I were a 10-year old child in 2003, I’d consider this to be true magic. If this isn’t a testimony to how important visuals are, I don’t know what is. However, the