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.

Parameter
Type
Description

session

The current smart session.

messages

A list of messages to process.

Returns: Task<Message>. A task that represents the asynchronous operation. The task result contains the response message.

Throws:

Dispose(disposing)

Releases the unmanaged resources used by the component and optionally releases the managed resources.

Parameter
Type
Description

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.

Parameter
Type
Description

query

The query string to compare.

text

An array of text strings to compare against the query.

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.

Parameter
Type
Description

response

The response containing the assistant message.

message

The message to update with the assistant's response.

Throws:

ReadUsage(message, reply)

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

Parameter
Type
Description

message

The message to update with usage information.

reply

The reply containing usage information.

Last updated