Skip to main content

SmartAdapter

Namespace: Wisej.AI

Assembly: Wisej.AI

Represents an abstract base class for creating smart adapters that interact with AI endpoints.

public class SmartAdapter : Component, 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.

NameTypeDescription
containerIContainerAn 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.

ParameterTypeDescription
prompt SmartPromptThe 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.

ParameterTypeDescription
TThe type of session to create.
systemPrompt SmartPromptThe 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.

ParameterTypeDescription
disposingBooleanTrue 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.

ParameterTypeDescription
messageMessageMessage 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.

ParameterTypeDescription
controlControlThe control to check.

Returns: Boolean. True if the control is associated; otherwise, false.

NotifyAgentsAsync(message)

Notifies all agents asynchronously with a message.

ParameterTypeDescription
messageMessageThe message to notify agents with.

Returns: Task. A task representing the asynchronous operation.

OnBusyChanged(e)

Raises the BusyChanged event.

ParameterTypeDescription
eEventArgsAn EventArgs that contains the event data.

OnControlCreated(control)

Called when a control is created.

ParameterTypeDescription
controlControlThe control that was created.

OnControlDisposed(control)

Called when a control is disposed.

ParameterTypeDescription
controlControlThe control that was disposed.

OnDone(e)

Raises the Done event.

ParameterTypeDescription
eEventArgsAn EventArgs that contains the event data.

OnStart(e)

Raises the Start event.

ParameterTypeDescription
eEventArgsAn EventArgs that contains the event data.

RegisterControl(control)

Registers a control with the adapter.

ParameterTypeDescription
controlControlThe control to register.

RemoveTool(tool)

Removes a tool from the adapter.

ParameterTypeDescription
toolDelegateThe tool to remove.

Returns: SmartAdapter.

RemoveTools(target)

Removes the tools from the specified object.

ParameterTypeDescription
targetObjectThe target object containing tools.

Returns: SmartAdapter. The current SmartAdapter instance.

RunAsync(control)

Runs the adapter asynchronously.

ParameterTypeDescription
control ControlThe control to run the adapter on.

Returns: Task<Message>. A task representing the asynchronous operation.

UnregisterControl(control)

Unregisters a control from the adapter.

ParameterTypeDescription
controlControlThe control to unregister.

UseTool(tool)

Adds a tool to the adapter.

ParameterTypeDescription
toolDelegateThe tool to add.

Returns: SmartAdapter.

UseTools(target)

Adds multiple tools to the adapter from a target object.

ParameterTypeDescription
targetObjectThe 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

NameDescription
SmartAudioTTSAdapterConverts the Text of the associated Audio control into lifelike speech.
SmartAudioWhisperAdapterTranscribes the audio file of the of the associated Audio control to its Text property in the original language of the audio. speech-to-text
SmartCalendarAdapterRepresents a smart calendar adapter that extends the functionality of a SmartAdapter.
SmartChartAdapterRepresents an adapter that enhances a chart control with AI features.
SmartChartJS3AdapterRepresents an adapter that enhances a ChartJS control with several AI features.
SmartChatBoxAdapterTurns 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).
SmartComboBoxAdapterAdds semantic filtering to the ComboBox auto-complete functionality.
SmartCopilotAdapterTurns 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).
SmartDataEntryAdapterEnhances all the controls in the associated container with the AI-powered capability to extract structured data from unstructured text.
SmartDocumentAdapterRepresents 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
SmartObjectAdapterConverts unstructured text into a structured .NET object.
SmartPictureBoxAdapterRepresents an adapter for a PictureBox that generates images based on a description using the OpenAI DALL-E endpoint.
SmartQueryAdapterRepresents an adapter that generates a data set from a database schema and a user-provided description.
SmartRealtimeAdapterRepresents a smart adapter that provides real-time data processing capabilities for use with the OpenAIEndpointRealtime endpoint.
SmartReportAdapterEnhances the ChatBox control to allow seamless PDF report queries using an AI provider.
SmartTextBoxAdapterEnhances a TextBox control with several AI features, including suggestions, translation, and auto-correction.

Implements

NameDescription
IToolProviderRepresents a provider that supplies tools.