Table of Contents

Class ConversationManager

Default implementation of IConversationManager.

public class ConversationManager
Inheritance
object
ConversationManager

Constructors

ConversationManager(string, IConversationsApiListener, IAgentMemorySettings, IConversationStore)

public ConversationManager(string agentId, IConversationsApiListener listener, IAgentMemorySettings memoryConfig, IConversationStore store)

Parameters

agentId string
listener IConversationsApiListener
memoryConfig IAgentMemorySettings
store IConversationStore

Properties

AgentId

public string AgentId { get; }

Property Value

string

AutoSave

public bool AutoSave { get; }

Property Value

bool

Conversation

public Conversation Conversation { get; }

Property Value

Conversation

IsInitialized

public bool IsInitialized { get; }

Property Value

bool

ItemCount

public int ItemCount { get; }

Property Value

int

Items

public List<ConversationItem> Items { get; }

Property Value

List<ConversationItem>

LastError

public Exception LastError { get; }

Property Value

Exception

LastMessage

public Message LastMessage { get; }

Property Value

Message

MemoryConfig

public IAgentMemorySettings MemoryConfig { get; }

Property Value

IAgentMemorySettings

Messages

public List<Message> Messages { get; }

Property Value

List<Message>

Name

public string Name { get; set; }

Property Value

string

PersistMode

public ConversationPersistMode PersistMode { get; }

Property Value

ConversationPersistMode

StoreType

public ConversationStoreType StoreType { get; }

Property Value

ConversationStoreType

SummaryModel

public Model SummaryModel { get; }

Property Value

Model

Methods

AppendUsage(UsageMetadata)

public void AppendUsage(UsageMetadata usage)

Parameters

usage UsageMetadata

CreateConversationAsync(CancellationToken)

public UniTask<Conversation> CreateConversationAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

UniTask<Conversation>

DeleteConversationAndItemsAsync(string, CancellationToken)

public UniTask<bool> DeleteConversationAndItemsAsync(string convId, CancellationToken ct = default)

Parameters

convId string
ct CancellationToken

Returns

UniTask<bool>

GetContextMessages()

public List<Message> GetContextMessages()

Returns

List<Message>

ListConversationsAsync(CancellationToken)

public UniTask<Conversation[]> ListConversationsAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

UniTask<Conversation[]>

LoadConversationAsync(string, bool, CancellationToken)

public UniTask<Conversation> LoadConversationAsync(string convId, bool createIfError = true, CancellationToken ct = default)

Parameters

convId string
createIfError bool
ct CancellationToken

Returns

UniTask<Conversation>

OnConversationTitleUpdated(string)

protected virtual void OnConversationTitleUpdated(string value)

Parameters

value string

PushInputMessageAsync(Message, int)

Pushes a system message or a user message to the session.

public UniTask<List<Message>> PushInputMessageAsync(Message inputMessage, int index = -1)

Parameters

inputMessage Message

The message to be added to the session.

index int

Returns

UniTask<List<Message>>

Context messages after the new message has been added. This includes the new message and any previous messages in the session, limited by the profile's max context size.

PushOutputMessage(ResponseMessage, UsageMetadata)

Pushes the response (ChatCompletion) from the chat model to the session. It will extract the assistant's message from the ChatCompletion and add it to the session.

public void PushOutputMessage(ResponseMessage outputMessage, UsageMetadata usage)

Parameters

outputMessage ResponseMessage
usage UsageMetadata

ReCalculateTotalUsage()

public void ReCalculateTotalUsage()

SaveConversationAsync(CancellationToken)

public UniTask<Conversation> SaveConversationAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

UniTask<Conversation>

SaveConversationItemsAsync(CancellationToken)

public UniTask<ConversationItem[]> SaveConversationItemsAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

UniTask<ConversationItem[]>

SetConversationAsync(Conversation, CancellationToken)

public UniTask<bool> SetConversationAsync(Conversation conversation, CancellationToken ct = default)

Parameters

conversation Conversation
ct CancellationToken

Returns

UniTask<bool>