Skip to main content

SmartDocumentAdapter

Namespace: Wisej.AI.Adapters

Assembly: Wisej.AI

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.

public class SmartDocumentAdapter : SmartAdapter

This class integrates with the IEmbeddingStorageService to search within the document being managed. It provides properties to configure the bot's appearance and document handling, and events to manage responses.

Constructors​

SmartDocumentAdapter()​

Initializes a new instance of the SmartDocumentAdapter class.

Properties​

AutoReset​

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

BotAvatar​

String: Gets or sets the avatar image source of the bot. (Default: "resource.wx/Wisej.AI/Icons/wisej-avatar.svg")

BotName​

String: Gets or sets the name of the bot. (Default: "Wisej.AI")

ChatBox​

ChatBox: Gets the associated ChatBox control.

ConversionService​

IDocumentConversionService: Gets or sets the document conversion service used for converting documents to text.

FilePath​

String: Gets or sets the file path of the document. (Default: null)

FileType​

String: Gets or sets the file type. i.e. .docx, .pdf, .txt. If null it will be detected automatically. (Default: null)

MaxClusters​

Int32: Get or sets the maximum number of vector clusters to generate when performing summarization tasks. (Default: 5)

MinSimilarity​

Single: Gets or sets the minimum similarity threshold. (Default: 0.25)

Stream​

Stream: Gets or sets the file path of the document. (Default: null)

TextSplitterService​

ITextSplitterService: Gets or sets the text splitter service used for splitting text into smaller chunks.

TopN​

Int32: Gets or sets the number of top results to retrieve. (Default: 10)

User​

User: Gets the user representing the bot.

Methods​

AskAsync(question)​

ParameterTypeDescription
questionString

Returns: Task<String>.

Throws:

OnAnswerReceived(e)​

Raises the AnswerReceived event.

ParameterTypeDescription
eAnswerReceivedArgsThe AnswerReceivedArgs instance containing the event data.

OnControlCreated(control)​

ParameterTypeDescription
controlControl

OnControlDisposed(control)​

ParameterTypeDescription
controlControl

ParseAnswer(text)​

ParameterTypeDescription
textString

Returns: String.

ParseSourceText(text)​

ParameterTypeDescription
textString

Returns: String.

ResetSession(removeMessages)​

Resets the conversation history.

ParameterTypeDescription
removeMessagesBooleanIndicates whether all messages from the ChatBox control should also be removed.

RunAsyncCore(control)​

Executes the core logic asynchronously.

ParameterTypeDescription
controlControlThe control associated with the operation.

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

Events​

AnswerReceived​

AnswerReceivedHandler Occurs when an answer is received.

Implements​

NameDescription
IToolProviderRepresents a provider that supplies tools.