Decorator to enable users to continue a conversation. Requires both data persistence and authentication to be enabled.

This decorator will automatically:

  • Send the persisted messages and elements to the UI.
  • Restore the user session.

Only JSON serializable fields of the user session will be saved and restored.

Usage

At minimum, you will need to use the @cl.on_chat_resume decorator to resume conversations.

@cl.on_chat_resume
async def on_chat_resume(thread):
    pass

However, if you are using a Langchain agent for instance, you will need to reinstantiate and set it in the user session yourself.

Resume Langchain Chat Example

Practical example of how to resume a chat with context.

Parameters

thread
ThreadDict

The persisted chat to resume.