GoogleAIEndpoint

Wisej.AI.Endpoints.GoogleAIEndpoint

Namespace: Wisej.AI.Endpoints

Assembly: Wisej.AI (3.5.0.0)

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.

Parameter
Type
Description

payload

The payload to which messages are added.

session

The current session.

messages

The list of messages to be processed.

Throws:

AddOptions(message, session)

Adds options to the message for content generation.

Parameter
Type
Description

message

The message to which options are added.

session

The 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.

Parameter
Type
Description

inputs

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.

Parameter
Type
Description

response

The response containing the assistant's message.

message

The message object to populate with the assistant's response.

Throws:

ReadEmbeddingsResponse(response)

Reads the embeddings response and extracts the embedding vectors.

Parameter
Type
Description

response

The 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.

Parameter
Type
Description

message

The message to update with usage data.

reply

The reply containing usage metadata.

Last updated