Android · cartesian-core
ChatSession
Conversation state, streaming answers, events and follow-up suggestions.
val session: ChatSession = client.chatkotlinState
stateStateFlow<ChatState>
An immutable snapshot of the current thread. It updates on every streamed frame.
eventsSharedFlow<ChatEvent>
One-off events: TurnStarted, ProductsShown, CartChanged, TurnFinished, Error.
suggestionsStateFlow<List<String>>
Follow-up questions for the latest finished answer. Cleared when a new turn starts.
threadIdString?
Methods
| Method | Description |
|---|---|
suspend send(text) | Starts a turn, creating a thread if there isn't one. Throws Busy if a turn is running. |
suspend stop() | Interrupts the running turn |
suspend newChat(): Boolean | Clears the state for a new thread. Returns false while a turn is running. |
suspend open(threadId) | Loads a past thread and its transcript |
suspend retry() | Re-sends the last question after a failure |
suspend rate(messageId, rating) | Rating.Up or Rating.Down |
suspend dismissError() | Clears state.error |
ChatState
| Field | Type |
|---|---|
threadId | String? |
messages | List<ChatMessage>: UserMessage or AssistantMessage |
isResponding | Boolean |
isLoading | Boolean (opening a thread) |
isEmpty | Boolean |
error | String? |
feedback | Map<messageId, Rating> |
AssistantMessage
| Field | Type | Description |
|---|---|---|
text | String | Markdown answer, streamed |
thinking | String | Reasoning summary, if the backend sends one |
steps | List<AgentStep> | Activity trace: title, detail, phase (Started, Completed, Failed), kind (Search, Tool, System), tool |
activeStep | AgentStep? | The step currently running |
products | List<Product> | Products shown with the answer |
comparisons | List<Comparison> | |
cartUpdates | List<CartUpdate> | operation, changedCount, itemCount, total, currency |
status | MessageStatus | Streaming, Done, Stopped or Failed |
error | String? | |
elapsedSeconds | Int? |