LogoLogo
HomeNewsSupportVideos
  • Welcome
  • Wisej.NET
  • Concepts
    • Getting Started
    • General Concepts
    • Architecture
    • Extensibility
    • AI Providers
    • Vector Databases
    • Usage Metrics
    • Logging & Error Handling
  • Markup
  • Components
    • API
      • SmartAdapter
        • SmartAudioTTSAdapter
        • SmartAudioWhisperAdapter
        • SmartCalendarAdapter
        • SmartChartAdapter
        • SmartChartJS3Adapter
        • SmartChatBoxAdapter
        • SmartComboBoxAdapter
        • SmartCopilotAdapter
        • SmartDataEntryAdapter
        • SmartDocumentAdapter
        • SmartFullCalendarAdapter
        • SmartObjectAdapter
        • SmartPictureBoxAdapter
        • SmartQueryAdapter
        • SmartRealtimeAdapter
        • SmartReportAdapter
        • SmartTextBoxAdapter
        • SmartAdapter.ExtendsAttribute
        • SmartAdapter.FieldNameAttribute
        • SmartAdapter.FieldPromptAttribute
        • SmartAdapter.FieldRectangleAttribute
        • SmartAdapter.WorksWithAttribute
      • SmartEndpoint
        • AmazonBedrockEndpoint
        • AnthropicEndpoint
        • AzureAIEndpoint
        • CerebrasEndpoint
        • DeepSeekEndpoint
        • GoogleAIEndpoint
        • GroqCloudEndpoint
        • GroqCloudEndpointWhisper
        • HuggingFaceEndpoint
        • HuggingFaceJavaScriptEndpoint
        • LocalAIEndpoint
        • LocalAIEndpointImageGen
        • LocalAIEndpointTTS
        • LocalAIEndpointWhisper
        • NvidiaAIEndpoint
        • OllamaEndpoint
        • OpenAIEndpoint
        • OpenAIEndpointDallE
        • OpenAIEndpointRealtime
        • OpenAIEndpointTTS
        • OpenAIEndpointWhisper
        • SambaNovaEndpoint
        • SmartHttpEndpoint
        • TogetherAIEndpoint
        • XAIEndpoint
        • SmartEndpoint.Metrics
        • SmartEndpoint.Response
      • SmartExtensions
      • SmartHub
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartObject
      • SmartPrompt
        • SmartAgentPrompt
        • SmartParallelPrompt
        • SmartPrompt.Parameter
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartRealtimeSession
      • SmartSession
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.Message
        • SmartSession.MessageCollection
        • SmartSession.MessageRole
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
        • SmartSession.TrimmingStrategy
      • SmartTool
        • SmartTool.IToolProvider
        • SmartTool.ToolAttribute
        • SmartTool.ToolContext
      • Markup
        • MarkupExtensions
      • Controls
        • UVLightOverlay
      • Embeddings
        • EmbeddedDocument
        • Embedding
        • Matches
        • Metadata
      • Helpers
        • ApiKeys
        • Markdown
        • TextTokenizer
      • Services
        • DefaultSessionTrimmingService
        • IDocumentConversionService
          • DefaultDocumentConversionService
        • IEmbeddingGenerationService
          • DefaultEmbeddingGenerationService
          • HuggingFaceEmbeddingGenerationService
        • IEmbeddingStorageService
          • AzureAISearchEmbeddingStorageService
          • ChromaEmbeddingStorageService
          • FileSystemEmbeddingStorageService
          • MemoryEmbeddingStorageService
          • PineconeEmbeddingStorageService
          • QdrantEmbeddingStorageService
        • IHttpClientService
          • DefaultHttpClientService
        • ILoggerService
          • DefaultLoggerService
        • IOCRService
          • DefaultOCRService
        • IRerankingService
          • DefaultRerankingService
          • LocalAIRerankingService
          • PineconeRerankingService
        • ISessionTrimmingService
          • DefaultSessionTrimmingService
        • ITextSplitterService
          • RecursiveCharacterTextSplitterService
          • TextSplitterServiceBase
        • ITokenizerService
          • DefaultTokenizerService
        • IWebSearchService
          • BingWebSearchService
          • BraveWebSearchService
          • GoogleWebSearchService
      • Tools
        • ArxivTools
        • ChartJS3Tools
        • DatabaseTools
        • DataTableFilterTools
        • DocumentSearchTools
        • DocumentTools
        • FullCalendarTools
        • IToolsContainer
        • MathTools
        • ToolsContainer
        • UtilityTools
        • WebSearchTools
    • Built-in Services
      • IOCRService
      • ILoggerService
      • ITextSplitterService
      • ITokenizerService
      • IHttpClientService
      • IWebSearchService
      • IRerankingService
      • ISessionTrimmingService
      • IDocumentConversionService
      • IEmbeddingStorageService
      • IEmbeddingGenerationService
    • Built-in SmartTools
      • ToolsContainer
      • MathTools
      • UtilityTools
      • DatabaseTools
      • DocumentTools
      • DocumentSearchTools
      • WebSearchTools
      • ChartJS3Tools
      • FullCalendarTools
    • Built-in SmartAdapters
      • SmartAdapter
      • SmartAudioTTSAdapter
      • SmartAudioWhisperAdapter
      • SmartCalendarAdapter
      • SmartChartAdapter
      • SmartChartJS3Adapter
      • SmartChatBoxAdapter
      • SmartComboBoxAdapter
      • SmartCopilotAdapter
      • SmartDataEntryAdapter
      • SmartDocumentAdapter
      • SmartFullCalendarAdapter
      • SmartObjectAdapter
      • SmartPictureBoxAdapter
      • SmartQueryAdapter
      • SmartRealtimeAdapter
      • SmartReportAdapter
      • SmartTextBoxAdapter
    • Configure Services
    • Using SmartHub
    • Using SmartTools
    • Using SmartPrompt
    • Using SmartSession
    • Using SmartRealTimeAdapter
    • UVLightOverlay Control
Powered by GitBook
On this page
  • Constructors
  • SmartHttpEndpoint()
  • Properties
  • ApiKey
  • Authentication
  • Headers
  • MaxRetries
  • RetryDelay
  • URL
  • Methods
  • AskAsync(session, messages)
  • AskEmbeddingsAsync(inputs)
  • BuildPayload(session, messages)
  • CreateContent(data)
  • DetectContextLimitExceeded(response)
  • DetectRateLimitExceeded(response)
  • GetApiKey()
  • GetApiURL()
  • GetEmbeddingsURL()
  • PostAsync(url, data)
  • ReadAssistantMessage(response, message)
  • ReadUsage(message, reply)
  • Inherited By
Export as PDF
  1. Components
  2. API
  3. SmartEndpoint

SmartHttpEndpoint

Wisej.AI.Endpoints.SmartHttpEndpoint

PreviousSambaNovaEndpointNextTogetherAIEndpoint

Last updated 5 days ago

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
Public Class SmartHttpEndpoint
    Inherits 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 class.

Properties

ApiKey

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

Authentication

The URL should not end with a trailing slash. If a trailing slash is present, it will be removed.

Methods

Asynchronously sends a request to the endpoint and returns the response message.

Parameter
Type
Description

session

The session managing the AI interaction.

messages

The list of messages to be sent.

The implementation of this method should call session.Usage.Add(assistantMessage.Usage) to keep track of the input and output tokens utilized at the session level.

**Throws:** * [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) Thrown when *session* or *messages* is null.

Asynchronously requests embeddings for the specified inputs.

Parameter
Type
Description

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.

Parameter
Type
Description

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.

Parameter
Type
Description

data

The data to be serialized into the content.

Detects if the context limit has been exceeded in the response.

Parameter
Type
Description

response

The HTTP response message.

Detects if the rate limit has been exceeded in the response.

Parameter
Type
Description

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.

Parameter
Type
Description

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.

Parameter
Type
Description

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.

Parameter
Type
Description

message

The message object to update with usage data.

reply

The dynamic object containing the API response data.

Inherited By

Name
Description

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")

Headers

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

MaxRetries

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

RetryDelay

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

URL

: Gets or sets the base URL of the endpoint. (Default: null)

AskAsync(session, messages)

Returns: . A task representing the asynchronous operation, with a as the result.

AskEmbeddingsAsync(inputs)

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.

BuildPayload(session, messages)

Returns: . The constructed payload object.

Thrown when session or messages is null.

CreateContent(data)

Returns: . The created .

DetectContextLimitExceeded(response)

Returns: . true if the context limit is exceeded; otherwise, false.

DetectRateLimitExceeded(response)

Returns: . true if the rate limit is exceeded; otherwise, false.

GetApiKey()

Returns: . The API key as a string.

GetApiURL()

Returns: . The API URL as a string.

GetEmbeddingsURL()

Returns: . The embeddings URL as a string.

Thrown when the method is not implemented.

PostAsync(url, data)

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.

ReadAssistantMessage(response, message)

Thrown when the response or message is null.

ReadUsage(message, reply)

String
NameValueCollection
Int32
Int32
String
Task<Message>
Message
Task<Embedding>
Embedding
ArgumentNullException
NotSupportedException
Object
ArgumentNullException
HttpContent
HttpContent
Boolean
Boolean
String
String
String
NotImplementedException
Task<Response>
Response
TokenLimitExceededException
RateLimitExceededException
Exception
ArgumentNullException
SmartSession
IList<Message>
String[]
SmartSession
IList<Message>
Object
HttpResponseMessage
HttpResponseMessage
String
Object
Response
Message
Message
Object
AmazonBedrockEndpoint
AnthropicEndpoint
AzureAIEndpoint
CerebrasEndpoint
DeepSeekEndpoint
GoogleAIEndpoint
GroqCloudEndpoint
GroqCloudEndpointWhisper
HuggingFaceEndpoint
LocalAIEndpoint
LocalAIEndpointImageGen
LocalAIEndpointTTS
LocalAIEndpointWhisper
NvidiaAIEndpoint
OllamaEndpoint
OpenAIEndpoint
OpenAIEndpointDallE
OpenAIEndpointRealtime
OpenAIEndpointTTS
OpenAIEndpointWhisper
SambaNovaEndpoint
TogetherAIEndpoint
XAIEndpoint
SmartEndpoint
SmartHttpEndpoint
SmartHttpEndpoint
String