SmartHttpEndpoint
Wisej.AI.Endpoints.SmartHttpEndpoint
Last updated
Wisej.AI.Endpoints.SmartHttpEndpoint
Last updated
Namespace: Wisej.AI.Endpoints
Assembly: Wisej.AI (3.5.0.0)
Represents an abstract base class for a smart HTTP endpoint, providing common functionality for HTTP-based communication.
This class is designed to facilitate communication with HTTP endpoints by managing authentication, headers, and retry logic. It provides methods for sending requests and handling responses, including error detection and retry mechanisms.
Initializes a new instance of the class.
: Gets or sets the API key used for authentication. (Default: null
)
The URL should not end with a trailing slash. If a trailing slash is present, it will be removed.
Asynchronously sends a request to the endpoint and returns the response message.
session
The session managing the AI interaction.
messages
The list of messages to be sent.
**Throws:** * [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) Thrown when *session* or *messages* is null.
Asynchronously requests embeddings for the specified inputs.
inputs
The array of input strings for which embeddings are requested.
This method sends the inputs to the embeddings endpoint and returns the resulting embeddings.Throws:
Builds the payload for the request.
session
The session managing the AI interaction.
messages
The list of messages to be included in the payload.
Throws:
Creates the HTTP content from the given data.
data
The data to be serialized into the content.
Detects if the context limit has been exceeded in the response.
response
The HTTP response message.
Detects if the rate limit has been exceeded in the response.
response
The HTTP response message.
Gets the API key for the endpoint.
Gets the API URL for the endpoint.
Gets the URL for embeddings.
Throws:
Asynchronously sends a POST request to the specified URL with the given data.
url
The URL to send the request to.
data
The data to be sent in the request body.
This method handles retries and error detection, including token and rate limit exceeded exceptions.Throws:
Reads the assistant's message from the API response.
response
The response received from the API.
message
The message object to populate with the response content.
Throws:
Reads the usage statistics from the API response.
message
The message object to update with usage data.
reply
The dynamic object containing the API response data.
Represents an endpoint for connecting to Amazon Bedrock services.
Represents an endpoint for connecting to Anthropic services.
Represents an endpoint for connecting to Azure AI services, specifically designed to interact with OpenAI models.
Represents a connection to Cerebras endpoints, inheriting from OpenAIEndpoint.
Represents a connection to DeepSeek endpoints, inheriting from OpenAIEndpoint.
Represents a connection to Google AI endpoints for generating content and embeddings.
https://console.groq.com/docs/openai
Represents a connection to GroqCloud speech endpoints for audio transcription.
Represents a connection to HuggingFace serverless endpoints for model inference and embeddings.
Represents a connection to LocalAI endpoints, providing access to various AI models and services.
Represents an endpoint for connecting to LocalAI Image Generation services.
Represents an endpoint for connecting to LocalAI's speech services.
Represents an endpoint for connecting to LocalAI's Whisper model for speech-to-text transcriptions.
Represents a connection to NVIDIA AI endpoints, providing access to various AI models and services.
Represents an endpoint that connects to Ollama services, providing functionalities for chat and embeddings.
Represents an endpoint for connecting to OpenAI services.
Represents an endpoint for connecting to OpenAI DallE services.
Represents a component that manages communication with OpenAI's real-time API endpoints.
Represents an endpoint for connecting to OpenAI's speech services.
Represents an endpoint for connecting to OpenAI's Whisper model for speech-to-text transcriptions.
Represents a connection to SambaNova endpoints, inheriting from OpenAIEndpoint.
Represents a connection to TogetherAI endpoints, providing access to various AI models and services.
Represents a connection to X.AI endpoints, extending the functionality of OpenAIEndpoint.
: Gets or sets the authentication scheme used for requests. (Default: "Bearer"
)
: Gets or sets the collection of additional headers to be included in requests.
: Gets or sets the maximum number of retry attempts for failed requests. (Default: 10
)
: Gets or sets the delay between retry attempts in milliseconds. (Default: 10000
)
: Gets or sets the base URL of the endpoint. (Default: null
)
Returns: . A task representing the asynchronous operation, with a as the result.
Returns: . A task representing the asynchronous operation, with an as the result.
Thrown when inputs is null.
Thrown when the embedding model is not defined.
Returns: . The constructed payload object.
Thrown when session or messages is null.
Returns: . The created .
Returns: . true
if the context limit is exceeded; otherwise, false
.
Returns: . true
if the rate limit is exceeded; otherwise, false
.
Returns: . The API key as a string.
Returns: . The API URL as a string.
Returns: . The embeddings URL as a string.
Thrown when the method is not implemented.
Returns: . A task representing the asynchronous operation, with a as the result.
Thrown when the token limit is exceeded.
Thrown when the rate limit is exceeded.
Thrown when the response status code is not OK.
Thrown when the response or message is null.