is it possible to give the conversation history an...
# ask-ai
s
is it possible to give the conversation history and continue the chat
t
Thanks for reaching out, Venkateshwara. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely, you can provide conversation history and continue the chat in LiveKit! To do this, you can use the
ChatContext
parameter to load previous messages and pass them to an agent when starting a session. Here’s a simple example to help you get started:
Copy code
from livekit.agents import ChatContext

chat_ctx = ChatContext.empty()
chat_ctx.add_message(role="assistant", content="Hello, how can I help you?")
chat_ctx.add_message(role="user", content="I want to plan a trip to Paris.")
By passing this
chat_ctx
to the agent, you’ll be able to maintain the conversation context smoothly. Also, keep in mind that the full conversation history is accessible through
session.history
. If you want to save chat history beyond a session, you can easily set up external storage for that. I hope this helps you keep your chats seamless and connected! Sources: Workflows | LiveKit Docs | examples/voice_agents/realtime_load_chat_history.py | Docs::Agents | Session recording and transcripts | LiveKit Docs | OpenAI Realtime API integration guide | LiveKit Docs