code-dot-org
code-dot-org copied to clipboard
Gen AI: more robust chat logging
In service of simplifying our chat logging, a couple of related changes.
Break up chat history in UI into three pieces:
-
chatMessagesPast: past messages that are from a previous "session" and are only now needed from a UI perspective (ie, to show students what they did before). Added to whenchatMessagesCurrentis wiped (see below). -
chatMessagesCurrent: current set of messages that we're sending to the model. Append to this when we get a response from the model, and wipe and move existing messages tochatMessagesPastwhen a new session is created (eg, by a change in system prompt) -
chatMessagePending: the message a user has input and is awaiting response from the server. Wiped once we receive a response from the server.
Standardizes response from Rails in all cases to be a list of messages that should be appended to the chat history in the UI.
Links
- slides with a bit of graphical description: link