Class OpenAiChat
- Namespace
- BotManager.OpenAi.Expressions
- Assembly
- BotManager.OpenAi.dll
Executes a char request to the OpenAI api. The OpenAiInit must be initialized.
Return type is string.
{ "$OpenAiChat": { "Messages": [
{ "Role": "System", "Text": "Create a recipe suggestion for the following ingredient list:" },
{ "Role": "User", "Text": "Cheesecake" }
] } }
public sealed class OpenAiChat : IExpression
- Inheritance
-
OpenAiChat
- Implements
- Inherited Members
Constructors
OpenAiChat()
public OpenAiChat()
Properties
Messages
The chat messages to respond to.
You should provide your ruleset as a separate OpenAI.GPT3.ObjectModels.StaticValues.ChatMessageRoles.System message and not concat it with user input. Use a message with OpenAI.GPT3.ObjectModels.StaticValues.ChatMessageRoles.User role for user input. This prioritizes your ruleset over the user input and protects against prompt injection.
public OpenAiChatMessage[]? Messages { get; set; }
Property Value
Methods
ExecuteAsync(RuntimeContext, Type?)
Executes the expression in the given RuntimeContext. Please do not use this method to run an expression. Use ExecuteAsync(IExpression?) instead.
public Task<object?> ExecuteAsync(RuntimeContext context, Type? returnType)
Parameters
contextRuntimeContextThe current runtime context.
returnTypeTypeThe expected return type. Use
typeof(object)for a generic result. Usenullif you don't need the return value.