GoogleAIEndpoint
Namespace: Wisej.AI.Endpoints
Assembly: Wisej.AI
Represents a connection to Google AI endpoints for generating content and embeddings.
- C#
- VB.NET
public class GoogleAIEndpoint : SmartHttpEndpoint
Public Class GoogleAIEndpoint
Inherits 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 | Object | The payload to which messages are added. |
| session | SmartSession | The current session. |
| messages | IList<Message> | The list of messages to be processed. |
Throws:
- ArgumentNullException
Thrown when session , payload , or messages is
null.
AddOptions(message, session)
Adds options to the message for content generation.
| Parameter | Type | Description |
|---|---|---|
| message | Object | The message to which options are added. |
| session | SmartSession | 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 | String[] | The array of input strings to be embedded. |
Returns: Object. The constructed payload object for embedding requests.
Throws:
- ArgumentNullException
Thrown when inputs is
null.
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 | Response | The response containing the assistant's message. |
| message | Message | The message object to populate with the assistant's response. |
Throws:
- ArgumentNullException
Thrown when response or message is
null.
ReadEmbeddingsResponse(response)
Reads the embeddings response and extracts the embedding vectors.
| Parameter | Type | Description |
|---|---|---|
| response | Response | The response containing the embeddings data. |
Returns: Single[][]. An array of float arrays representing the embedding vectors.
Throws:
- ArgumentNullException
Thrown when response is
null.
ReadUsage(message, reply)
Reads the usage data from the reply and updates the message usage.
| Parameter | Type | Description |
|---|---|---|
| message | Message | The message to update with usage data. |
| reply | Object | The reply containing usage metadata. |