Dynamic System Prompt using vector searches on chat history and profile documents

So I have a RP bot app, it’s pretty simple, apart from the fact that it uses vector message history.

However, I had an idea. And so far can’t find anyone that’s made something similar. So currently I use MongoDB to also store the rp profiles and from that generate a system prompt to start or continue a session.

Now here’s the twist. what if I could use a vector search to generate the system prompt? Based on the chat history store and the profiles database.

What I’ve come up with so far is a static prompt template. That gets updated based on the context of the conversation. For example:

You setup an interface that allows you to load multiple profiles into the same “room” So you have a chat between yourself, AI character1 and AI character2.

Your input would be “So character1 how’s the wife and kids?” and in return the system prompt gets formed for Character1. Now the response comes as tagged from character1 who was prompted with a dynamic system prompt generated from the chat context from their perspective. You could even throw in the history chain of you talking to character1 one-on-one. so now the completion is fine tuned by three data-sources.

Then the next question could be for character2 who would be prompted based on the chat context, the responses from character1 and the user input. And so on.

I made a similar sample app in the past. You can manually switch the system prompt from the UI depending on which one you want to talk to by selecting the character’s icon. When a character is selected, it becomes the role=assistant and all the others are role=user but with name prefix to distinguish one another. I dynamically update the context with this rule before I send it to the API. If only we can put “name” property on the message, then it would be much better.

Yeah I played around with a similar idea, however I see this as the next step.
To reinforce the dialogue, I could add text to the system prompt such as

“You are sad that character1’s son Timmy is sick with the flu.”
“You should urge [user] to buy the next round, because they won on the horse race”

Couple that with rules such as “You are character1” "You like jazz music and the fact character2 was talking about the band jazz “Smooth Cat”

And the rules changing every post based on details like that instead of just “You like Jazz music”

Then again joined with this being done based on a pattern match in the input, you could even fire off messages between 1 and 2!

I think that is nice to add dynamically in the system prompt. You can probably process the previous context to extract such data. The challenge is which data. As your context grows, you only want to persist a few things in the system prompt and history context. The rest are fetched using long term memory via RAG.