SmartSession.MessageCollection

Wisej.AI.SmartSession MessageCollection

Namespace: Wisej.AI

Assembly: Wisej.AI (3.5.0.0)

Represents a collection of messages in a session.

public class MessageCollection : ObservableCollection<>, ICloneable

Constructors

MessageCollection()

Initializes a new instance of MessageCollection.

Methods

Add(role, content)

Adds a message with the specified role and content.

Parameter
Type
Description

role

The role of the message.

content

The content of the message.

Returns: MessageCollection. The current MessageCollection instance.

Throws:

AddRange(messages)

Adds a range of messages to the collection.

Parameter
Type
Description

messages

The messages to add.

Returns: MessageCollection. The current MessageCollection instance.

Clone()

Creates a shallow clone of the collection.

Returns: MessageCollection. A shallow clone of the MessageCollection.

InsertItem(index, item)

Inserts a message at the specified index.

Parameter
Type
Description

index

The zero-based index at which the message should be inserted.

item

The message to insert.

MoveItem(oldIndex, newIndex)

Moves a message from one index to another.

Parameter
Type
Description

oldIndex

The zero-based index specifying the location to move from.

newIndex

The zero-based index specifying the location to move to.

RemoveAll(predicate)

Removes all messages that match the specified predicate.

Parameter
Type
Description

predicate

The predicate to match messages.

Returns: MessageCollection. The current MessageCollection instance.

RemoveLast(count)

Removes the last message(s) from the collection.

Parameter
Type
Description

count

The number of messages to remove. Default is 1.

Returns: MessageCollection. The current MessageCollection instance.

Last updated