InMemoryConversation

Simple in-memory implementation of Conversation for testing and ephemeral use cases.

Constructors

Link copied to clipboard
constructor(messages: List<Message> = emptyList(), id: String = MobyNameGenerator.generateName(), persistent: Boolean = false, assets: AssetTracker = InMemoryAssetTracker())

Properties

Link copied to clipboard
open override val assetTracker: AssetTracker

Assets tracked in the conversation.

Link copied to clipboard
open val id: String
Link copied to clipboard
open override val messages: List<Message>

Messages in the conversation in chronological order. Visible to user.

Functions

Link copied to clipboard
open override fun addMessage(message: Message): Message

Modify the state of this conversation Return the newly added message for convenience

Link copied to clipboard
open fun infoString(verbose: Boolean?, indent: Int): String
Link copied to clipboard
open infix override fun last(n: Int): Conversation

Create a nonpersistent conversation with the last n messages from this conversation.

Link copied to clipboard

Non-null if the conversation has messages and the last message is from the user.

Link copied to clipboard
open fun persistent(): Boolean
Link copied to clipboard
open fun promptContributor(conversationFormatter: ConversationFormatter = WindowingConversationFormatter()): <Error class: unknown class>

Prompt contributor that represents the conversation so far. Usually we will want to add messages from the conversation to a prompt instead of formatting the conversation