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.
Throws:
ArgumentNullException Thrown when the message is null.
AskEmbeddingsAsync(inputs)

Asynchronously requests embeddings for the specified inputs.
Returns: Task<Embedding>. A task representing the asynchronous operation, with a result of type Embedding.
Throws:
ArgumentNullException Thrown when the inputs are null.
BuildEmbeddingsPayload(inputs)

Builds the payload for the embeddings request.
Returns: Object. An object representing the payload for the embeddings request.
Throws:
ArgumentNullException Thrown when the inputs are null.
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.
Throws:
ArgumentNullException Thrown when the response or message is null.
ReadEmbeddingsResponse(response)

Reads the embeddings response and extracts the embeddings data.
Returns: Single[][]. A jagged array of floats representing the embeddings.
Throws:
ArgumentNullException Thrown when the response is null.
ReadUsage(message, reply)

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