SmartHttpEndpoint
Wisej.AI.Endpoints.SmartHttpEndpoint
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.
public class SmartHttpEndpoint : SmartEndpoint
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.
Constructors
SmartHttpEndpoint()

Initializes a new instance of the SmartHttpEndpoint class.
Properties
ApiKey

String: Gets or sets the API key used for authentication. (Default: null
)
Authentication

String: Gets or sets the authentication scheme used for requests. (Default: "Bearer"
)
Headers

NameValueCollection: Gets or sets the collection of additional headers to be included in requests.
MaxRetries

Int32: Gets or sets the maximum number of retry attempts for failed requests. (Default: 10
)
RetryDelay

Int32: Gets or sets the delay between retry attempts in milliseconds. (Default: 10000
)
URL

String: Gets or sets the base URL of the endpoint. (Default: null
)
The URL should not end with a trailing slash. If a trailing slash is present, it will be removed.
Methods
AskAsync(session, messages)

Asynchronously sends a request to the endpoint and returns the response message.
Returns: Task<Message>. A task representing the asynchronous operation, with a Message as the result.
**Throws:** * [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) Thrown when *session* or *messages* is null.
AskEmbeddingsAsync(inputs)

Asynchronously requests embeddings for the specified inputs.
Returns: Task<Embedding>. A task representing the asynchronous operation, with an Embedding as the result.
This method sends the inputs to the embeddings endpoint and returns the resulting embeddings.Throws:
ArgumentNullException Thrown when inputs is null.
NotSupportedException Thrown when the embedding model is not defined.
BuildPayload(session, messages)

Builds the payload for the request.
Returns: Object. The constructed payload object.
Throws:
ArgumentNullException Thrown when session or messages is null.
CreateContent(data)

Creates the HTTP content from the given data.
Returns: HttpContent. The created HttpContent.
DetectContextLimitExceeded(response)

Detects if the context limit has been exceeded in the response.
Returns: Boolean. true
if the context limit is exceeded; otherwise, false
.
DetectRateLimitExceeded(response)

Detects if the rate limit has been exceeded in the response.
Returns: Boolean. true
if the rate limit is exceeded; otherwise, false
.
GetApiKey()

Gets the API key for the endpoint.
Returns: String. The API key as a string.
GetApiURL()

Gets the API URL for the endpoint.
Returns: String. The API URL as a string.
GetEmbeddingsURL()

Gets the URL for embeddings.
Returns: String. The embeddings URL as a string.
Throws:
NotImplementedException Thrown when the method is not implemented.
PostAsync(url, data)

Asynchronously sends a POST request to the specified URL with the given data.
Returns: Task<Response>. A task representing the asynchronous operation, with a Response as the result.
This method handles retries and error detection, including token and rate limit exceeded exceptions.Throws:
TokenLimitExceededException Thrown when the token limit is exceeded.
RateLimitExceededException Thrown when the rate limit is exceeded.
Exception Thrown when the response status code is not OK.
ReadAssistantMessage(response, message)

Reads the assistant's message from the API response.
Throws:
ArgumentNullException Thrown when the response or message is null.
ReadUsage(message, reply)

Reads the usage statistics from the API response.
Inherited By
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.
Last updated