OllamaEndpoint

Wisej.AI.Endpoints.OllamaEndpoint

Namespace: Wisej.AI.Endpoints

Assembly: Wisej.AI (3.5.0.0)

Represents an endpoint that connects to Ollama services, providing functionalities for chat and embeddings.

public class OllamaEndpoint : SmartHttpEndpoint

This class extends the SmartHttpEndpoint to interact with Ollama endpoints. It provides methods to construct API URLs, add options to messages, and handle responses.

Constructors

OllamaEndpoint()

Initializes a new instance of the OllamaEndpoint class with default settings.

Properties

EmbeddingModel

String: Gets or sets the embedding model used by the endpoint. (Default: "all-minilm")

MaxContextTokens

Int32: Gets or sets the maximum number of tokens the context window for the specified Model can hold. (Default: 8192)

Methods

AddOptions(message, session)

Adds options to the message for the current session.

Parameter
Type
Description

message

The dynamic message object to which options are added.

session

The current session containing model options.

Throws:

AskEmbeddingsAsync(inputs)

Asynchronously requests embeddings for the specified inputs.

Parameter
Type
Description

inputs

An array of input strings for which embeddings are requested.

Returns: Task<Embedding>. A task representing the asynchronous operation, with a result of type Embedding.

Throws:

BuildEmbeddingsPayload(inputs)

Builds the payload for the embeddings request.

Parameter
Type
Description

inputs

An array of input strings for which the payload is built.

Returns: Object. An object representing the payload for the embeddings request.

Throws:

GetApiURL()

Constructs the API URL for chat interactions.

Returns: String. A string representing the chat API URL.

GetEmbeddingsURL()

Constructs the API URL for embeddings interactions.

Returns: String. A string representing the embeddings API URL.

ReadAssistantMessage(response, message)

Reads the assistant's message from the response and updates the message object.

Parameter
Type
Description

response

The response received from the API.

message

The message object to be updated with the assistant's response.

Throws:

ReadEmbeddingsResponse(response)

Reads the embeddings response and extracts the embeddings data.

Parameter
Type
Description

response

The response received from the API.

Returns: Single[][]. A jagged array of floats representing the embeddings.

Throws:

ReadUsage(message, reply)

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

Parameter
Type
Description

message

The message object to be updated with usage statistics.

reply

The dynamic reply object containing usage information.

Last updated