Package-level declarations

Types

Link copied to clipboard
data class AIAgentActivity(val state: AIAgentActivity.State, val text: String? = null)

What the agent says it is doing while it answers, besides what its reply shows, such as thinking or checking external sources. Stream Chat's AI indicator events carry it:

Link copied to clipboard
class AIAgentError(message: String? = null) : Exception

The agent couldn't answer: it said so, such as with an AIAgentActivity in the AIAgentActivity.State.Error state, or its reply didn't start in time.

Link copied to clipboard

Where an AIConversationTransport tells its AIConversationState what the conversation holds. Call it on the state's thread, the main thread for a viewModelScope.

Link copied to clipboard
data class AIConversationRequest<out M : AIMessage>(val kind: AIConversationRequestKind, val text: String, val attachments: List<Uri> = emptyList(), val message: M? = null, val uiAction: AIUIAction? = null, val messageId: String = UUID.randomUUID().toString())

What the person asks of the agent, which an AIConversationState hands to its AIConversationTransport.

Link copied to clipboard
value class AIConversationRequestKind(val rawValue: String)

What the person asks for in an AIConversationRequest. It is an open set: compare against the kinds you know, and treat the rest as a new message.

Link copied to clipboard
class AIConversationState<M : AIMessage>(transport: AIConversationTransport<M>, scope: CoroutineScope, val approver: AIToolApprover? = null, replyTimeout: Duration? = DefaultReplyTimeout)

The state behind a conversation with an AI agent, and what the person does in it.

Link copied to clipboard
value class AIConversationStatus(val rawValue: String)

Where an AIConversationState's latest exchange with the agent is. It is an open set: compare against the statuses you know.

Link copied to clipboard

How an AIConversationState reaches the agent and learns what it holds: it sends what the person asks, stops the agent, and tells the state its messages as they change.

Link copied to clipboard
interface AIMessage

A message in a conversation with an AI agent, as AIConversation shows it.

Link copied to clipboard
class AIMessageAttachment(val kind: AIMessageAttachment.Kind, val uri: Uri? = null, val bitmap: ImageBitmap? = null, val name: String? = null, val size: Long? = null, val mimeType: String? = null, val extraData: Map<String, Any?> = emptyMap())

Something a message carries besides its text, such as an image or a file.

Link copied to clipboard

How the person rated a reply.

Link copied to clipboard
value class AIMessageRole(val rawValue: String)

Who wrote a message. It is an open set: compare against the roles you know.

Link copied to clipboard
data class AIPendingMessage(val id: String = UUID.randomUUID().toString(), val text: String, val attachments: List<AIMessageAttachment> = emptyList())

A message the person sent that has not arrived in the conversation yet. The conversation shows it at once, and its copy takes over its row when it arrives.

Link copied to clipboard
data class AIReplyActions(val rating: AIMessageRating? = null, val onRegenerate: () -> Unit? = null, val onRate: (AIMessageRating?) -> Unit? = null)

What the person can do with a finished reply besides copying and sharing it.

Functions

Link copied to clipboard
fun <M : AIMessage> rememberAIConversationState(transport: AIConversationTransport<M>, approver: AIToolApprover? = null, replyTimeout: Duration? = AIConversationState.DefaultReplyTimeout): AIConversationState<M>

An AIConversationState that lives as long as the composition, connected to transport.