1.6 KiB
The system begins with a generic system prompt.
The user begins interacting with the model, perhaps introducing himself. Perhaps the initial UI should contain a pre-filled message as if it's from the model, saying "Hi, I'm {name}. Tell me about yourself or what you want me to do."
Every time the user submits a message, the backend should:
-
Save the message to the database under a conversation key for later lookup
-
Generate a new message from the model, and add it to the database. The model should be
-
Extract Facts from the user's message, and add them to the database, linking the Facts with the messages they came from. (Yes, this should be done after the model response, not before; because when we run a query to find Facts to inject into the context sent to the model, we don't want Facts from the user's current message to be candidates for injection, because we're sending the user's message unadulterated to the model; there's no reason to inject the same Facts that the model is already using to generate its response.)
-
Extract Facts from the model's response, and add them to the database, linking the Facts with the messages they came from.
-
For each Fact produced in the two fact-extraction steps, generate FactTriggers and add them to the database, linking the FactTriggers with the Facts they came from. A FactTrigger is a natural language phrase that describes a situation in which it would be useful to invoke the Fact. (e.g., "When food preferences are discussed").
-
Produce a running summary of the conversation, and save that to the database.
-
Update the UI to show the new message.