SmartAdapter
Namespace: Wisej.AI
Assembly: Wisej.AI
Represents an abstract base class for creating smart adapters that interact with AI endpoints.
- C#
- VB.NET
public class SmartAdapter : Component, IToolProvider
Public Class SmartAdapter
Inherits Component
Implements IToolProvider
Constructors
SmartAdapter()
Initializes a new instance of the SmartAdapter class.
SmartAdapter(container)
Initializes a new instance of the SmartAdapter class attached to an IContainer implementation to allow for disposing the SmartAdapter when the service container is disposed.
| Name | Type | Description |
|---|---|---|
| container | IContainer | An IContainer that represents the container of the component. |
Properties
Agents
AgentCollection: Gets the collection of agents associated with this adapter.
AutoRun
Boolean: Gets or sets a value indicating whether the adapter should automatically run. (Default: True)
AutoUpdate
Boolean: Gets or sets a value indicating whether the adapter should automatically update the browser when is done processing (requires a working WebSocket connection). (Default: True)
Busy
Boolean: Gets or sets a value indicating whether the adapter is busy. (Default: False)
Controls
IList<Control>: Gets the list of controls associated with this adapter.
HasTools
Boolean: Gets a value indicating whether the adapter has any tools.
Hub
SmartHub: Gets or sets the SmartHub associated with this adapter.
Name
String: Gets or sets the name of the adapter.
Parameters
ParameterCollection: Gets the collection of parameters associated with this adapter.
Session
SmartSession: Gets the SmartSession in use by the adapter.
SystemPrompt
String: Gets or sets the system prompt used by the adapter. (Default: "")
Tools
ToolCollection: Gets the collection of tools associated with this adapter.
Usage
Metrics: Gets the usage metrics for the session.
Methods
ClearTools()
Clears all tools from the adapter.
CreateSession(prompt)
Creates a new session with an optional prompt.
| Parameter | Type | Description |
|---|---|---|
| prompt | SmartPrompt | The prompt to use for the session. |
Returns: SmartSession. A new SmartSession instance.
CreateSession<T>(systemPrompt)
Creates a new session of a specified type with an optional prompt.
| Parameter | Type | Description |
|---|---|---|
| T | The type of session to create. | |
| systemPrompt | SmartPrompt | The system prompt to use for the session. |
Returns: T. A new session of type T .
Dispose(disposing)
Releases the unmanaged resources used by the SmartAdapter and optionally releases the managed resources.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | True to release both managed and unmanaged resources; false to release only unmanaged resources. |
GetJSON(message)
Returns the JSON string returned in the message by stripping the enclosing markers (json and ) if present.
| Parameter | Type | Description |
|---|---|---|
| message | Message | Message with the response text that may be a JSON string. |
Returns: String. JSON string.
IsAssociatedWith(control)
Determines whether a control is associated with the adapter.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to check. |
Returns: Boolean. True if the control is associated; otherwise, false.
NotifyAgentsAsync(message)
Notifies all agents asynchronously with a message.
| Parameter | Type | Description |
|---|---|---|
| message | Message | The message to notify agents with. |
Returns: Task. A task representing the asynchronous operation.
OnBusyChanged(e)
Raises the BusyChanged event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | An EventArgs that contains the event data. |
OnControlCreated(control)
Called when a control is created.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control that was created. |
OnControlDisposed(control)
Called when a control is disposed.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control that was disposed. |
OnDone(e)
Raises the Done event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | An EventArgs that contains the event data. |
OnStart(e)
Raises the Start event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | An EventArgs that contains the event data. |
RegisterControl(control)
Registers a control with the adapter.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to register. |
RemoveTool(tool)
Removes a tool from the adapter.
| Parameter | Type | Description |
|---|---|---|
| tool | Delegate | The tool to remove. |
Returns: SmartAdapter.
RemoveTools(target)
Removes the tools from the specified object.
| Parameter | Type | Description |
|---|---|---|
| target | Object | The target object containing tools. |
Returns: SmartAdapter. The current SmartAdapter instance.
RunAsync(control)
Runs the adapter asynchronously.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to run the adapter on. |
Returns: Task<Message>. A task representing the asynchronous operation.
UnregisterControl(control)
Unregisters a control from the adapter.
| Parameter | Type | Description |
|---|---|---|
| control | Control | The control to unregister. |
UseTool(tool)
Adds a tool to the adapter.
| Parameter | Type | Description |
|---|---|---|
| tool | Delegate | The tool to add. |
Returns: SmartAdapter.
UseTools(target)
Adds multiple tools to the adapter from a target object.
| Parameter | Type | Description |
|---|---|---|
| target | Object | The target object containing tools. |
Returns: SmartAdapter.
Events
BusyChanged
EventHandler Occurs when the busy state of the adapter changes.
Done
EventHandler Occurs when the adapter has completed processing.
Start
EventHandler Occurs when the adapter starts processing.
Inherited By
| Name | Description |
|---|---|
| SmartAudioTTSAdapter | Converts the Text of the associated Audio control into lifelike speech. |
| SmartAudioWhisperAdapter | Transcribes the audio file of the of the associated Audio control to its Text property in the original language of the audio. speech-to-text |
| SmartCalendarAdapter | Represents a smart calendar adapter that extends the functionality of a SmartAdapter. |
| SmartChartAdapter | Represents an adapter that enhances a chart control with AI features. |
| SmartChartJS3Adapter | Represents an adapter that enhances a ChartJS control with several AI features. |
| SmartChatBoxAdapter | 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). |
| SmartComboBoxAdapter | Adds semantic filtering to the ComboBox auto-complete functionality. |
| SmartCopilotAdapter | Turns the ChatBox control into a AI-powered assistant. It can control and navigate an application, click menu items, navigation bar items, buttons, etc. It can also invoke methods in your applications as needed (see SmartTool). |
| SmartDataEntryAdapter | Enhances all the controls in the associated container with the AI-powered capability to extract structured data from unstructured text. |
| SmartDocumentAdapter | Represents a document adapter that can perform AI tasks using a document as a data source and interact with the user through a ChatBox control. |
| SmartFullCalendarAdapter | |
| SmartObjectAdapter | Converts unstructured text into a structured .NET object. |
| SmartPictureBoxAdapter | Represents an adapter for a PictureBox that generates images based on a description using the OpenAI DALL-E endpoint. |
| SmartQueryAdapter | Represents an adapter that generates a data set from a database schema and a user-provided description. |
| SmartRealtimeAdapter | Represents a smart adapter that provides real-time data processing capabilities for use with the OpenAIEndpointRealtime endpoint. |
| SmartReportAdapter | Enhances the ChatBox control to allow seamless PDF report queries using an AI provider. |
| SmartTextBoxAdapter | Enhances a TextBox control with several AI features, including suggestions, translation, and auto-correction. |
Implements
| Name | Description |
|---|---|
| IToolProvider | Represents a provider that supplies tools. |