Why use the user session?
Let’s say you want to keep track of each chat session message count. A naive implementation might look like this:This example is for illustrative purposes only. It is not recommended to use
this code in production.
Naive Example
counter
.
This is where the user session comes in. Let’s rewrite the above example using the user session:
Correct example
User Session Default Values
By default, Chainlit stores chat session related data in the user session. The following keys are reserved for chat session related data:The session id.
Only set if you are enabled Authentication. Contains the
user object of the user that started this chat session.
Only relevant if you are using the Chat
Profiles feature. Contains the chat profile
selected by this user.
Only relevant if you are using the Chat
Settings feature. Contains the chat
settings given by this user.