SmartChatBoxAdapter
Wisej.AI.Adapters.SmartChatBoxAdapter
Namespace: Wisej.AI.Adapters
Assembly: Wisej.AI (3.5.0.0)
Turns the ChatBox control into a AI-powered bot. It can answer any question (depending on the AI model being used) and can invoke methods in your applications as needed (see SmartTool).
public class SmartChatBoxAdapter : SmartAdapter
Works with:
AzureAI/OpenAI gpt-4
AzureAI/OpenAI gpt-4o
AzureAI/OpenAI gpt-3.5
AzureAI/Anthropic Claude
Google Gemini
Llama3:8b and 70b
You are not limited to what the model can answer. When you add a method decorated with the ToolAttribute the AI can invoke it when necessary in order to retrieve any information or take any action. This is a simple example that provides current date/time knowledge to the AI bot, including the name of the day:
[SmartTool.Tool]
[Description("Returns the current date and time.")]
public DateTime GetCurrentDateTime() {
return DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
}
When the AI needs to know the current date/time it will invoke this method. For example: "When is the next national holiday in {country}?". In this example you can see how to allow the AI to take an action.
[SmartTool.Tool]
[Description("Changes the background color of the application header.")]
public void SetHeaderColor(
[Description("Name of the new color. Use @toolbar to reset to the original color.")]
string color)
{
((MainPage)Application.MainPage).panelHeader.BackColor = Color.FromName(color);
}
When the AI wants to change the header color it will invoke this method with the correct parameter. Use this feature with a lot of caution! A method like "LaunchThermonuclearStrike()" is not allowed.
Constructors
SmartChatBoxAdapter()

Initializes a new instance of SmartChatBoxAdapter.
Properties
AutoReset

Boolean: Gets or sets a value indicating whether the history of the conversation is cleared after each response. (Default: False
)
BotAvatar

String: Icon of the AI bot. (Default: "resource.wx/Wisej.AI/Icons/wisej-avatar.svg"
)
BotName

String: Name of the AI bot. (Default: "Wisej.AI"
)
ChatBox

User

User: The User associated to the AI bot. It's created using BotName and BotAvatar.
Methods
FormatAnswer(answer, sources)

Returns: String.
OnAnswerReceived(args)

OnControlCreated(control)

OnControlDisposed(control)

OnSourceClicked(args)

ParseAnswer(text)

Returns: String.
ParseSources(text)

Returns: String[].
ResetSession(removeMessages)

Resets the conversation history.
removeMessages
Indicates whether all messages from the ChatBox control should also be removed.
RunAsyncCore(control)

Returns: Task<Message>.
Events
AnswerReceived

SourceClicked

Implements
Represents a provider that supplies tools.
Last updated