SmartHub
Wisej.AI.SmartHub
Namespace: Wisej.AI
Assembly: Wisej.AI (3.5.0.0)
Represents a SmartHub component that provides AI capabilities to controls within a container.
public class SmartHub : SmartObject, IExtenderProvider, IToolProvider
The SmartHub class is an extender provider that allows controls to be extended with AI functionalities. It manages various services and tools to facilitate AI operations, such as embedding generation, document conversion, and similarity queries.
Constructors
SmartHub()

Initializes a new instance of the SmartHub class.
SmartHub(containerControl)

Initializes a new instance of the SmartHub class with a specified container control.
Throws:
ArgumentNullException Thrown when the containerControl is null.
SmartHub(container)

Initializes a new instance of the SmartHub class attached to an IContainer implementation.
Properties
BindingContext

BindingContext: Gets the binding context for the SmartHub.
ContainerControl

Control: Returns or sets the container Controlthat provides the BindingContext for binding to the IDataErrorInfo interface implemented by a DataSource. (Default: null
)
Culture

CultureInfo: Gets or sets the culture information for the SmartHub. (Default: null
)
DataSource

Object: Gets or sets a data source that can be used to resolve prompt parameters. (Default: null
)
Endpoint

SmartEndpoint: Gets or sets the default endpoint. (Default: null
)
IsDisposed

Boolean: Gets a value indicating whether the SmartHub is disposed.
Methods
AskAsync(question, image, systemPrompt)

Asynchronously asks a question and returns a response message.
Returns: Task<Message>. A task representing the asynchronous operation, with a Message as the result.
Throws:
ArgumentNullException Thrown when the question is null.
Dispose(disposing)

Releases the unmanaged resources used by the SmartHub and optionally releases the managed resources.
disposing
true to release both managed and unmanaged resources; false to release only unmanaged resources.
EmbedAsync(text)

Asynchronously generates an embedding for a specified text.
Returns: Task<Embedding>. A task representing the asynchronous operation, with an Embedding as the result.
EmbedAsync(chunks)

Asynchronously generates an embedding for a specified array of text chunks.
Returns: Task<Embedding>. A task representing the asynchronous operation, with an Embedding as the result.
Throws:
ArgumentNullException Thrown when the chunks array is null.
GetAdapter(control)

Gets the adapter associated with a specified control.
Returns: SmartAdapter. The SmartAdapter associated with the control, or null if none exists.
Throws:
ArgumentNullException Thrown when the control is null.
GetAdapter<T>(control)

Gets the adapter of a specified type associated with a specified control.
T
The type of the adapter.
Returns: T. The adapter of type T associated with the control, or null if none exists.
Throws:
ArgumentNullException Thrown when the control is null.
GetAI(control)

Gets the AI properties for a specified control.
Returns: Properties. The Properties associated with the control.
GetParameterValue(parameter)

Gets the value of a specified parameter.
Returns: Object. The value of the parameter as a string.
Throws:
ArgumentNullException Thrown when the parameter is null.
IngestDocumentAsync(filePath, documentName, collectionName, metadata, overwrite)

Asynchronously ingests a document from a specified file path.
Returns: Task<EmbeddedDocument>. A task representing the asynchronous operation, with an EmbeddedDocument as the result.
This method utilizes several services to perform its operations: ITextSplitterService, and IDocumentConversionService, and IEmbeddingGenerationService, and IEmbeddingStorageService.Throws:
ArgumentNullException Thrown when the filePath or documentName is null.
IngestDocumentAsync(stream, documentName, collectionName, overwrite, metadata)

Asynchronously ingests a document from a specified stream.
Returns: Task<EmbeddedDocument>. A task representing the asynchronous operation, with an EmbeddedDocument as the result.
This method utilizes several services to perform its operations: ITextSplitterService, and IDocumentConversionService, and IEmbeddingGenerationService, and IEmbeddingStorageService.Throws:
ArgumentNullException Thrown when the stream or documentName is null.
RemoveAdapter(adapter)

Removes a specified adapter from the SmartHub.
Throws:
ArgumentNullException Thrown when the adapter is null.
RemoveTool(tool)

Removes a tool from the SmartHub.
Returns: SmartHub. The current SmartHub instance.
Throws:
ArgumentNullException Thrown when the tool is null.
SimilarityQueryAsync(query, chunks, topN, minSimilarity, computeSimilarity)

Asynchronously performs a similarity query on a specified query and text chunks.
computeSimilarity
The function to compute similarity. Default is null.
Returns: Task<String[]>. A task representing the asynchronous operation, with an array of strings as the result.
Throws:
ArgumentNullException Thrown when the query or chunks are null.
SimilarityQueryAsync(query, chunks, vectors, topN, minSimilarity, computeSimilarity)

Asynchronously performs a similarity query on a specified query, text chunks, and vectors.
computeSimilarity
The function to compute similarity. Default is null.
Returns: Task<String[]>. A task representing the asynchronous operation, with an array of strings as the result.
Throws:
ArgumentNullException Thrown when the query, chunks, or vectors are null.
SimilarityScoreAsync(query, chunks, computeSimilarity)

Asynchronously calculates similarity scores for a specified query and text chunks.
computeSimilarity
The function to compute similarity. Default is null.
Returns: Task<Single[]>. A task representing the asynchronous operation, with an array of floats as the result.
Throws:
ArgumentNullException Thrown when the query or chunks are null.
SimilarityScoreAsync(query, chunks, embeddings, computeSimilarity)

Asynchronously calculates similarity scores for a specified query, text chunks, and embeddings.
computeSimilarity
The function to compute similarity. Default is null.
Returns: Task<Single[]>. A task representing the asynchronous operation, with an array of floats as the result.
Throws:
ArgumentNullException Thrown when the query, chunks, or embeddings are null.
UseTool(tool)

Adds a tool to the SmartHub.
Returns: SmartHub. The current SmartHub instance.
Throws:
ArgumentNullException Thrown when the tool is null.
UseTools(target)

Uses tools from a specified target.
Returns: SmartHub. The current SmartHub instance.
Implements
Represents a provider that supplies tools.
Last updated