HuggingFaceJavaScriptEndpoint
Wisej.AI.Endpoints.HuggingFaceJavaScriptEndpoint
Namespace: Wisej.AI.Endpoints
Assembly: Wisej.AI (3.5.0.0)
Represents an endpoint that uses the transformers.js module in the user's browser to provide AI services to Wisej.AI components.
public class HuggingFaceJavaScriptEndpoint : SmartEndpoint
This class is part of the SmartEndpoint category and is designed to interact with the Hugging Face transformers.js library. It provides various AI services such as text generation, translation, and more, by utilizing different pipelines.
Constructors
HuggingFaceJavaScriptEndpoint()

Initializes a new instance of the HuggingFaceJavaScriptEndpoint.
Properties
Id

String: Gets the unique identifier for the component.
Model

String: Gets or sets the model used by the endpoint. (Default: null
)
Pipeline

TransformersPipeline: Gets or sets the pipeline used by the endpoint. (Default: None
)
The pipeline determines the type of AI service provided, such as translation or text generation. index
PipelineSubtask

String: Gets or sets the subtask for the selected pipeline. (Default: ""
)
This property allows further specification of the task within the chosen pipeline. index
SourceURL

String: Gets or sets the source URL for the transformers.js library. (Default: "https://cdn.jsdelivr.net/npm/@xenova/transformers"
)
Methods
AskAsync(session, messages)

Asynchronously processes a list of messages and returns a response message.
Returns: Task<Message>. A task that represents the asynchronous operation. The task result contains the response message.
Throws:
ArgumentNullException Thrown when session or messages is null.
NotSupportedException Thrown when the pipeline is not supported.
Dispose(disposing)

Releases the unmanaged resources used by the component and optionally releases the managed resources.
disposing
true to release both managed and unmanaged resources; false to release only unmanaged resources.
GetSimilarityAsync(query, text)

Asynchronously calculates the similarity between a query and an array of text.
Returns: Task<Single[]>. A task that represents the asynchronous operation. The task result contains an array of similarity scores.
ReadAssistantMessage(response, message)

Reads the assistant message from the response and updates the message.
Throws:
ArgumentNullException Thrown when response or message is null.
ReadUsage(message, reply)

Reads the usage information from the reply and updates the message.
Last updated