Skip to main content

Chat Sessions

Chat sessions let a deployed App continue a conversation across multiple messages.

When you call app.chat(message), the SDK stores the returned session_id and sends it with the next message automatically. You do not need to manage the session ID for normal multi-turn chat.

Send a Message

response = app.chat("My name is Alex.")

print(response.response)
print(response.session_id)

app.chat() returns a ChatResponse.

FieldDescription
responseThe assistant's reply.
session_idThe session identifier returned by the API.
retrieved_contextsData source chunks used for the response, if any.
messagesConversation messages returned by the API.
raw_payloadThe raw API response payload.

Continue a Conversation

Call app.chat() again on the same App instance:

app.chat("My name is Alex.")

response = app.chat("What is my name?")
print(response.response)

The SDK sends the latest session ID automatically, so the assistant can use previous conversation context.

Check the Current Session ID

Use app.session_id to inspect the active session:

print(app.session_id)

Before the first message, this value is None. After a successful chat response, it contains the current session ID.

Reset the Session

Use reset_session() to start a fresh conversation:

app.chat("My name is Alex.")

app.reset_session()

response = app.chat("What is my name?")
print(response.response)

After resetting, the next message starts a new session instead of continuing the previous one.

Use the ChatSession Helper

You can also create a small session helper:

session = app.session()

response = session.ask("Summarize the uploaded handbook.")
print(response.response)

This helper uses the same underlying App session behavior.

Interactive Chat Mode

Call .chat() without a message to start an interactive terminal chat:

app.chat()

Type exit or quit to end the session.

Notes

  • Session state is retained on the App instance.
  • If you create a new App instance, it starts without a retained session ID.
  • Use reset_session() when you want a clean conversation.
  • Use retrieved_contexts to inspect which knowledge chunks were used in responses from data sources.

Next Steps