Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DescriptorKeyForAIPromtTokenCount is the descriptor key for the AI prompt token count. DescriptorKeyForAIPromtTokenCount = "airequesttokencount" // DescriptorKeyForAICompletionTokenCount is the descriptor key for the AI completion token count. DescriptorKeyForAICompletionTokenCount = "airesponsetokencount" // DescriptorKeyForAITotalTokenCount is the descriptor key for the AI total token count. DescriptorKeyForAITotalTokenCount = "aitotaltokencount" // DescriptorKeyForSubscriptionBasedAIRequestTokenCount is the descriptor key for the subscription-based AI request token count. DescriptorKeyForSubscriptionBasedAIRequestTokenCount = "airequesttokencountsubs" // DescriptorKeyForSubscriptionBasedAIResponseTokenCount is the descriptor key for the subscription-based AI response token count. DescriptorKeyForSubscriptionBasedAIResponseTokenCount = "airesponsetokencountsubs" // DescriptorKeyForSubscriptionBasedAITotalTokenCount is the descriptor key for the subscription-based AI total token count. DescriptorKeyForSubscriptionBasedAITotalTokenCount = "aitotaltokencountsubs" // DescriptorKeyForAISubscription is the descriptor key for the AI subscription. DescriptorKeyForAISubscription = "subscription" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AIRatelimitHelper ¶
type AIRatelimitHelper struct {
// contains filtered or unexported fields
}
AIRatelimitHelper is a helper struct for managing AI rate limiting.
func NewAIRatelimitHelper ¶
func NewAIRatelimitHelper(cfg *config.Server) *AIRatelimitHelper
NewAIRatelimitHelper creates a new instance of the AIRatelimitHelper.
func (*AIRatelimitHelper) DoAIRatelimit ¶
func (airl *AIRatelimitHelper) DoAIRatelimit(tokenCount TokenCountAndModel, doBackendBasedAIRatelimit bool, doSubscriptionBasedAIRatelimit bool, backendBasedAIRatelimitDescriptorValue string, subscription *subscription_model.Subscription, application *subscription_model.Application)
DoAIRatelimit performs AI rate limiting.
type TokenCountAndModel ¶
TokenCountAndModel is a struct that holds the prompt, completion, and total token counts.
func ExtractTokenCountFromExternalProcessingResponseBody ¶
func ExtractTokenCountFromExternalProcessingResponseBody(body []byte, promptPath, completionPath, totalPath, modelPath string) (*TokenCountAndModel, error)
ExtractTokenCountFromExternalProcessingResponseBody extracts token counts from external processing response body.
func ExtractTokenCountFromExternalProcessingResponseHeaders ¶
func ExtractTokenCountFromExternalProcessingResponseHeaders(headerValues []*v3.HeaderValue, promptHeader, completionHeader, totalHeader, modelHeader string) (*TokenCountAndModel, error)
ExtractTokenCountFromExternalProcessingResponseHeaders extracts token counts from external processing response headers.
Click to show internal directories.
Click to hide internal directories.