Conversation

org.llm4s.llmconnect.model.Conversation
See theConversation companion object
case class Conversation(messages: Seq[Message])

Represents the message stream in a conversation. Typically this will be a sequence of system prompt, then a series of user message and assistant responses. After the system message we have a user message. The next message is the assistant response. If the conversation is ongoing, the next message will be a user message, or if the previous AssistantMessage requested one or more tool calls it will be followed by ToolMessages in response to each requested tool.

Value parameters

messages

Sequence of messages in the conversation.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Add a message and return a new Conversation. This operation is immutable - the original conversation is unchanged.

Add a message and return a new Conversation. This operation is immutable - the original conversation is unchanged.

Value parameters

message

The message to add

Attributes

Returns

A new Conversation containing all previous messages plus the new one

def addMessages(newMessages: Seq[Message]): Conversation

Add multiple messages and return a new Conversation. This operation is immutable - the original conversation is unchanged.

Add multiple messages and return a new Conversation. This operation is immutable - the original conversation is unchanged.

Value parameters

newMessages

The messages to add

Attributes

Returns

A new Conversation containing all previous messages plus the new ones

def filterByRole(role: MessageRole): Seq[Message]

Filter messages by role.

Filter messages by role.

Value parameters

role

The message role to filter by

Attributes

Returns

Sequence of messages matching the role

def lastMessage: Option[Message]

Get the last message in the conversation.

Get the last message in the conversation.

Attributes

Returns

Some(Message) if conversation has messages, None if empty

def messageCount: Int

Get count of messages.

Get count of messages.

Attributes

Returns

Number of messages in the conversation

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product