Chat Life Cycle
Whenever a user connects to your Chainlit app, a new chat session is created. A chat session goes through a life cycle of events, which you can respond to by defining hooks.
On Chat Start
The on_chat_start decorator is used to define a hook that is called when a new chat session is created.
On Message
The on_message decorator is used to define a hook that is called when a new message is received from the user.
On Stop
The on_stop
decorator is used to define a hook that is called when the user clicks the stop button while a task was running.
On Chat End
The on_chat_end decorator is used to define a hook that is called when the chat session ends either because the user disconnected or started a new chat session.
On Chat Resume
The on_chat_resume decorator is used to define a hook that is called when a user resumes a chat session that was previously disconnected. This can only happen if authentication and data persistence are enabled.
Was this page helpful?