Skip to main content

GoogleAIEndpoint

Namespace: Wisej.AI.Endpoints

Assembly: Wisej.AI

Represents a connection to Google AI endpoints for generating content and embeddings.

public class GoogleAIEndpoint : SmartHttpEndpoint

This class is used to interact with Google AI services, allowing for content generation and text embeddings. It extends the SmartHttpEndpoint to provide specific functionality for Google AI.

Constructors

GoogleAIEndpoint()

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

Properties

Authentication

String: Gets or sets the authentication token for accessing the Google AI endpoint. (Default: null)

EmbeddingModel

String: Gets or sets the model used for text embeddings. (Default: "text-embedding-004")

Model

String: Gets or sets the model used for content generation. (Default: "gemini-1.5-pro-latest")

URL

String: Gets or sets the base URL for the Google AI endpoint. (Default: "https://generativelanguage.googleapis.com/v1beta/models")

Methods

AddMessages(payload, session, messages)

Adds messages to the payload for processing.

ParameterTypeDescription
payloadObjectThe payload to which messages are added.
sessionSmartSessionThe current session.
messagesIList<Message>The list of messages to be processed.

Throws:

AddOptions(message, session)

Adds options to the message for content generation.

ParameterTypeDescription
messageObjectThe message to which options are added.
sessionSmartSessionThe current session containing model options.

This method configures the generation parameters such as temperature and max output tokens. It also incorporates any additional model options from the session.

BuildEmbeddingsPayload(inputs)

Builds the payload for embedding requests.

ParameterTypeDescription
inputsString[]The array of input strings to be embedded.

Returns: Object. The constructed payload object for embedding requests.

Throws:

GetApiURL()

Constructs the API URL for content generation requests.

Returns: String. The constructed API URL as a string.

GetEmbeddingsURL()

Constructs the API URL for embedding requests.

Returns: String. The constructed embeddings URL as a string.

ReadAssistantMessage(response, message)

Reads the assistant's message from the response.

ParameterTypeDescription
responseResponseThe response containing the assistant's message.
messageMessageThe message object to populate with the assistant's response.

Throws:

ReadEmbeddingsResponse(response)

Reads the embeddings response and extracts the embedding vectors.

ParameterTypeDescription
responseResponseThe response containing the embeddings data.

Returns: Single[][]. An array of float arrays representing the embedding vectors.

Throws:

ReadUsage(message, reply)

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

ParameterTypeDescription
messageMessageThe message to update with usage data.
replyObjectThe reply containing usage metadata.