Class Conversation
- Namespace
- Oobabooga
APIHelper
- Assembly
- DougWare.OobaboogaAPIHelper.dll
Represents a conversation.
- Inheritance
-
Conversation
- Inherited Members
Constructors
Conversation()
Conversation(PromptTemplate)
Initializes a new instance of the Conversation class.
Parameters
promptTemplate
PromptTemplate The PromptTemplate instance containing the configuration.
Properties
SystemPrompt
Gets or sets the initial system prompt.
Property Value
SystemPromptTokenCount
Gets or sets the number of tokens in the system prompt. 13 is the number of tokens in the default system prompt.
Property Value
TokenCount
Gets the number of tokens in the conversation.
Property Value
Turns
Gets or sets the list of turns in the conversation.
Property Value
Methods
AddTurn(string, bool)
Adds a new turn to the conversation with the provided content.
Parameters
content
stringThe content for the new turn.
countTokens
boolA boolean indicating whether or not to count tokens.
Returns
- Task
A Task that represents the asynchronous operation.
AddTurn(string, string, bool)
Adds a new turn to the conversation with the provided turn type and content.
Parameters
turnType
stringThe type of the new turn ("Human" or "Assistant").
content
stringThe content for the new turn.
countTokens
boolA boolean indicating whether or not to count tokens.
Returns
- Task
A Task that represents the asynchronous operation.
Exceptions
- Argument
Exception Thrown if turnType is not valid.
FromJsonFile(string, PromptTemplate)
Parameters
jsonFile
stringpromptTemplate
PromptTemplate
Returns
GetPrompt(Conversation, PromptTemplate)
Builds and returns the chat conversation prompt.
Parameters
conversation
ConversationThe Conversation object from which the prompt will be built.
promptTemplate
PromptTemplate The PromptTemplate instance containing the configuration.
Returns
- string
The resulting prompt as a string.
ParseConversationAsync(string, PromptTemplate, bool)
Parses a conversation from a string of conversation text.
public static Task<Conversation> ParseConversationAsync(string conversationText, PromptTemplate promptTemplate, bool countTokens = false)
Parameters
conversationText
stringThe conversation text to parse.
promptTemplate
PromptTemplate The PromptTemplate instance containing the configuration.
countTokens
boolA boolean indicating whether or not to count tokens.
Returns
- Task<Conversation>
A Task that represents the asynchronous operation. The Task.Result property returns a Conversation object representing the conversation.
Examples
string conversationText = "Human: Hello\nAssistant: Hi";
PromptTemplate template = new PromptTemplate();
Conversation conv = await Conversation.ParseConversationAsync(conversationText, template);
Exceptions
- Argument
Null Exception Thrown if conversationText is null.
- Format
Exception Thrown if the conversation text is improperly formatted.
ToJsonFile(Conversation, string)
Parameters
conversation
ConversationjsonFile
string