SmartAdapter
Overview
This is the base class for all adapters. It provides essential functionality and common properties that are shared by all adapter implementations.
In Wisej.AI, the concept of adapters serves the purpose of connecting application objects to AI providers. Acting as a "bridge," these adapters adjust the AI responses to ensure compatibility with the specific application objects. This adaptation facilitates seamless integration between the AI functionalities and the targeted application components.
The SmartAdapter utilizes all the Wisej.AI components (such as SmartHub, SmartPrompt, and SmartSession), along with various tools, to maximize the powerful UI controls and real-time capabilities of Wisej.NET.
Properties
All adapters share these properties.
Hub
The Hub property is responsible for connecting the adapter to a SmartHub
instance, which serves as the source for obtaining the endpoint for the adapter's operation. Multiple adapters can be configured to utilize the same SmartHub
instance.
AutoUpdate
AutoUpdate is a property that specifies whether the adapter should automatically refresh the browser upon completion of its processing tasks. This functionality requires an active WebSocket connection. The default value is true.
AutoRun
AutoRun is a property that determines whether the adapter should execute automatically. This property is applicable only to adapters linked to a control and intended to respond to control-related events. For instance, if the adapter is configured to trigger actions when the text of a control changes, it utilizes this property. The default value is true.
Busy
The Busy property is a read-only attribute that indicates whether the adapter is currently engaged in processing a request sent to the AI endpoint.
When the value of this property changes, it triggers the BusyChanged event.
SystemPrompt
The system prompt utilized by the adapter can be specified as either a string or a key name within an .ini file. This property is helps in fine-tuning the adapter's behavior.
For instance, you can set the system prompt with the following syntax:
This configuration directs the adapter to focus exclusively on customer service-related inquiries.
Usage
Tools
The Tools property is a collection of SmartTool
methods that are registered with the adapter. This property allows you to add, remove, and inspect the tools within the collection.
Parameters
The collection of parameters associated with this adapter consists of placeholders that can be utilized throughout Wisej.AI. These placeholders can be inserted in various locations, such as:
Prompts
Description attribute
FieldPrompt attribute
Placeholders are enclosed within {{
and }}
. However, they are defined using only their name. To assign a value to a parameter, you can use the Add()
method to add or replace a parameter or the indexer.
Agents
Agents within this collection are processed in the order they are added, ensuring a predictable sequence of operations. This enables developers to orchestrate complex sequences of actions or modifications before or after AI model interactions.
Agents in Wisej.AI are capable of working also with audio and image-related adapters. They can perform pre-processing or post-processing tasks on audio and images, allowing for a wide range of functionalities such as enhancing, analyzing, or transforming the media content in conjunction with AI capabilities.
Session
The Session property maintains a reference to the current SmartSession
utilized by the adapter. This property is essential as it allows the adapter to access and manage session-specific data and states, providing a context for operations and ensuring that interactions with the AI model can be tailored based on the session's attributes and history.
Controls
This refers to the collection of controls associated with the adapter. It is important to note that not all adapters are linked to controls.
Events
Start
This event is triggered when the adapter begins its communication with the AI model. It marks the initial stage of interaction, allowing developers to execute any predefined actions or set up necessary conditions at the onset of the exchange between the adapter and the AI model.
Done
This event is triggered once the adapter has received a response from the AI model and completed processing it. At this point, all necessary handling, modifications, and enhancements have been applied. This event provides an opportunity for developers to perform post-processing actions, such as logging the transaction, updating the user interface, or invoking other application logic based on the finalized data.
BusyChanged
Similar to the Start and Done events, the BusyChanged event occurs whenever there is a change in the value of the Busy property.
Last updated