Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.11 KB

File metadata and controls

45 lines (33 loc) · 1.11 KB
title on_chat_resume

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.

Parameters

The persisted chat to resume.

Usage

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

import chainlit
from chainlit import ThreadDict

@chainlit.on_chat_resume
async def on_chat_resume(thread: ThreadDict):
    pass

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

<Card title="Resume Langchain Chat Example" color="#F80061" icon="message" href="https://github.com/Chainlit/cookbook/tree/main/resume-chat"

Practical example of how to resume a chat with context.