diff --git a/api/applyconfiguration/api/v1alpha1/aipromptenrichment.go b/api/applyconfiguration/api/v1alpha1/aipromptenrichment.go new file mode 100644 index 00000000000..b4a4fc06c05 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/aipromptenrichment.go @@ -0,0 +1,42 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// AIPromptEnrichmentApplyConfiguration represents a declarative configuration of the AIPromptEnrichment type for use +// with apply. +type AIPromptEnrichmentApplyConfiguration struct { + Prepend []MessageApplyConfiguration `json:"prepend,omitempty"` + Append []MessageApplyConfiguration `json:"append,omitempty"` +} + +// AIPromptEnrichmentApplyConfiguration constructs a declarative configuration of the AIPromptEnrichment type for use with +// apply. +func AIPromptEnrichment() *AIPromptEnrichmentApplyConfiguration { + return &AIPromptEnrichmentApplyConfiguration{} +} + +// WithPrepend adds the given value to the Prepend field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Prepend field. +func (b *AIPromptEnrichmentApplyConfiguration) WithPrepend(values ...*MessageApplyConfiguration) *AIPromptEnrichmentApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithPrepend") + } + b.Prepend = append(b.Prepend, *values[i]) + } + return b +} + +// WithAppend adds the given value to the Append field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Append field. +func (b *AIPromptEnrichmentApplyConfiguration) WithAppend(values ...*MessageApplyConfiguration) *AIPromptEnrichmentApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithAppend") + } + b.Append = append(b.Append, *values[i]) + } + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/aipromptguard.go b/api/applyconfiguration/api/v1alpha1/aipromptguard.go new file mode 100644 index 00000000000..b5126c81a08 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/aipromptguard.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// AIPromptGuardApplyConfiguration represents a declarative configuration of the AIPromptGuard type for use +// with apply. +type AIPromptGuardApplyConfiguration struct { + Request *PromptguardRequestApplyConfiguration `json:"request,omitempty"` + Response *PromptguardResponseApplyConfiguration `json:"response,omitempty"` +} + +// AIPromptGuardApplyConfiguration constructs a declarative configuration of the AIPromptGuard type for use with +// apply. +func AIPromptGuard() *AIPromptGuardApplyConfiguration { + return &AIPromptGuardApplyConfiguration{} +} + +// WithRequest sets the Request field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Request field is set to the value of the last call. +func (b *AIPromptGuardApplyConfiguration) WithRequest(value *PromptguardRequestApplyConfiguration) *AIPromptGuardApplyConfiguration { + b.Request = value + return b +} + +// WithResponse sets the Response field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Response field is set to the value of the last call. +func (b *AIPromptGuardApplyConfiguration) WithResponse(value *PromptguardResponseApplyConfiguration) *AIPromptGuardApplyConfiguration { + b.Response = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/airoutepolicy.go b/api/applyconfiguration/api/v1alpha1/airoutepolicy.go new file mode 100644 index 00000000000..cd1e7ebd49d --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/airoutepolicy.go @@ -0,0 +1,59 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/kgateway-dev/kgateway/v2/api/v1alpha1" +) + +// AIRoutePolicyApplyConfiguration represents a declarative configuration of the AIRoutePolicy type for use +// with apply. +type AIRoutePolicyApplyConfiguration struct { + PromptEnrichment *AIPromptEnrichmentApplyConfiguration `json:"promptEnrichment,omitempty"` + PromptGuard *AIPromptGuardApplyConfiguration `json:"promptGuard,omitempty"` + Defaults []FieldDefaultApplyConfiguration `json:"defaults,omitempty"` + RouteType *apiv1alpha1.RouteType `json:"routeType,omitempty"` +} + +// AIRoutePolicyApplyConfiguration constructs a declarative configuration of the AIRoutePolicy type for use with +// apply. +func AIRoutePolicy() *AIRoutePolicyApplyConfiguration { + return &AIRoutePolicyApplyConfiguration{} +} + +// WithPromptEnrichment sets the PromptEnrichment field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the PromptEnrichment field is set to the value of the last call. +func (b *AIRoutePolicyApplyConfiguration) WithPromptEnrichment(value *AIPromptEnrichmentApplyConfiguration) *AIRoutePolicyApplyConfiguration { + b.PromptEnrichment = value + return b +} + +// WithPromptGuard sets the PromptGuard field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the PromptGuard field is set to the value of the last call. +func (b *AIRoutePolicyApplyConfiguration) WithPromptGuard(value *AIPromptGuardApplyConfiguration) *AIRoutePolicyApplyConfiguration { + b.PromptGuard = value + return b +} + +// WithDefaults adds the given value to the Defaults field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Defaults field. +func (b *AIRoutePolicyApplyConfiguration) WithDefaults(values ...*FieldDefaultApplyConfiguration) *AIRoutePolicyApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithDefaults") + } + b.Defaults = append(b.Defaults, *values[i]) + } + return b +} + +// WithRouteType sets the RouteType field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RouteType field is set to the value of the last call. +func (b *AIRoutePolicyApplyConfiguration) WithRouteType(value apiv1alpha1.RouteType) *AIRoutePolicyApplyConfiguration { + b.RouteType = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/aiupstream.go b/api/applyconfiguration/api/v1alpha1/aiupstream.go new file mode 100644 index 00000000000..bfb4621ed67 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/aiupstream.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// AIUpstreamApplyConfiguration represents a declarative configuration of the AIUpstream type for use +// with apply. +type AIUpstreamApplyConfiguration struct { + CustomHost *HostApplyConfiguration `json:"customHost,omitempty"` + LLM *LLMProvidersApplyConfiguration `json:"llm,omitempty"` + MultiPool *MultiPoolConfigApplyConfiguration `json:"multipool,omitempty"` +} + +// AIUpstreamApplyConfiguration constructs a declarative configuration of the AIUpstream type for use with +// apply. +func AIUpstream() *AIUpstreamApplyConfiguration { + return &AIUpstreamApplyConfiguration{} +} + +// WithCustomHost sets the CustomHost field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CustomHost field is set to the value of the last call. +func (b *AIUpstreamApplyConfiguration) WithCustomHost(value *HostApplyConfiguration) *AIUpstreamApplyConfiguration { + b.CustomHost = value + return b +} + +// WithLLM sets the LLM field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LLM field is set to the value of the last call. +func (b *AIUpstreamApplyConfiguration) WithLLM(value *LLMProvidersApplyConfiguration) *AIUpstreamApplyConfiguration { + b.LLM = value + return b +} + +// WithMultiPool sets the MultiPool field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MultiPool field is set to the value of the last call. +func (b *AIUpstreamApplyConfiguration) WithMultiPool(value *MultiPoolConfigApplyConfiguration) *AIUpstreamApplyConfiguration { + b.MultiPool = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/anthropicconfig.go b/api/applyconfiguration/api/v1alpha1/anthropicconfig.go new file mode 100644 index 00000000000..366048121d0 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/anthropicconfig.go @@ -0,0 +1,50 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// AnthropicConfigApplyConfiguration represents a declarative configuration of the AnthropicConfig type for use +// with apply. +type AnthropicConfigApplyConfiguration struct { + AuthToken *SingleAuthTokenApplyConfiguration `json:"authToken,omitempty"` + CustomHost *HostApplyConfiguration `json:"customHost,omitempty"` + Version *string `json:"apiVersion,omitempty"` + Model *string `json:"model,omitempty"` +} + +// AnthropicConfigApplyConfiguration constructs a declarative configuration of the AnthropicConfig type for use with +// apply. +func AnthropicConfig() *AnthropicConfigApplyConfiguration { + return &AnthropicConfigApplyConfiguration{} +} + +// WithAuthToken sets the AuthToken field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthToken field is set to the value of the last call. +func (b *AnthropicConfigApplyConfiguration) WithAuthToken(value *SingleAuthTokenApplyConfiguration) *AnthropicConfigApplyConfiguration { + b.AuthToken = value + return b +} + +// WithCustomHost sets the CustomHost field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CustomHost field is set to the value of the last call. +func (b *AnthropicConfigApplyConfiguration) WithCustomHost(value *HostApplyConfiguration) *AnthropicConfigApplyConfiguration { + b.CustomHost = value + return b +} + +// WithVersion sets the Version field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Version field is set to the value of the last call. +func (b *AnthropicConfigApplyConfiguration) WithVersion(value string) *AnthropicConfigApplyConfiguration { + b.Version = &value + return b +} + +// WithModel sets the Model field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Model field is set to the value of the last call. +func (b *AnthropicConfigApplyConfiguration) WithModel(value string) *AnthropicConfigApplyConfiguration { + b.Model = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/azureopenaiconfig.go b/api/applyconfiguration/api/v1alpha1/azureopenaiconfig.go new file mode 100644 index 00000000000..abc13356911 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/azureopenaiconfig.go @@ -0,0 +1,50 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// AzureOpenAIConfigApplyConfiguration represents a declarative configuration of the AzureOpenAIConfig type for use +// with apply. +type AzureOpenAIConfigApplyConfiguration struct { + AuthToken *SingleAuthTokenApplyConfiguration `json:"authToken,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + DeploymentName *string `json:"deploymentName,omitempty"` + ApiVersion *string `json:"apiVersion,omitempty"` +} + +// AzureOpenAIConfigApplyConfiguration constructs a declarative configuration of the AzureOpenAIConfig type for use with +// apply. +func AzureOpenAIConfig() *AzureOpenAIConfigApplyConfiguration { + return &AzureOpenAIConfigApplyConfiguration{} +} + +// WithAuthToken sets the AuthToken field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthToken field is set to the value of the last call. +func (b *AzureOpenAIConfigApplyConfiguration) WithAuthToken(value *SingleAuthTokenApplyConfiguration) *AzureOpenAIConfigApplyConfiguration { + b.AuthToken = value + return b +} + +// WithEndpoint sets the Endpoint field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Endpoint field is set to the value of the last call. +func (b *AzureOpenAIConfigApplyConfiguration) WithEndpoint(value string) *AzureOpenAIConfigApplyConfiguration { + b.Endpoint = &value + return b +} + +// WithDeploymentName sets the DeploymentName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeploymentName field is set to the value of the last call. +func (b *AzureOpenAIConfigApplyConfiguration) WithDeploymentName(value string) *AzureOpenAIConfigApplyConfiguration { + b.DeploymentName = &value + return b +} + +// WithApiVersion sets the ApiVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ApiVersion field is set to the value of the last call. +func (b *AzureOpenAIConfigApplyConfiguration) WithApiVersion(value string) *AzureOpenAIConfigApplyConfiguration { + b.ApiVersion = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/customresponse.go b/api/applyconfiguration/api/v1alpha1/customresponse.go new file mode 100644 index 00000000000..c6c2798ff50 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/customresponse.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// CustomResponseApplyConfiguration represents a declarative configuration of the CustomResponse type for use +// with apply. +type CustomResponseApplyConfiguration struct { + Message *string `json:"message,omitempty"` + StatusCode *uint32 `json:"statusCode,omitempty"` +} + +// CustomResponseApplyConfiguration constructs a declarative configuration of the CustomResponse type for use with +// apply. +func CustomResponse() *CustomResponseApplyConfiguration { + return &CustomResponseApplyConfiguration{} +} + +// WithMessage sets the Message field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Message field is set to the value of the last call. +func (b *CustomResponseApplyConfiguration) WithMessage(value string) *CustomResponseApplyConfiguration { + b.Message = &value + return b +} + +// WithStatusCode sets the StatusCode field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the StatusCode field is set to the value of the last call. +func (b *CustomResponseApplyConfiguration) WithStatusCode(value uint32) *CustomResponseApplyConfiguration { + b.StatusCode = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/fielddefault.go b/api/applyconfiguration/api/v1alpha1/fielddefault.go new file mode 100644 index 00000000000..ad65a5df879 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/fielddefault.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// FieldDefaultApplyConfiguration represents a declarative configuration of the FieldDefault type for use +// with apply. +type FieldDefaultApplyConfiguration struct { + Field *string `json:"field,omitempty"` + Value *string `json:"value,omitempty"` + Override *bool `json:"override,omitempty"` +} + +// FieldDefaultApplyConfiguration constructs a declarative configuration of the FieldDefault type for use with +// apply. +func FieldDefault() *FieldDefaultApplyConfiguration { + return &FieldDefaultApplyConfiguration{} +} + +// WithField sets the Field field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Field field is set to the value of the last call. +func (b *FieldDefaultApplyConfiguration) WithField(value string) *FieldDefaultApplyConfiguration { + b.Field = &value + return b +} + +// WithValue sets the Value field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Value field is set to the value of the last call. +func (b *FieldDefaultApplyConfiguration) WithValue(value string) *FieldDefaultApplyConfiguration { + b.Value = &value + return b +} + +// WithOverride sets the Override field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Override field is set to the value of the last call. +func (b *FieldDefaultApplyConfiguration) WithOverride(value bool) *FieldDefaultApplyConfiguration { + b.Override = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/geminiconfig.go b/api/applyconfiguration/api/v1alpha1/geminiconfig.go new file mode 100644 index 00000000000..d154d05c651 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/geminiconfig.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// GeminiConfigApplyConfiguration represents a declarative configuration of the GeminiConfig type for use +// with apply. +type GeminiConfigApplyConfiguration struct { + AuthToken *SingleAuthTokenApplyConfiguration `json:"authToken,omitempty"` + Model *string `json:"model,omitempty"` + ApiVersion *string `json:"apiVersion,omitempty"` +} + +// GeminiConfigApplyConfiguration constructs a declarative configuration of the GeminiConfig type for use with +// apply. +func GeminiConfig() *GeminiConfigApplyConfiguration { + return &GeminiConfigApplyConfiguration{} +} + +// WithAuthToken sets the AuthToken field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthToken field is set to the value of the last call. +func (b *GeminiConfigApplyConfiguration) WithAuthToken(value *SingleAuthTokenApplyConfiguration) *GeminiConfigApplyConfiguration { + b.AuthToken = value + return b +} + +// WithModel sets the Model field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Model field is set to the value of the last call. +func (b *GeminiConfigApplyConfiguration) WithModel(value string) *GeminiConfigApplyConfiguration { + b.Model = &value + return b +} + +// WithApiVersion sets the ApiVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ApiVersion field is set to the value of the last call. +func (b *GeminiConfigApplyConfiguration) WithApiVersion(value string) *GeminiConfigApplyConfiguration { + b.ApiVersion = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/llmbackend.go b/api/applyconfiguration/api/v1alpha1/llmbackend.go new file mode 100644 index 00000000000..c5961d1c4c8 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/llmbackend.go @@ -0,0 +1,72 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// LLMBackendApplyConfiguration represents a declarative configuration of the LLMBackend type for use +// with apply. +type LLMBackendApplyConfiguration struct { + LLMProvidersApplyConfiguration `json:",inline"` + MultiPool *MultiPoolConfigApplyConfiguration `json:"multipool,omitempty"` +} + +// LLMBackendApplyConfiguration constructs a declarative configuration of the LLMBackend type for use with +// apply. +func LLMBackend() *LLMBackendApplyConfiguration { + return &LLMBackendApplyConfiguration{} +} + +// WithOpenAI sets the OpenAI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the OpenAI field is set to the value of the last call. +func (b *LLMBackendApplyConfiguration) WithOpenAI(value *OpenAIConfigApplyConfiguration) *LLMBackendApplyConfiguration { + b.OpenAI = value + return b +} + +// WithAzureOpenAI sets the AzureOpenAI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AzureOpenAI field is set to the value of the last call. +func (b *LLMBackendApplyConfiguration) WithAzureOpenAI(value *AzureOpenAIConfigApplyConfiguration) *LLMBackendApplyConfiguration { + b.AzureOpenAI = value + return b +} + +// WithAnthropic sets the Anthropic field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Anthropic field is set to the value of the last call. +func (b *LLMBackendApplyConfiguration) WithAnthropic(value *AnthropicConfigApplyConfiguration) *LLMBackendApplyConfiguration { + b.Anthropic = value + return b +} + +// WithGemini sets the Gemini field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Gemini field is set to the value of the last call. +func (b *LLMBackendApplyConfiguration) WithGemini(value *GeminiConfigApplyConfiguration) *LLMBackendApplyConfiguration { + b.Gemini = value + return b +} + +// WithVertexAI sets the VertexAI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the VertexAI field is set to the value of the last call. +func (b *LLMBackendApplyConfiguration) WithVertexAI(value *VertexAIConfigApplyConfiguration) *LLMBackendApplyConfiguration { + b.VertexAI = value + return b +} + +// WithMistral sets the Mistral field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Mistral field is set to the value of the last call. +func (b *LLMBackendApplyConfiguration) WithMistral(value *MistralConfigApplyConfiguration) *LLMBackendApplyConfiguration { + b.Mistral = value + return b +} + +// WithMultiPool sets the MultiPool field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MultiPool field is set to the value of the last call. +func (b *LLMBackendApplyConfiguration) WithMultiPool(value *MultiPoolConfigApplyConfiguration) *LLMBackendApplyConfiguration { + b.MultiPool = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/llmproviders.go b/api/applyconfiguration/api/v1alpha1/llmproviders.go new file mode 100644 index 00000000000..f561850ba69 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/llmproviders.go @@ -0,0 +1,68 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// LLMProvidersApplyConfiguration represents a declarative configuration of the LLMProviders type for use +// with apply. +type LLMProvidersApplyConfiguration struct { + OpenAI *OpenAIConfigApplyConfiguration `json:"openai,omitempty"` + AzureOpenAI *AzureOpenAIConfigApplyConfiguration `json:"azureopenai,omitempty"` + Anthropic *AnthropicConfigApplyConfiguration `json:"anthropic,omitempty"` + Gemini *GeminiConfigApplyConfiguration `json:"gemini,omitempty"` + VertexAI *VertexAIConfigApplyConfiguration `json:"vertexai,omitempty"` + Mistral *MistralConfigApplyConfiguration `json:"mistral,omitempty"` +} + +// LLMProvidersApplyConfiguration constructs a declarative configuration of the LLMProviders type for use with +// apply. +func LLMProviders() *LLMProvidersApplyConfiguration { + return &LLMProvidersApplyConfiguration{} +} + +// WithOpenAI sets the OpenAI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the OpenAI field is set to the value of the last call. +func (b *LLMProvidersApplyConfiguration) WithOpenAI(value *OpenAIConfigApplyConfiguration) *LLMProvidersApplyConfiguration { + b.OpenAI = value + return b +} + +// WithAzureOpenAI sets the AzureOpenAI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AzureOpenAI field is set to the value of the last call. +func (b *LLMProvidersApplyConfiguration) WithAzureOpenAI(value *AzureOpenAIConfigApplyConfiguration) *LLMProvidersApplyConfiguration { + b.AzureOpenAI = value + return b +} + +// WithAnthropic sets the Anthropic field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Anthropic field is set to the value of the last call. +func (b *LLMProvidersApplyConfiguration) WithAnthropic(value *AnthropicConfigApplyConfiguration) *LLMProvidersApplyConfiguration { + b.Anthropic = value + return b +} + +// WithGemini sets the Gemini field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Gemini field is set to the value of the last call. +func (b *LLMProvidersApplyConfiguration) WithGemini(value *GeminiConfigApplyConfiguration) *LLMProvidersApplyConfiguration { + b.Gemini = value + return b +} + +// WithVertexAI sets the VertexAI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the VertexAI field is set to the value of the last call. +func (b *LLMProvidersApplyConfiguration) WithVertexAI(value *VertexAIConfigApplyConfiguration) *LLMProvidersApplyConfiguration { + b.VertexAI = value + return b +} + +// WithMistral sets the Mistral field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Mistral field is set to the value of the last call. +func (b *LLMProvidersApplyConfiguration) WithMistral(value *MistralConfigApplyConfiguration) *LLMProvidersApplyConfiguration { + b.Mistral = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/message.go b/api/applyconfiguration/api/v1alpha1/message.go new file mode 100644 index 00000000000..a8f58a6090e --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/message.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// MessageApplyConfiguration represents a declarative configuration of the Message type for use +// with apply. +type MessageApplyConfiguration struct { + Role *string `json:"role,omitempty"` + Content *string `json:"content,omitempty"` +} + +// MessageApplyConfiguration constructs a declarative configuration of the Message type for use with +// apply. +func Message() *MessageApplyConfiguration { + return &MessageApplyConfiguration{} +} + +// WithRole sets the Role field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Role field is set to the value of the last call. +func (b *MessageApplyConfiguration) WithRole(value string) *MessageApplyConfiguration { + b.Role = &value + return b +} + +// WithContent sets the Content field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Content field is set to the value of the last call. +func (b *MessageApplyConfiguration) WithContent(value string) *MessageApplyConfiguration { + b.Content = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/mistralconfig.go b/api/applyconfiguration/api/v1alpha1/mistralconfig.go new file mode 100644 index 00000000000..37015f44454 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/mistralconfig.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// MistralConfigApplyConfiguration represents a declarative configuration of the MistralConfig type for use +// with apply. +type MistralConfigApplyConfiguration struct { + AuthToken *SingleAuthTokenApplyConfiguration `json:"authToken,omitempty"` + CustomHost *HostApplyConfiguration `json:"customHost,omitempty"` + Model *string `json:"model,omitempty"` +} + +// MistralConfigApplyConfiguration constructs a declarative configuration of the MistralConfig type for use with +// apply. +func MistralConfig() *MistralConfigApplyConfiguration { + return &MistralConfigApplyConfiguration{} +} + +// WithAuthToken sets the AuthToken field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthToken field is set to the value of the last call. +func (b *MistralConfigApplyConfiguration) WithAuthToken(value *SingleAuthTokenApplyConfiguration) *MistralConfigApplyConfiguration { + b.AuthToken = value + return b +} + +// WithCustomHost sets the CustomHost field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CustomHost field is set to the value of the last call. +func (b *MistralConfigApplyConfiguration) WithCustomHost(value *HostApplyConfiguration) *MistralConfigApplyConfiguration { + b.CustomHost = value + return b +} + +// WithModel sets the Model field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Model field is set to the value of the last call. +func (b *MistralConfigApplyConfiguration) WithModel(value string) *MistralConfigApplyConfiguration { + b.Model = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/moderation.go b/api/applyconfiguration/api/v1alpha1/moderation.go new file mode 100644 index 00000000000..972d5c29f93 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/moderation.go @@ -0,0 +1,23 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// ModerationApplyConfiguration represents a declarative configuration of the Moderation type for use +// with apply. +type ModerationApplyConfiguration struct { + OpenAIModeration *OpenAIModerationApplyConfiguration `json:"openAIModeration,omitempty"` +} + +// ModerationApplyConfiguration constructs a declarative configuration of the Moderation type for use with +// apply. +func Moderation() *ModerationApplyConfiguration { + return &ModerationApplyConfiguration{} +} + +// WithOpenAIModeration sets the OpenAIModeration field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the OpenAIModeration field is set to the value of the last call. +func (b *ModerationApplyConfiguration) WithOpenAIModeration(value *OpenAIModerationApplyConfiguration) *ModerationApplyConfiguration { + b.OpenAIModeration = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/multipoolconfig.go b/api/applyconfiguration/api/v1alpha1/multipoolconfig.go new file mode 100644 index 00000000000..f81f1aecc30 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/multipoolconfig.go @@ -0,0 +1,28 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// MultiPoolConfigApplyConfiguration represents a declarative configuration of the MultiPoolConfig type for use +// with apply. +type MultiPoolConfigApplyConfiguration struct { + Priorities []PriorityApplyConfiguration `json:"priorities,omitempty"` +} + +// MultiPoolConfigApplyConfiguration constructs a declarative configuration of the MultiPoolConfig type for use with +// apply. +func MultiPoolConfig() *MultiPoolConfigApplyConfiguration { + return &MultiPoolConfigApplyConfiguration{} +} + +// WithPriorities adds the given value to the Priorities field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Priorities field. +func (b *MultiPoolConfigApplyConfiguration) WithPriorities(values ...*PriorityApplyConfiguration) *MultiPoolConfigApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithPriorities") + } + b.Priorities = append(b.Priorities, *values[i]) + } + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/openaiconfig.go b/api/applyconfiguration/api/v1alpha1/openaiconfig.go new file mode 100644 index 00000000000..894d83c2863 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/openaiconfig.go @@ -0,0 +1,41 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// OpenAIConfigApplyConfiguration represents a declarative configuration of the OpenAIConfig type for use +// with apply. +type OpenAIConfigApplyConfiguration struct { + AuthToken *SingleAuthTokenApplyConfiguration `json:"authToken,omitempty"` + CustomHost *HostApplyConfiguration `json:"customHost,omitempty"` + Model *string `json:"model,omitempty"` +} + +// OpenAIConfigApplyConfiguration constructs a declarative configuration of the OpenAIConfig type for use with +// apply. +func OpenAIConfig() *OpenAIConfigApplyConfiguration { + return &OpenAIConfigApplyConfiguration{} +} + +// WithAuthToken sets the AuthToken field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthToken field is set to the value of the last call. +func (b *OpenAIConfigApplyConfiguration) WithAuthToken(value *SingleAuthTokenApplyConfiguration) *OpenAIConfigApplyConfiguration { + b.AuthToken = value + return b +} + +// WithCustomHost sets the CustomHost field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CustomHost field is set to the value of the last call. +func (b *OpenAIConfigApplyConfiguration) WithCustomHost(value *HostApplyConfiguration) *OpenAIConfigApplyConfiguration { + b.CustomHost = value + return b +} + +// WithModel sets the Model field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Model field is set to the value of the last call. +func (b *OpenAIConfigApplyConfiguration) WithModel(value string) *OpenAIConfigApplyConfiguration { + b.Model = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/openaimoderation.go b/api/applyconfiguration/api/v1alpha1/openaimoderation.go new file mode 100644 index 00000000000..a7492c98374 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/openaimoderation.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// OpenAIModerationApplyConfiguration represents a declarative configuration of the OpenAIModeration type for use +// with apply. +type OpenAIModerationApplyConfiguration struct { + Model *string `json:"model,omitempty"` + AuthToken *SingleAuthTokenApplyConfiguration `json:"authToken,omitempty"` +} + +// OpenAIModerationApplyConfiguration constructs a declarative configuration of the OpenAIModeration type for use with +// apply. +func OpenAIModeration() *OpenAIModerationApplyConfiguration { + return &OpenAIModerationApplyConfiguration{} +} + +// WithModel sets the Model field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Model field is set to the value of the last call. +func (b *OpenAIModerationApplyConfiguration) WithModel(value string) *OpenAIModerationApplyConfiguration { + b.Model = &value + return b +} + +// WithAuthToken sets the AuthToken field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthToken field is set to the value of the last call. +func (b *OpenAIModerationApplyConfiguration) WithAuthToken(value *SingleAuthTokenApplyConfiguration) *OpenAIModerationApplyConfiguration { + b.AuthToken = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/priority.go b/api/applyconfiguration/api/v1alpha1/priority.go new file mode 100644 index 00000000000..fedbfff65e6 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/priority.go @@ -0,0 +1,28 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// PriorityApplyConfiguration represents a declarative configuration of the Priority type for use +// with apply. +type PriorityApplyConfiguration struct { + Pool []LLMProvidersApplyConfiguration `json:"pool,omitempty"` +} + +// PriorityApplyConfiguration constructs a declarative configuration of the Priority type for use with +// apply. +func Priority() *PriorityApplyConfiguration { + return &PriorityApplyConfiguration{} +} + +// WithPool adds the given value to the Pool field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Pool field. +func (b *PriorityApplyConfiguration) WithPool(values ...*LLMProvidersApplyConfiguration) *PriorityApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithPool") + } + b.Pool = append(b.Pool, *values[i]) + } + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/promptguardrequest.go b/api/applyconfiguration/api/v1alpha1/promptguardrequest.go new file mode 100644 index 00000000000..d40b89c58da --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/promptguardrequest.go @@ -0,0 +1,50 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// PromptguardRequestApplyConfiguration represents a declarative configuration of the PromptguardRequest type for use +// with apply. +type PromptguardRequestApplyConfiguration struct { + CustomResponse *CustomResponseApplyConfiguration `json:"customResponse,omitempty"` + Regex *RegexApplyConfiguration `json:"regex,omitempty"` + Webhook *WebhookApplyConfiguration `json:"webhook,omitempty"` + Moderation *ModerationApplyConfiguration `json:"moderation,omitempty"` +} + +// PromptguardRequestApplyConfiguration constructs a declarative configuration of the PromptguardRequest type for use with +// apply. +func PromptguardRequest() *PromptguardRequestApplyConfiguration { + return &PromptguardRequestApplyConfiguration{} +} + +// WithCustomResponse sets the CustomResponse field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CustomResponse field is set to the value of the last call. +func (b *PromptguardRequestApplyConfiguration) WithCustomResponse(value *CustomResponseApplyConfiguration) *PromptguardRequestApplyConfiguration { + b.CustomResponse = value + return b +} + +// WithRegex sets the Regex field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Regex field is set to the value of the last call. +func (b *PromptguardRequestApplyConfiguration) WithRegex(value *RegexApplyConfiguration) *PromptguardRequestApplyConfiguration { + b.Regex = value + return b +} + +// WithWebhook sets the Webhook field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Webhook field is set to the value of the last call. +func (b *PromptguardRequestApplyConfiguration) WithWebhook(value *WebhookApplyConfiguration) *PromptguardRequestApplyConfiguration { + b.Webhook = value + return b +} + +// WithModeration sets the Moderation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Moderation field is set to the value of the last call. +func (b *PromptguardRequestApplyConfiguration) WithModeration(value *ModerationApplyConfiguration) *PromptguardRequestApplyConfiguration { + b.Moderation = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/promptguardresponse.go b/api/applyconfiguration/api/v1alpha1/promptguardresponse.go new file mode 100644 index 00000000000..b5072974ac8 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/promptguardresponse.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// PromptguardResponseApplyConfiguration represents a declarative configuration of the PromptguardResponse type for use +// with apply. +type PromptguardResponseApplyConfiguration struct { + Regex *RegexApplyConfiguration `json:"regex,omitempty"` + Webhook *WebhookApplyConfiguration `json:"webhook,omitempty"` +} + +// PromptguardResponseApplyConfiguration constructs a declarative configuration of the PromptguardResponse type for use with +// apply. +func PromptguardResponse() *PromptguardResponseApplyConfiguration { + return &PromptguardResponseApplyConfiguration{} +} + +// WithRegex sets the Regex field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Regex field is set to the value of the last call. +func (b *PromptguardResponseApplyConfiguration) WithRegex(value *RegexApplyConfiguration) *PromptguardResponseApplyConfiguration { + b.Regex = value + return b +} + +// WithWebhook sets the Webhook field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Webhook field is set to the value of the last call. +func (b *PromptguardResponseApplyConfiguration) WithWebhook(value *WebhookApplyConfiguration) *PromptguardResponseApplyConfiguration { + b.Webhook = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/regex.go b/api/applyconfiguration/api/v1alpha1/regex.go new file mode 100644 index 00000000000..81c1b493197 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/regex.go @@ -0,0 +1,52 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/kgateway-dev/kgateway/v2/api/v1alpha1" +) + +// RegexApplyConfiguration represents a declarative configuration of the Regex type for use +// with apply. +type RegexApplyConfiguration struct { + Matches []RegexMatchApplyConfiguration `json:"matches,omitempty"` + Builtins []apiv1alpha1.BuiltIn `json:"builtins,omitempty"` + Action *apiv1alpha1.Action `json:"action,omitempty"` +} + +// RegexApplyConfiguration constructs a declarative configuration of the Regex type for use with +// apply. +func Regex() *RegexApplyConfiguration { + return &RegexApplyConfiguration{} +} + +// WithMatches adds the given value to the Matches field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Matches field. +func (b *RegexApplyConfiguration) WithMatches(values ...*RegexMatchApplyConfiguration) *RegexApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithMatches") + } + b.Matches = append(b.Matches, *values[i]) + } + return b +} + +// WithBuiltins adds the given value to the Builtins field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Builtins field. +func (b *RegexApplyConfiguration) WithBuiltins(values ...apiv1alpha1.BuiltIn) *RegexApplyConfiguration { + for i := range values { + b.Builtins = append(b.Builtins, values[i]) + } + return b +} + +// WithAction sets the Action field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Action field is set to the value of the last call. +func (b *RegexApplyConfiguration) WithAction(value apiv1alpha1.Action) *RegexApplyConfiguration { + b.Action = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/regexmatch.go b/api/applyconfiguration/api/v1alpha1/regexmatch.go new file mode 100644 index 00000000000..25a05eedeaa --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/regexmatch.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// RegexMatchApplyConfiguration represents a declarative configuration of the RegexMatch type for use +// with apply. +type RegexMatchApplyConfiguration struct { + Pattern *string `json:"pattern,omitempty"` + Name *string `json:"name,omitempty"` +} + +// RegexMatchApplyConfiguration constructs a declarative configuration of the RegexMatch type for use with +// apply. +func RegexMatch() *RegexMatchApplyConfiguration { + return &RegexMatchApplyConfiguration{} +} + +// WithPattern sets the Pattern field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Pattern field is set to the value of the last call. +func (b *RegexMatchApplyConfiguration) WithPattern(value string) *RegexMatchApplyConfiguration { + b.Pattern = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *RegexMatchApplyConfiguration) WithName(value string) *RegexMatchApplyConfiguration { + b.Name = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/routepolicyspec.go b/api/applyconfiguration/api/v1alpha1/routepolicyspec.go index 62cff93328a..7b4928183d9 100644 --- a/api/applyconfiguration/api/v1alpha1/routepolicyspec.go +++ b/api/applyconfiguration/api/v1alpha1/routepolicyspec.go @@ -7,6 +7,7 @@ package v1alpha1 type RoutePolicySpecApplyConfiguration struct { TargetRef *LocalPolicyTargetReferenceApplyConfiguration `json:"targetRef,omitempty"` Timeout *int `json:"timeout,omitempty"` + AI *AIRoutePolicyApplyConfiguration `json:"ai,omitempty"` } // RoutePolicySpecApplyConfiguration constructs a declarative configuration of the RoutePolicySpec type for use with @@ -30,3 +31,11 @@ func (b *RoutePolicySpecApplyConfiguration) WithTimeout(value int) *RoutePolicyS b.Timeout = &value return b } + +// WithAI sets the AI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AI field is set to the value of the last call. +func (b *RoutePolicySpecApplyConfiguration) WithAI(value *AIRoutePolicyApplyConfiguration) *RoutePolicySpecApplyConfiguration { + b.AI = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/singleauthtoken.go b/api/applyconfiguration/api/v1alpha1/singleauthtoken.go new file mode 100644 index 00000000000..9348ebd0c27 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/singleauthtoken.go @@ -0,0 +1,47 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + + v1alpha1 "github.com/kgateway-dev/kgateway/v2/api/v1alpha1" +) + +// SingleAuthTokenApplyConfiguration represents a declarative configuration of the SingleAuthToken type for use +// with apply. +type SingleAuthTokenApplyConfiguration struct { + Kind *v1alpha1.SingleAuthTokenKind `json:"kind,omitempty"` + Inline *string `json:"inline,omitempty"` + SecretRef *v1.LocalObjectReference `json:"secretRef,omitempty"` +} + +// SingleAuthTokenApplyConfiguration constructs a declarative configuration of the SingleAuthToken type for use with +// apply. +func SingleAuthToken() *SingleAuthTokenApplyConfiguration { + return &SingleAuthTokenApplyConfiguration{} +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *SingleAuthTokenApplyConfiguration) WithKind(value v1alpha1.SingleAuthTokenKind) *SingleAuthTokenApplyConfiguration { + b.Kind = &value + return b +} + +// WithInline sets the Inline field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Inline field is set to the value of the last call. +func (b *SingleAuthTokenApplyConfiguration) WithInline(value string) *SingleAuthTokenApplyConfiguration { + b.Inline = &value + return b +} + +// WithSecretRef sets the SecretRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SecretRef field is set to the value of the last call. +func (b *SingleAuthTokenApplyConfiguration) WithSecretRef(value v1.LocalObjectReference) *SingleAuthTokenApplyConfiguration { + b.SecretRef = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/upstreamspec.go b/api/applyconfiguration/api/v1alpha1/upstreamspec.go index 493c613a61e..2819909f341 100644 --- a/api/applyconfiguration/api/v1alpha1/upstreamspec.go +++ b/api/applyconfiguration/api/v1alpha1/upstreamspec.go @@ -7,6 +7,7 @@ package v1alpha1 type UpstreamSpecApplyConfiguration struct { Aws *AwsUpstreamApplyConfiguration `json:"aws,omitempty"` Static *StaticUpstreamApplyConfiguration `json:"static,omitempty"` + AI *AIUpstreamApplyConfiguration `json:"ai,omitempty"` } // UpstreamSpecApplyConfiguration constructs a declarative configuration of the UpstreamSpec type for use with @@ -30,3 +31,11 @@ func (b *UpstreamSpecApplyConfiguration) WithStatic(value *StaticUpstreamApplyCo b.Static = value return b } + +// WithAI sets the AI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AI field is set to the value of the last call. +func (b *UpstreamSpecApplyConfiguration) WithAI(value *AIUpstreamApplyConfiguration) *UpstreamSpecApplyConfiguration { + b.AI = value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/vertexaiconfig.go b/api/applyconfiguration/api/v1alpha1/vertexaiconfig.go new file mode 100644 index 00000000000..465111cfb62 --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/vertexaiconfig.go @@ -0,0 +1,81 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + apiv1alpha1 "github.com/kgateway-dev/kgateway/v2/api/v1alpha1" +) + +// VertexAIConfigApplyConfiguration represents a declarative configuration of the VertexAIConfig type for use +// with apply. +type VertexAIConfigApplyConfiguration struct { + AuthToken *SingleAuthTokenApplyConfiguration `json:"authToken,omitempty"` + Model *string `json:"model,omitempty"` + ApiVersion *string `json:"apiVersion,omitempty"` + ProjectId *string `json:"projectId,omitempty"` + Location *string `json:"location,omitempty"` + ModelPath *string `json:"modelPath,omitempty"` + Publisher *apiv1alpha1.Publisher `json:"publisher,omitempty"` +} + +// VertexAIConfigApplyConfiguration constructs a declarative configuration of the VertexAIConfig type for use with +// apply. +func VertexAIConfig() *VertexAIConfigApplyConfiguration { + return &VertexAIConfigApplyConfiguration{} +} + +// WithAuthToken sets the AuthToken field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthToken field is set to the value of the last call. +func (b *VertexAIConfigApplyConfiguration) WithAuthToken(value *SingleAuthTokenApplyConfiguration) *VertexAIConfigApplyConfiguration { + b.AuthToken = value + return b +} + +// WithModel sets the Model field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Model field is set to the value of the last call. +func (b *VertexAIConfigApplyConfiguration) WithModel(value string) *VertexAIConfigApplyConfiguration { + b.Model = &value + return b +} + +// WithApiVersion sets the ApiVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ApiVersion field is set to the value of the last call. +func (b *VertexAIConfigApplyConfiguration) WithApiVersion(value string) *VertexAIConfigApplyConfiguration { + b.ApiVersion = &value + return b +} + +// WithProjectId sets the ProjectId field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProjectId field is set to the value of the last call. +func (b *VertexAIConfigApplyConfiguration) WithProjectId(value string) *VertexAIConfigApplyConfiguration { + b.ProjectId = &value + return b +} + +// WithLocation sets the Location field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Location field is set to the value of the last call. +func (b *VertexAIConfigApplyConfiguration) WithLocation(value string) *VertexAIConfigApplyConfiguration { + b.Location = &value + return b +} + +// WithModelPath sets the ModelPath field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ModelPath field is set to the value of the last call. +func (b *VertexAIConfigApplyConfiguration) WithModelPath(value string) *VertexAIConfigApplyConfiguration { + b.ModelPath = &value + return b +} + +// WithPublisher sets the Publisher field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Publisher field is set to the value of the last call. +func (b *VertexAIConfigApplyConfiguration) WithPublisher(value apiv1alpha1.Publisher) *VertexAIConfigApplyConfiguration { + b.Publisher = &value + return b +} diff --git a/api/applyconfiguration/api/v1alpha1/webhook.go b/api/applyconfiguration/api/v1alpha1/webhook.go new file mode 100644 index 00000000000..0c703af63ac --- /dev/null +++ b/api/applyconfiguration/api/v1alpha1/webhook.go @@ -0,0 +1,38 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "sigs.k8s.io/gateway-api/apis/v1" +) + +// WebhookApplyConfiguration represents a declarative configuration of the Webhook type for use +// with apply. +type WebhookApplyConfiguration struct { + Host *HostApplyConfiguration `json:"host,omitempty"` + ForwardHeaders []v1.HTTPHeaderMatch `json:"forwardHeaders,omitempty"` +} + +// WebhookApplyConfiguration constructs a declarative configuration of the Webhook type for use with +// apply. +func Webhook() *WebhookApplyConfiguration { + return &WebhookApplyConfiguration{} +} + +// WithHost sets the Host field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Host field is set to the value of the last call. +func (b *WebhookApplyConfiguration) WithHost(value *HostApplyConfiguration) *WebhookApplyConfiguration { + b.Host = value + return b +} + +// WithForwardHeaders adds the given value to the ForwardHeaders field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the ForwardHeaders field. +func (b *WebhookApplyConfiguration) WithForwardHeaders(values ...v1.HTTPHeaderMatch) *WebhookApplyConfiguration { + for i := range values { + b.ForwardHeaders = append(b.ForwardHeaders, values[i]) + } + return b +} diff --git a/api/applyconfiguration/internal/internal.go b/api/applyconfiguration/internal/internal.go index e4656435509..308260a6aeb 100644 --- a/api/applyconfiguration/internal/internal.go +++ b/api/applyconfiguration/internal/internal.go @@ -23,6 +23,60 @@ func Parser() *typed.Parser { var parserOnce sync.Once var parser *typed.Parser var schemaYAML = typed.YAMLObject(`types: +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIPromptEnrichment + map: + fields: + - name: append + type: + list: + elementType: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Message + elementRelationship: atomic + - name: prepend + type: + list: + elementType: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Message + elementRelationship: atomic +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIPromptGuard + map: + fields: + - name: request + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.PromptguardRequest + - name: response + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.PromptguardResponse +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIRoutePolicy + map: + fields: + - name: defaults + type: + list: + elementType: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.FieldDefault + elementRelationship: atomic + - name: promptEnrichment + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIPromptEnrichment + - name: promptGuard + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIPromptGuard + - name: routeType + type: + scalar: string +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIUpstream + map: + fields: + - name: customHost + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Host + - name: llm + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.LLMProviders + - name: multipool + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.MultiPoolConfig - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AccessLog map: fields: @@ -113,6 +167,21 @@ var schemaYAML = typed.YAMLObject(`types: elementType: namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.CustomLabel elementRelationship: atomic +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AnthropicConfig + map: + fields: + - name: apiVersion + type: + scalar: string + - name: authToken + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + - name: customHost + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Host + - name: model + type: + scalar: string - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AwsUpstream map: fields: @@ -123,6 +192,24 @@ var schemaYAML = typed.YAMLObject(`types: type: namedType: io.k8s.api.core.v1.LocalObjectReference default: {} +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AzureOpenAIConfig + map: + fields: + - name: apiVersion + type: + scalar: string + default: "" + - name: authToken + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + - name: deploymentName + type: + scalar: string + default: "" + - name: endpoint + type: + scalar: string + default: "" - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.CELFilter map: fields: @@ -147,6 +234,15 @@ var schemaYAML = typed.YAMLObject(`types: type: scalar: string default: "" +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.CustomResponse + map: + fields: + - name: message + type: + scalar: string + - name: statusCode + type: + scalar: numeric - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.DirectResponse map: fields: @@ -225,6 +321,18 @@ var schemaYAML = typed.YAMLObject(`types: - name: securityContext type: namedType: io.k8s.api.core.v1.SecurityContext +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.FieldDefault + map: + fields: + - name: field + type: + scalar: string + - name: override + type: + scalar: boolean + - name: value + type: + scalar: string - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.FileSink map: fields: @@ -307,6 +415,20 @@ var schemaYAML = typed.YAMLObject(`types: elementType: namedType: __untyped_deduced_ elementRelationship: separable +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.GeminiConfig + map: + fields: + - name: apiVersion + type: + scalar: string + default: "" + - name: authToken + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + - name: model + type: + scalar: string + default: "" - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.GracefulShutdownSpec map: fields: @@ -498,6 +620,27 @@ var schemaYAML = typed.YAMLObject(`types: - name: stats type: namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.StatsConfig +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.LLMProviders + map: + fields: + - name: anthropic + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AnthropicConfig + - name: azureopenai + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AzureOpenAIConfig + - name: gemini + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.GeminiConfig + - name: mistral + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.MistralConfig + - name: openai + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.OpenAIConfig + - name: vertexai + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.VertexAIConfig - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.ListenerPolicy map: fields: @@ -544,6 +687,63 @@ var schemaYAML = typed.YAMLObject(`types: type: scalar: string default: "" +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Message + map: + fields: + - name: content + type: + scalar: string + - name: role + type: + scalar: string +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.MistralConfig + map: + fields: + - name: authToken + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + - name: customHost + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Host + - name: model + type: + scalar: string +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Moderation + map: + fields: + - name: openAIModeration + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.OpenAIModeration +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.MultiPoolConfig + map: + fields: + - name: priorities + type: + list: + elementType: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Priority + elementRelationship: atomic +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.OpenAIConfig + map: + fields: + - name: authToken + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + - name: customHost + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Host + - name: model + type: + scalar: string +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.OpenAIModeration + map: + fields: + - name: authToken + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + - name: model + type: + scalar: string - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Pod map: fields: @@ -628,12 +828,72 @@ var schemaYAML = typed.YAMLObject(`types: elementRelationship: associative keys: - type +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Priority + map: + fields: + - name: pool + type: + list: + elementType: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.LLMProviders + elementRelationship: atomic +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.PromptguardRequest + map: + fields: + - name: customResponse + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.CustomResponse + - name: moderation + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Moderation + - name: regex + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Regex + - name: webhook + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Webhook +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.PromptguardResponse + map: + fields: + - name: regex + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Regex + - name: webhook + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Webhook - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.ProxyDeployment map: fields: - name: replicas type: scalar: numeric +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Regex + map: + fields: + - name: action + type: + scalar: string + - name: builtins + type: + list: + elementType: + scalar: string + elementRelationship: atomic + - name: matches + type: + list: + elementType: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.RegexMatch + elementRelationship: atomic +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.RegexMatch + map: + fields: + - name: name + type: + scalar: string + - name: pattern + type: + scalar: string - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.ResponseFlagFilter map: fields: @@ -667,6 +927,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.RoutePolicySpec map: fields: + - name: ai + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIRoutePolicy - name: targetRef type: namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.LocalPolicyTargetReference @@ -739,6 +1002,19 @@ var schemaYAML = typed.YAMLObject(`types: map: elementType: scalar: string +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + map: + fields: + - name: inline + type: + scalar: string + - name: kind + type: + scalar: string + default: "" + - name: secretRef + type: + namedType: io.k8s.api.core.v1.LocalObjectReference - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.StaticUpstream map: fields: @@ -796,6 +1072,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.UpstreamSpec map: fields: + - name: ai + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AIUpstream - name: aws type: namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.AwsUpstream @@ -813,6 +1092,46 @@ var schemaYAML = typed.YAMLObject(`types: elementRelationship: associative keys: - type +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.VertexAIConfig + map: + fields: + - name: apiVersion + type: + scalar: string + default: "" + - name: authToken + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.SingleAuthToken + - name: location + type: + scalar: string + default: "" + - name: model + type: + scalar: string + default: "" + - name: modelPath + type: + scalar: string + - name: projectId + type: + scalar: string + default: "" + - name: publisher + type: + scalar: string +- name: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Webhook + map: + fields: + - name: forwardHeaders + type: + list: + elementType: + namedType: io.k8s.sigs.gateway-api.apis.v1.HTTPHeaderMatch + elementRelationship: atomic + - name: host + type: + namedType: com.github.kgateway-dev.kgateway.v2.api.v1alpha1.Host - name: io.k8s.api.core.v1.Affinity map: fields: diff --git a/api/applyconfiguration/utils.go b/api/applyconfiguration/utils.go index 8541082b252..9b2c86a47c6 100644 --- a/api/applyconfiguration/utils.go +++ b/api/applyconfiguration/utils.go @@ -25,12 +25,26 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.AiExtensionApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("AiExtensionStats"): return &apiv1alpha1.AiExtensionStatsApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("AIPromptEnrichment"): + return &apiv1alpha1.AIPromptEnrichmentApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("AIPromptGuard"): + return &apiv1alpha1.AIPromptGuardApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("AIRoutePolicy"): + return &apiv1alpha1.AIRoutePolicyApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("AIUpstream"): + return &apiv1alpha1.AIUpstreamApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("AnthropicConfig"): + return &apiv1alpha1.AnthropicConfigApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("AwsUpstream"): return &apiv1alpha1.AwsUpstreamApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("AzureOpenAIConfig"): + return &apiv1alpha1.AzureOpenAIConfigApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("CELFilter"): return &apiv1alpha1.CELFilterApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("CustomLabel"): return &apiv1alpha1.CustomLabelApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("CustomResponse"): + return &apiv1alpha1.CustomResponseApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("DirectResponse"): return &apiv1alpha1.DirectResponseApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("DirectResponseSpec"): @@ -41,6 +55,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.EnvoyBootstrapApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("EnvoyContainer"): return &apiv1alpha1.EnvoyContainerApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("FieldDefault"): + return &apiv1alpha1.FieldDefaultApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("FileSink"): return &apiv1alpha1.FileSinkApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("FilterType"): @@ -49,6 +65,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.GatewayParametersApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("GatewayParametersSpec"): return &apiv1alpha1.GatewayParametersSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("GeminiConfig"): + return &apiv1alpha1.GeminiConfigApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("GracefulShutdownSpec"): return &apiv1alpha1.GracefulShutdownSpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("GrpcService"): @@ -75,16 +93,40 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.ListenerPolicyApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ListenerPolicySpec"): return &apiv1alpha1.ListenerPolicySpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("LLMProviders"): + return &apiv1alpha1.LLMProvidersApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("LocalPolicyTargetReference"): return &apiv1alpha1.LocalPolicyTargetReferenceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Message"): + return &apiv1alpha1.MessageApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MistralConfig"): + return &apiv1alpha1.MistralConfigApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Moderation"): + return &apiv1alpha1.ModerationApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MultiPoolConfig"): + return &apiv1alpha1.MultiPoolConfigApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("OpenAIConfig"): + return &apiv1alpha1.OpenAIConfigApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("OpenAIModeration"): + return &apiv1alpha1.OpenAIModerationApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("Pod"): return &apiv1alpha1.PodApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("PolicyAncestorStatus"): return &apiv1alpha1.PolicyAncestorStatusApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("PolicyStatus"): return &apiv1alpha1.PolicyStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Priority"): + return &apiv1alpha1.PriorityApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PromptguardRequest"): + return &apiv1alpha1.PromptguardRequestApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("PromptguardResponse"): + return &apiv1alpha1.PromptguardResponseApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ProxyDeployment"): return &apiv1alpha1.ProxyDeploymentApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Regex"): + return &apiv1alpha1.RegexApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("RegexMatch"): + return &apiv1alpha1.RegexMatchApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ResponseFlagFilter"): return &apiv1alpha1.ResponseFlagFilterApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("RoutePolicy"): @@ -99,6 +141,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.ServiceApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("ServiceAccount"): return &apiv1alpha1.ServiceAccountApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("SingleAuthToken"): + return &apiv1alpha1.SingleAuthTokenApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("StaticUpstream"): return &apiv1alpha1.StaticUpstreamApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("StatsConfig"): @@ -111,6 +155,10 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &apiv1alpha1.UpstreamSpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("UpstreamStatus"): return &apiv1alpha1.UpstreamStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("VertexAIConfig"): + return &apiv1alpha1.VertexAIConfigApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Webhook"): + return &apiv1alpha1.WebhookApplyConfiguration{} } return nil diff --git a/api/v1alpha1/ai_policy.go b/api/v1alpha1/ai_policy.go new file mode 100644 index 00000000000..989b18b00bc --- /dev/null +++ b/api/v1alpha1/ai_policy.go @@ -0,0 +1,298 @@ +package v1alpha1 + +import ( + gwv1 "sigs.k8s.io/gateway-api/apis/v1" +) + +// AIRoutePolicy config is used to configure the behavior of the LLM provider +// on the level of individual routes. These route settings, such as prompt enrichment, +// retrieval augmented generation (RAG), and semantic caching, are applicable only +// for routes that send requests to an LLM provider backend. +type AIRoutePolicy struct { + + // Enrich requests sent to the LLM provider by appending and prepending system prompts. + // This can be configured only for LLM providers that use the `CHAT` API route type. + PromptEnrichment *AIPromptEnrichment `json:"promptEnrichment,omitempty"` + + // Set up prompt guards to block unwanted requests to the LLM provider and mask sensitive data. + // Prompt guards can be used to reject requests based on the content of the prompt, as well as + // mask responses based on the content of the response. + PromptGuard *AIPromptGuard `json:"promptGuard,omitempty"` + + // Provide defaults to merge with user input fields. + // Defaults do _not_ override the user input fields, unless you explicitly set `override` to `true`. + Defaults []FieldDefault `json:"defaults,omitempty"` + + // The type of route to the LLM provider API. Currently, `CHAT` and `CHAT_STREAMING` are supported. + // +kubebuilder:validation:Enum=CHAT;CHAT_STREAMING + // +kube:default=CHAT + RouteType RouteType `json:"routeType,omitempty"` +} + +// AIPromptEnrichment defines the config to enrich requests sent to the LLM provider by appending and prepending system prompts. +// This can be configured only for LLM providers that use the CHAT API type. +// +// Prompt enrichment allows you to add additional context to the prompt before sending it to the model. +// Unlike RAG or other dynamic context methods, prompt enrichment is static and is applied to every request. +// +// **Note**: Some providers, including Anthropic, do not support SYSTEM role messages, and instead have a dedicated +// system field in the input JSON. In this case, use the [`defaults` setting](#fielddefault) to set the system field. +// +// The following example prepends a system prompt of `Answer all questions in French.` +// and appends `Describe the painting as if you were a famous art critic from the 17th century.` +// to each request that is sent to the `openai` HTTPRoute. +// ```yaml +// +// name: openai-opt +// namespace: kgateway-system +// +// spec: +// +// targetRefs: +// - group: gateway.networking.k8s.io +// kind: HTTPRoute +// name: openai +// aiRoutePolicy: +// promptEnrichment: +// prepend: +// - role: SYSTEM +// content: "Answer all questions in French." +// append: +// - role: USER +// content: "Describe the painting as if you were a famous art critic from the 17th century." +// +// ``` +type AIPromptEnrichment struct { + // A list of messages to be prepended to the prompt sent by the client. + Prepend []Message `json:"prepend,omitempty"` + // A list of messages to be appended to the prompt sent by the client. + Append []Message `json:"append,omitempty"` +} + +// RouteType is the type of route to the LLM provider API. +type RouteType string + +const ( + // The LLM generates the full response before responding to a client. + CHAT RouteType = "CHAT" + // Stream responses to a client, which allows the LLM to stream out tokens as they are generated. + CHAT_STREAMING RouteType = "CHAT_STREAMING" +) + +// An entry for a message to prepend or append to each prompt. +type Message struct { + // Role of the message. The available roles depend on the backend + // LLM provider model, such as `SYSTEM` or `USER` in the OpenAI API. + Role string `json:"role,omitempty"` + // String content of the message. + Content string `json:"content,omitempty"` +} + +// BuiltIn regex patterns for specific types of strings in prompts. +// For example, if you specify `CREDIT_CARD`, any credit card numbers +// in the request or response are matched. +// +kubebuilder:validation:Enum=SSN;CREDIT_CARD;PHONE_NUMBER;EMAIL +type BuiltIn string + +const ( + // Default regex matching for Social Security numbers. + SSN BuiltIn = "SSN" + // Default regex matching for credit card numbers. + CREDIT_CARD BuiltIn = "CREDIT_CARD" + // Default regex matching for phone numbers. + PHONE_NUMBER BuiltIn = "PHONE_NUMBER" + // Default regex matching for email addresses. + EMAIL BuiltIn = "EMAIL" +) + +// RegexMatch configures the regular expression (regex) matching for prompt guards and data masking. +type RegexMatch struct { + // The regex pattern to match against the request or response. + Pattern string `json:"pattern,omitempty"` + // An optional name for this match, which can be used for debugging purposes. + Name string `json:"name,omitempty"` +} + +// Action to take if a regex pattern is matched in a request or response. +// This setting applies only to request matches. PromptguardResponse matches are always masked by default. +type Action string + +const ( + // Mask the matched data in the request. + MASK Action = "MASK" + // Reject the request if the regex matches content in the request. + REJECT Action = "REJECT" +) + +// Regex configures the regular expression (regex) matching for prompt guards and data masking. +type Regex struct { + // A list of regex patterns to match against the request or response. + // Matches and built-ins are additive. + Matches []RegexMatch `json:"matches,omitempty"` + // A list of built-in regex patterns to match against the request or response. + // Matches and built-ins are additive. + Builtins []BuiltIn `json:"builtins,omitempty"` + // The action to take if a regex pattern is matched in a request or response. + // This setting applies only to request matches. PromptguardResponse matches are always masked by default. + // Defaults to `MASK`. + // +kubebuilder:default=MASK + Action Action `json:"action,omitempty"` +} + +// Webhook configures a webhook to forward requests or responses to for prompt guarding. +type Webhook struct { + // Host to send the traffic to. + // +kubebuilder:validation:Required + Host *Host `json:"host"` + + // ForwardHeaders define headers to forward with the request to the webhook. + ForwardHeaders []gwv1.HTTPHeaderMatch `json:"forwardHeaders,omitempty"` +} + +// CustomResponse configures a response to return to the client if request content +// is matched against a regex pattern and the action is `REJECT`. +type CustomResponse struct { + // A custom response message to return to the client. If not specified, defaults to + // "The request was rejected due to inappropriate content". + // +kubebuilder:default="The request was rejected due to inappropriate content" + Message string `json:"message,omitempty"` + + // The status code to return to the client. Defaults to 403. + // +kubebuilder:default=403 + // +kubebuilder:validation:Minimum=200 + // +kubebuilder:validation:Maximum=599 + StatusCode uint32 `json:"statusCode,omitempty"` +} + +// OpenAIModeration configure an OpenAI moderation endpoint. +type OpenAIModeration struct { + // The name of the OpenAI moderation model to use. Defaults to + // [`omni-moderation-latest`](https://platform.openai.com/docs/guides/moderation). + // +kubebuilder:default="omni-moderation-latest" + Model string `json:"model,omitempty"` + + // The authorization token that the AIRoutePolicy gateway uses + // to access the OpenAI moderation model. + AuthToken *SingleAuthToken `json:"authToken,omitempty"` +} + +// Moderation configures an external moderation model endpoint. This endpoint evaluates +// request prompt data against predefined content rules to determine if the content +// adheres to those rules. +// +// Any requests routed through the AIRoutePolicy Gateway are processed by the specified +// moderation model. If the model identifies the content as harmful based on its rules, +// the request is automatically rejected. +// +// You can configure a moderation endpoint either as a standalone prompt guard setting +// or alongside other request and response guard settings. +type Moderation struct { + // Pass prompt data through an external moderation model endpoint, + // which compares the request prompt input to predefined content rules. + // Configure an OpenAI moderation endpoint. + OpenAIModeration *OpenAIModeration `json:"openAIModeration"` + + // TODO: support other moderation models +} + +// PromptguardRequest defines the prompt guards to apply to requests sent by the client. +type PromptguardRequest struct { + + // A custom response message to return to the client. If not specified, defaults to + // "The request was rejected due to inappropriate content". + CustomResponse *CustomResponse `json:"customResponse,omitempty"` + + // Regular expression (regex) matching for prompt guards and data masking. + Regex *Regex `json:"regex,omitempty"` + + // Configure a webhook to forward requests to for prompt guarding. + Webhook *Webhook `json:"webhook,omitempty"` + + // Pass prompt data through an external moderation model endpoint, + // which compares the request prompt input to predefined content rules. + Moderation *Moderation `json:"moderation,omitempty"` +} + +// PromptguardResponse configures the response that the prompt guard applies to responses returned by the LLM provider. +type PromptguardResponse struct { + // Regular expression (regex) matching for prompt guards and data masking. + Regex *Regex `json:"regex,omitempty"` + + // Configure a webhook to forward responses to for prompt guarding. + Webhook *Webhook `json:"webhook,omitempty"` +} + +// AIPromptGuard configures a prompt guards to block unwanted requests to the LLM provider and mask sensitive data. +// Prompt guards can be used to reject requests based on the content of the prompt, as well as +// mask responses based on the content of the response. +// +// This example rejects any request prompts that contain +// the string "credit card", and masks any credit card numbers in the response. +// ```yaml +// promptGuard: +// +// request: +// customResponse: +// message: "Rejected due to inappropriate content" +// regex: +// action: REJECT +// matches: +// - pattern: "credit card" +// name: "CC" +// response: +// regex: +// builtins: +// - CREDIT_CARD +// action: MASK +// +// ``` +type AIPromptGuard struct { + // Prompt guards to apply to requests sent by the client. + Request *PromptguardRequest `json:"request,omitempty"` + // Prompt guards to apply to responses returned by the LLM provider. + Response *PromptguardResponse `json:"response,omitempty"` +} + +// FieldDefault provides defaults to merge with user input fields. +// Defaults do _not_ override the user input fields, unless you explicitly set `override` to `true`. +// +// Example overriding the system field for Anthropic: +// ```yaml +// # Anthropic doesn't support a system chat type +// defaults: +// - field: "system" +// value: "answer all questions in French" +// +// ``` +// +// Example setting the temperature and overriding `max_tokens`: +// ```yaml +// defaults: +// - field: "temperature" +// value: "0.5" +// - field: "max_tokens" +// value: "100" +// +// ``` +// +// Example overriding custom list: +// ```yaml +// defaults: +// - field: "custom_list" +// value: "[a,b,c]" +// +// ``` +type FieldDefault struct { + // The name of the field. + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Field string `json:"field,omitempty"` + // The field default value, which can be any JSON Data Type. + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Value string `json:"value,omitempty"` + // Whether to override the field's value if it already exists. + // Defaults to false. + // +kubebuilder:default=false + Override bool `json:"override,omitempty"` +} diff --git a/api/v1alpha1/ai_upstream.go b/api/v1alpha1/ai_upstream.go new file mode 100644 index 00000000000..8238c1fde46 --- /dev/null +++ b/api/v1alpha1/ai_upstream.go @@ -0,0 +1,253 @@ +package v1alpha1 + +import corev1 "k8s.io/api/core/v1" + +// +kubebuilder:validation:XValidation:message="There must one and only one LLM or MultiPool can be set",rule="1 == (self.llm != null?1:0) + (self.multipool != null?1:0)" +type AIUpstream struct { + // Send requests to a custom host and port, such as to proxy the request, + // or to use a different backend that is API-compliant with the upstream version. + CustomHost *Host `json:"customHost,omitempty"` + + // The LLM configures the AIRoutePolicy gateway to use a single LLM provider backend. + LLM *LLMProviders `json:"llm,omitempty"` + // The MultiPool configures the backends for multiple hosts or models from the same provider in one Upstream resource. + MultiPool *MultiPoolConfig `json:"multipool,omitempty"` +} + +// LLMProviders configures the AIRoutePolicy gateway to use a single LLM provider backend. +// +kubebuilder:validation:XValidation:message="There must one and only one LLMProviders type set",rule="1 == (self.openai != null?1:0) + (self.azureopenai != null?1:0) + (self.anthropic != null?1:0) + (self.gemini != null?1:0) + (self.vertexai != null?1:0) + (self.mistral != null?1:0)" +type LLMProviders struct { + OpenAI *OpenAIConfig `json:"openai,omitempty"` + AzureOpenAI *AzureOpenAIConfig `json:"azureopenai,omitempty"` + Anthropic *AnthropicConfig `json:"anthropic,omitempty"` + Gemini *GeminiConfig `json:"gemini,omitempty"` + VertexAI *VertexAIConfig `json:"vertexai,omitempty"` + Mistral *MistralConfig `json:"mistral,omitempty"` +} + +type SingleAuthTokenKind string + +const ( + // Inline provides the token directly in the configuration for the Upstream. + Inline SingleAuthTokenKind = "Inline" + + // SecretRef provides the token directly in the configuration for the Upstream. + SecretRef SingleAuthTokenKind = "SecretRef" + + // Passthrough the existing token. This token can either + // come directly from the client, or be generated by an OIDC flow + // early in the request lifecycle. This option is useful for + // backends which have federated identity setup and can re-use + // the token from the client. + // Currently, this token must exist in the `Authorization` header. + Passthrough SingleAuthTokenKind = "Passthrough" +) + +// SingleAuthToken configures the authorization token that the AIRoutePolicy gateway uses to access the LLM provider API. +// This token is automatically sent in a request header, depending on the LLM provider. +// +kubebuilder:validation:XValidation:message="There must one and only one SingleAuthToken type set",rule="1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) ? 0 : 1)" +// +kubebuilder:validation:XValidation:message="Inline token must be set when kind is Inline or SecretRef must be set when kind is SecretRef",rule="(self.kind == 'Inline' && has(self.inline)) || (self.kind == 'SecretRef' && has(self.secretRef))" +type SingleAuthToken struct { + // Kind specifies which type of authorization token is being used. + // Must be one of: "Inline", "SecretRef", "Passthrough". + // +kubebuilder:validation:Enum=Inline;SecretRef;Passthrough + Kind SingleAuthTokenKind `json:"kind"` + + // Provide the token directly in the configuration for the Upstream. + // This option is the least secure. Only use this option for quick tests such as trying out AIRoutePolicy Gateway. + Inline string `json:"inline,omitempty"` + + // Store the API key in a Kubernetes secret in the same namespace as the Upstream. + // Then, refer to the secret in the Upstream configuration. This option is more secure than an inline token, + // because the API key is encoded and you can restrict access to secrets through RBAC rules. + // You might use this option in proofs of concept, controlled development and staging environments, + // or well-controlled prod environments that use secrets. + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"` +} + +// OpenAIConfig settings for the [OpenAI](https://platform.openai.com/docs/api-reference/streaming) LLM provider. +type OpenAIConfig struct { + // The authorization token that the AIRoutePolicy gateway uses to access the OpenAI API. + // This token is automatically sent in the `Authorization` header of the + // request and prefixed with `Bearer`. + // +kubebuilder:validation:Required + AuthToken *SingleAuthToken `json:"authToken,omitempty"` + // Optional: Send requests to a custom host and port, such as to proxy the request, + // or to use a different backend that is API-compliant with the upstream version. + CustomHost *Host `json:"customHost,omitempty"` + // Optional: Override the model name, such as `gpt-4o-mini`. + // If unset, the model name is taken from the request. + // This setting can be useful when setting up model failover within the same LLM provider. + Model string `json:"model,omitempty"` +} + +// AzureOpenAIConfig settings for the [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/) LLM provider. +type AzureOpenAIConfig struct { + // The authorization token that the AIRoutePolicy gateway uses to access the Azure OpenAI API. + // This token is automatically sent in the `api-key` header of the request. + // +kubebuilder:validation:Required + AuthToken *SingleAuthToken `json:"authToken"` + + // The endpoint for the Azure OpenAI API to use, such as `my-endpoint.openai.azure.com`. + // If the scheme is included, it is stripped. + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Endpoint string `json:"endpoint"` + + // The name of the Azure OpenAI model deployment to use. + // For more information, see the [Azure OpenAI model docs](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models). + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + DeploymentName string `json:"deploymentName"` + + // The version of the Azure OpenAI API to use. + // For more information, see the [Azure OpenAI API version reference](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs). + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + ApiVersion string `json:"apiVersion"` +} + +// GeminiConfig settings for the [Gemini](https://ai.google.dev/gemini-api/docs) LLM provider. +type GeminiConfig struct { + // The authorization token that the AIRoutePolicy gateway uses to access the Gemini API. + // This token is automatically sent in the `key` query parameter of the request. + // +kubebuilder:validation:Required + AuthToken *SingleAuthToken `json:"authToken"` + + // The Gemini model to use. + // For more information, see the [Gemini models docs](https://ai.google.dev/gemini-api/docs/models/gemini). + // +kubebuilder:validation:Required + Model string `json:"model"` + + // The version of the Gemini API to use. + // For more information, see the [Gemini API version docs](https://ai.google.dev/gemini-api/docs/api-versions). + // +kubebuilder:validation:Required + ApiVersion string `json:"apiVersion"` +} + +// Publisher configures the type of publisher model to use for VertexAI. Currently, only Google is supported. +type Publisher string + +const GOOGLE Publisher = "GOOGLE" + +// VertexAIConfig settings for the [Vertex AIRoutePolicy](https://cloud.google.com/vertex-ai/docs) LLM provider. +// To find the values for the project ID, project location, and publisher, you can check the fields of an API request, such as +// `https://{LOCATION}-aiplatform.googleapis.com/{VERSION}/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/{PROVIDER}/`. +type VertexAIConfig struct { + // The authorization token that the AIRoutePolicy gateway uses to access the Vertex AIRoutePolicy API. + // This token is automatically sent in the `key` header of the request. + // +kubebuilder:validation:Required + AuthToken *SingleAuthToken `json:"authToken"` + + // The Vertex AIRoutePolicy model to use. + // For more information, see the [Vertex AIRoutePolicy model docs](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models). + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Model string `json:"model"` + + // The version of the Vertex AIRoutePolicy API to use. + // For more information, see the [Vertex AIRoutePolicy API reference](https://cloud.google.com/vertex-ai/docs/reference#versions). + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + ApiVersion string `json:"apiVersion"` + + // The ID of the Google Cloud Project that you use for the Vertex AIRoutePolicy. + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + ProjectId string `json:"projectId"` + + // The location of the Google Cloud Project that you use for the Vertex AIRoutePolicy. + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinLength=1 + Location string `json:"location"` + + // Optional: The model path to route to. Defaults to the Gemini model path, `generateContent`. + ModelPath string `json:"modelPath,omitempty"` + + // The type of publisher model to use. Currently, only Google is supported. + // +kubebuilder:validation:Enum=GOOGLE + Publisher Publisher `json:"publisher,omitempty"` +} + +// MistralConfig configures the settings for the [Mistral AIRoutePolicy](https://docs.mistral.ai/getting-started/quickstart/) LLM provider. +type MistralConfig struct { + // The authorization token that the AIRoutePolicy gateway uses to access the OpenAI API. + // This token is automatically sent in the `Authorization` header of the + // request and prefixed with `Bearer`. + // +kubebuilder:validation:Required + AuthToken *SingleAuthToken `json:"authToken"` + // Optional: Send requests to a custom host and port, such as to proxy the request, + // or to use a different backend that is API-compliant with the upstream version. + CustomHost *Host `json:"customHost,omitempty"` + // Optional: Override the model name. + // If unset, the model name is taken from the request. + // This setting can be useful when testing model failover scenarios. + Model string `json:"model,omitempty"` +} + +// AnthropicConfig settings for the [Anthropic](https://docs.anthropic.com/en/release-notes/api) LLM provider. +type AnthropicConfig struct { + // The authorization token that the AIRoutePolicy gateway uses to access the Anthropic API. + // This token is automatically sent in the `x-api-key` header of the request. + // +kubebuilder:validation:Required + AuthToken *SingleAuthToken `json:"authToken"` + // Optional: Send requests to a custom host and port, such as to proxy the request, + // or to use a different backend that is API-compliant with the upstream version. + CustomHost *Host `json:"customHost,omitempty"` + // Optional: A version header to pass to the Anthropic API. + // For more information, see the [Anthropic API versioning docs](https://docs.anthropic.com/en/api/versioning). + Version string `json:"apiVersion,omitempty"` + // Optional: Override the model name. + // If unset, the model name is taken from the request. + // This setting can be useful when testing model failover scenarios. + Model string `json:"model,omitempty"` +} + +// Priority configures the priority of the backend endpoints. +type Priority struct { + // A list of LLM provider backends within a single endpoint pool entry. + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:MaxItems=20 + Pool []LLMProviders `json:"pool,omitempty"` +} + +// MultiPoolConfig configures the backends for multiple hosts or models from the same provider in one Upstream resource. +// This method can be useful for creating one logical endpoint that is backed +// by multiple hosts or models. +// +// In the `priorities` section, the order of `pool` entries defines the priority of the backend endpoints. +// The `pool` entries can either define a list of backends or a single backend. +// Note: Only two levels of nesting are permitted. Any nested entries after the second level are ignored. +// +// ```yaml +// multi: +// +// priorities: +// - pool: +// - azureOpenai: +// deploymentName: gpt-4o-mini +// apiVersion: 2024-02-15-preview +// endpoint: ai-gateway.openai.azure.com +// authToken: +// secretRef: +// name: azure-secret +// namespace: kgateway-system +// - pool: +// - azureOpenai: +// deploymentName: gpt-4o-mini-2 +// apiVersion: 2024-02-15-preview +// endpoint: ai-gateway-2.openai.azure.com +// authToken: +// secretRef: +// name: azure-secret-2 +// namespace: kgateway-system +// +// ``` +type MultiPoolConfig struct { + // The priority list of backend pools. Each entry represents a set of LLM provider backends. + // The order defines the priority of the backend endpoints. + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:MaxItems=20 + Priorities []Priority `json:"priorities,omitempty"` +} diff --git a/api/v1alpha1/gateway_parameters_types.go b/api/v1alpha1/gateway_parameters_types.go index b64328c8176..621c5d73c6c 100644 --- a/api/v1alpha1/gateway_parameters_types.go +++ b/api/v1alpha1/gateway_parameters_types.go @@ -101,7 +101,7 @@ type KubernetesProxyConfig struct { // +kubebuilder:validation:Optional Stats *StatsConfig `json:"stats,omitempty"` - // Configuration for the AI extension. + // Configuration for the AIRoutePolicy extension. // // +kubebuilder:validation:Optional AiExtension *AiExtension `json:"aiExtension,omitempty"` @@ -554,7 +554,7 @@ func (in *StatsConfig) GetStatsRoutePrefixRewrite() *string { return in.StatsRoutePrefixRewrite } -// Configuration for the AI extension. +// Configuration for the AIRoutePolicy extension. type AiExtension struct { // Whether to enable the extension. // @@ -594,7 +594,7 @@ type AiExtension struct { // +kubebuilder:validation:Optional Ports []corev1.ContainerPort `json:"ports,omitempty"` - // Additional stats config for AI Extension. + // Additional stats config for AIRoutePolicy Extension. // This config can be useful for adding custom labels to the request metrics. // +optional // @@ -663,7 +663,7 @@ func (in *AiExtension) GetStats() *AiExtensionStats { type AiExtensionStats struct { // Set of custom labels to be added to the request metrics. - // These will be added on each request which goes through the AI Extension. + // These will be added on each request which goes through the AIRoutePolicy Extension. // +optional CustomLabels []*CustomLabel `json:"customLabels,omitempty"` } diff --git a/api/v1alpha1/route_policy_types.go b/api/v1alpha1/route_policy_types.go index 1e2793987f1..6d64cd3d4a9 100644 --- a/api/v1alpha1/route_policy_types.go +++ b/api/v1alpha1/route_policy_types.go @@ -31,5 +31,6 @@ type RoutePolicyList struct { type RoutePolicySpec struct { TargetRef LocalPolicyTargetReference `json:"targetRef,omitempty"` // +kubebuilder:validation:Minimum=1 - Timeout int `json:"timeout,omitempty"` + Timeout int `json:"timeout,omitempty"` + AI *AIRoutePolicy `json:"ai,omitempty"` } diff --git a/api/v1alpha1/upstream_policy_types.go b/api/v1alpha1/upstream_policy_types.go index 177cd199be1..b0e0155c01a 100644 --- a/api/v1alpha1/upstream_policy_types.go +++ b/api/v1alpha1/upstream_policy_types.go @@ -29,10 +29,11 @@ type UpstreamList struct { Items []Upstream `json:"items"` } -// +kubebuilder:validation:XValidation:message="There must one and only one upstream type set",rule="1 == (self.aws != null?1:0) + (self.static != null?1:0)" +// +kubebuilder:validation:XValidation:message="There must one and only one upstream type set",rule="1 == (self.aws != null?1:0) + (self.static != null?1:0) + (self.ai != null?1:0)" type UpstreamSpec struct { Aws *AwsUpstream `json:"aws,omitempty"` Static *StaticUpstream `json:"static,omitempty"` + AI *AIUpstream `json:"ai,omitempty"` } type AwsUpstream struct { Region string `json:"region,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index a1c5f0eda46..5053407b836 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -5,12 +5,122 @@ package v1alpha1 import ( - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - apisv1 "sigs.k8s.io/gateway-api/apis/v1" + v1 "sigs.k8s.io/gateway-api/apis/v1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AIPromptEnrichment) DeepCopyInto(out *AIPromptEnrichment) { + *out = *in + if in.Prepend != nil { + in, out := &in.Prepend, &out.Prepend + *out = make([]Message, len(*in)) + copy(*out, *in) + } + if in.Append != nil { + in, out := &in.Append, &out.Append + *out = make([]Message, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AIPromptEnrichment. +func (in *AIPromptEnrichment) DeepCopy() *AIPromptEnrichment { + if in == nil { + return nil + } + out := new(AIPromptEnrichment) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AIPromptGuard) DeepCopyInto(out *AIPromptGuard) { + *out = *in + if in.Request != nil { + in, out := &in.Request, &out.Request + *out = new(PromptguardRequest) + (*in).DeepCopyInto(*out) + } + if in.Response != nil { + in, out := &in.Response, &out.Response + *out = new(PromptguardResponse) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AIPromptGuard. +func (in *AIPromptGuard) DeepCopy() *AIPromptGuard { + if in == nil { + return nil + } + out := new(AIPromptGuard) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AIRoutePolicy) DeepCopyInto(out *AIRoutePolicy) { + *out = *in + if in.PromptEnrichment != nil { + in, out := &in.PromptEnrichment, &out.PromptEnrichment + *out = new(AIPromptEnrichment) + (*in).DeepCopyInto(*out) + } + if in.PromptGuard != nil { + in, out := &in.PromptGuard, &out.PromptGuard + *out = new(AIPromptGuard) + (*in).DeepCopyInto(*out) + } + if in.Defaults != nil { + in, out := &in.Defaults, &out.Defaults + *out = make([]FieldDefault, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AIRoutePolicy. +func (in *AIRoutePolicy) DeepCopy() *AIRoutePolicy { + if in == nil { + return nil + } + out := new(AIRoutePolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AIUpstream) DeepCopyInto(out *AIUpstream) { + *out = *in + if in.CustomHost != nil { + in, out := &in.CustomHost, &out.CustomHost + *out = new(Host) + **out = **in + } + if in.LLM != nil { + in, out := &in.LLM, &out.LLM + *out = new(LLMProviders) + (*in).DeepCopyInto(*out) + } + if in.MultiPool != nil { + in, out := &in.MultiPool, &out.MultiPool + *out = new(MultiPoolConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AIUpstream. +func (in *AIUpstream) DeepCopy() *AIUpstream { + if in == nil { + return nil + } + out := new(AIUpstream) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AccessLog) DeepCopyInto(out *AccessLog) { *out = *in @@ -90,24 +200,24 @@ func (in *AiExtension) DeepCopyInto(out *AiExtension) { } if in.SecurityContext != nil { in, out := &in.SecurityContext, &out.SecurityContext - *out = new(v1.SecurityContext) + *out = new(corev1.SecurityContext) (*in).DeepCopyInto(*out) } if in.Resources != nil { in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) + *out = new(corev1.ResourceRequirements) (*in).DeepCopyInto(*out) } if in.Env != nil { in, out := &in.Env, &out.Env - *out = make([]v1.EnvVar, len(*in)) + *out = make([]corev1.EnvVar, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.Ports != nil { in, out := &in.Ports, &out.Ports - *out = make([]v1.ContainerPort, len(*in)) + *out = make([]corev1.ContainerPort, len(*in)) copy(*out, *in) } if in.Stats != nil { @@ -153,6 +263,31 @@ func (in *AiExtensionStats) DeepCopy() *AiExtensionStats { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AnthropicConfig) DeepCopyInto(out *AnthropicConfig) { + *out = *in + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(SingleAuthToken) + (*in).DeepCopyInto(*out) + } + if in.CustomHost != nil { + in, out := &in.CustomHost, &out.CustomHost + *out = new(Host) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AnthropicConfig. +func (in *AnthropicConfig) DeepCopy() *AnthropicConfig { + if in == nil { + return nil + } + out := new(AnthropicConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AwsUpstream) DeepCopyInto(out *AwsUpstream) { *out = *in @@ -169,6 +304,26 @@ func (in *AwsUpstream) DeepCopy() *AwsUpstream { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureOpenAIConfig) DeepCopyInto(out *AzureOpenAIConfig) { + *out = *in + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(SingleAuthToken) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureOpenAIConfig. +func (in *AzureOpenAIConfig) DeepCopy() *AzureOpenAIConfig { + if in == nil { + return nil + } + out := new(AzureOpenAIConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CELFilter) DeepCopyInto(out *CELFilter) { *out = *in @@ -224,6 +379,21 @@ func (in *CustomLabel) DeepCopy() *CustomLabel { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomResponse) DeepCopyInto(out *CustomResponse) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomResponse. +func (in *CustomResponse) DeepCopy() *CustomResponse { + if in == nil { + return nil + } + out := new(CustomResponse) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DirectResponse) DeepCopyInto(out *DirectResponse) { *out = *in @@ -370,12 +540,12 @@ func (in *EnvoyContainer) DeepCopyInto(out *EnvoyContainer) { } if in.SecurityContext != nil { in, out := &in.SecurityContext, &out.SecurityContext - *out = new(v1.SecurityContext) + *out = new(corev1.SecurityContext) (*in).DeepCopyInto(*out) } if in.Resources != nil { in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) + *out = new(corev1.ResourceRequirements) (*in).DeepCopyInto(*out) } } @@ -390,6 +560,21 @@ func (in *EnvoyContainer) DeepCopy() *EnvoyContainer { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FieldDefault) DeepCopyInto(out *FieldDefault) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FieldDefault. +func (in *FieldDefault) DeepCopy() *FieldDefault { + if in == nil { + return nil + } + out := new(FieldDefault) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FileSink) DeepCopyInto(out *FileSink) { *out = *in @@ -554,6 +739,26 @@ func (in *GatewayParametersStatus) DeepCopy() *GatewayParametersStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GeminiConfig) DeepCopyInto(out *GeminiConfig) { + *out = *in + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(SingleAuthToken) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GeminiConfig. +func (in *GeminiConfig) DeepCopy() *GeminiConfig { + if in == nil { + return nil + } + out := new(GeminiConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GracefulShutdownSpec) DeepCopyInto(out *GracefulShutdownSpec) { *out = *in @@ -584,7 +789,7 @@ func (in *GrpcService) DeepCopyInto(out *GrpcService) { *out = *in if in.BackendRef != nil { in, out := &in.BackendRef, &out.BackendRef - *out = new(apisv1.BackendRef) + *out = new(v1.BackendRef) (*in).DeepCopyInto(*out) } if in.AdditionalRequestHeadersToLog != nil { @@ -772,7 +977,7 @@ func (in *Image) DeepCopyInto(out *Image) { } if in.PullPolicy != nil { in, out := &in.PullPolicy, &out.PullPolicy - *out = new(v1.PullPolicy) + *out = new(corev1.PullPolicy) **out = **in } } @@ -797,12 +1002,12 @@ func (in *IstioContainer) DeepCopyInto(out *IstioContainer) { } if in.SecurityContext != nil { in, out := &in.SecurityContext, &out.SecurityContext - *out = new(v1.SecurityContext) + *out = new(corev1.SecurityContext) (*in).DeepCopyInto(*out) } if in.Resources != nil { in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) + *out = new(corev1.ResourceRequirements) (*in).DeepCopyInto(*out) } if in.LogLevel != nil { @@ -847,7 +1052,7 @@ func (in *IstioIntegration) DeepCopyInto(out *IstioIntegration) { } if in.CustomSidecars != nil { in, out := &in.CustomSidecars, &out.CustomSidecars - *out = make([]v1.Container, len(*in)) + *out = make([]corev1.Container, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -929,6 +1134,51 @@ func (in *KubernetesProxyConfig) DeepCopy() *KubernetesProxyConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LLMProviders) DeepCopyInto(out *LLMProviders) { + *out = *in + if in.OpenAI != nil { + in, out := &in.OpenAI, &out.OpenAI + *out = new(OpenAIConfig) + (*in).DeepCopyInto(*out) + } + if in.AzureOpenAI != nil { + in, out := &in.AzureOpenAI, &out.AzureOpenAI + *out = new(AzureOpenAIConfig) + (*in).DeepCopyInto(*out) + } + if in.Anthropic != nil { + in, out := &in.Anthropic, &out.Anthropic + *out = new(AnthropicConfig) + (*in).DeepCopyInto(*out) + } + if in.Gemini != nil { + in, out := &in.Gemini, &out.Gemini + *out = new(GeminiConfig) + (*in).DeepCopyInto(*out) + } + if in.VertexAI != nil { + in, out := &in.VertexAI, &out.VertexAI + *out = new(VertexAIConfig) + (*in).DeepCopyInto(*out) + } + if in.Mistral != nil { + in, out := &in.Mistral, &out.Mistral + *out = new(MistralConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LLMProviders. +func (in *LLMProviders) DeepCopy() *LLMProviders { + if in == nil { + return nil + } + out := new(LLMProviders) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ListenerPolicy) DeepCopyInto(out *ListenerPolicy) { *out = *in @@ -1019,6 +1269,133 @@ func (in *LocalPolicyTargetReference) DeepCopy() *LocalPolicyTargetReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Message) DeepCopyInto(out *Message) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Message. +func (in *Message) DeepCopy() *Message { + if in == nil { + return nil + } + out := new(Message) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MistralConfig) DeepCopyInto(out *MistralConfig) { + *out = *in + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(SingleAuthToken) + (*in).DeepCopyInto(*out) + } + if in.CustomHost != nil { + in, out := &in.CustomHost, &out.CustomHost + *out = new(Host) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MistralConfig. +func (in *MistralConfig) DeepCopy() *MistralConfig { + if in == nil { + return nil + } + out := new(MistralConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Moderation) DeepCopyInto(out *Moderation) { + *out = *in + if in.OpenAIModeration != nil { + in, out := &in.OpenAIModeration, &out.OpenAIModeration + *out = new(OpenAIModeration) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Moderation. +func (in *Moderation) DeepCopy() *Moderation { + if in == nil { + return nil + } + out := new(Moderation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MultiPoolConfig) DeepCopyInto(out *MultiPoolConfig) { + *out = *in + if in.Priorities != nil { + in, out := &in.Priorities, &out.Priorities + *out = make([]Priority, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiPoolConfig. +func (in *MultiPoolConfig) DeepCopy() *MultiPoolConfig { + if in == nil { + return nil + } + out := new(MultiPoolConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenAIConfig) DeepCopyInto(out *OpenAIConfig) { + *out = *in + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(SingleAuthToken) + (*in).DeepCopyInto(*out) + } + if in.CustomHost != nil { + in, out := &in.CustomHost, &out.CustomHost + *out = new(Host) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenAIConfig. +func (in *OpenAIConfig) DeepCopy() *OpenAIConfig { + if in == nil { + return nil + } + out := new(OpenAIConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenAIModeration) DeepCopyInto(out *OpenAIModeration) { + *out = *in + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(SingleAuthToken) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenAIModeration. +func (in *OpenAIModeration) DeepCopy() *OpenAIModeration { + if in == nil { + return nil + } + out := new(OpenAIModeration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Pod) DeepCopyInto(out *Pod) { *out = *in @@ -1038,12 +1415,12 @@ func (in *Pod) DeepCopyInto(out *Pod) { } if in.SecurityContext != nil { in, out := &in.SecurityContext, &out.SecurityContext - *out = new(v1.PodSecurityContext) + *out = new(corev1.PodSecurityContext) (*in).DeepCopyInto(*out) } if in.ImagePullSecrets != nil { in, out := &in.ImagePullSecrets, &out.ImagePullSecrets - *out = make([]v1.LocalObjectReference, len(*in)) + *out = make([]corev1.LocalObjectReference, len(*in)) copy(*out, *in) } if in.NodeSelector != nil { @@ -1055,12 +1432,12 @@ func (in *Pod) DeepCopyInto(out *Pod) { } if in.Affinity != nil { in, out := &in.Affinity, &out.Affinity - *out = new(v1.Affinity) + *out = new(corev1.Affinity) (*in).DeepCopyInto(*out) } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations - *out = make([]v1.Toleration, len(*in)) + *out = make([]corev1.Toleration, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -1077,12 +1454,12 @@ func (in *Pod) DeepCopyInto(out *Pod) { } if in.ReadinessProbe != nil { in, out := &in.ReadinessProbe, &out.ReadinessProbe - *out = new(v1.Probe) + *out = new(corev1.Probe) (*in).DeepCopyInto(*out) } if in.LivenessProbe != nil { in, out := &in.LivenessProbe, &out.LivenessProbe - *out = new(v1.Probe) + *out = new(corev1.Probe) (*in).DeepCopyInto(*out) } } @@ -1149,6 +1526,88 @@ func (in *PolicyStatus) DeepCopy() *PolicyStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Priority) DeepCopyInto(out *Priority) { + *out = *in + if in.Pool != nil { + in, out := &in.Pool, &out.Pool + *out = make([]LLMProviders, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Priority. +func (in *Priority) DeepCopy() *Priority { + if in == nil { + return nil + } + out := new(Priority) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptguardRequest) DeepCopyInto(out *PromptguardRequest) { + *out = *in + if in.CustomResponse != nil { + in, out := &in.CustomResponse, &out.CustomResponse + *out = new(CustomResponse) + **out = **in + } + if in.Regex != nil { + in, out := &in.Regex, &out.Regex + *out = new(Regex) + (*in).DeepCopyInto(*out) + } + if in.Webhook != nil { + in, out := &in.Webhook, &out.Webhook + *out = new(Webhook) + (*in).DeepCopyInto(*out) + } + if in.Moderation != nil { + in, out := &in.Moderation, &out.Moderation + *out = new(Moderation) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptguardRequest. +func (in *PromptguardRequest) DeepCopy() *PromptguardRequest { + if in == nil { + return nil + } + out := new(PromptguardRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptguardResponse) DeepCopyInto(out *PromptguardResponse) { + *out = *in + if in.Regex != nil { + in, out := &in.Regex, &out.Regex + *out = new(Regex) + (*in).DeepCopyInto(*out) + } + if in.Webhook != nil { + in, out := &in.Webhook, &out.Webhook + *out = new(Webhook) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptguardResponse. +func (in *PromptguardResponse) DeepCopy() *PromptguardResponse { + if in == nil { + return nil + } + out := new(PromptguardResponse) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ProxyDeployment) DeepCopyInto(out *ProxyDeployment) { *out = *in @@ -1169,6 +1628,46 @@ func (in *ProxyDeployment) DeepCopy() *ProxyDeployment { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Regex) DeepCopyInto(out *Regex) { + *out = *in + if in.Matches != nil { + in, out := &in.Matches, &out.Matches + *out = make([]RegexMatch, len(*in)) + copy(*out, *in) + } + if in.Builtins != nil { + in, out := &in.Builtins, &out.Builtins + *out = make([]BuiltIn, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Regex. +func (in *Regex) DeepCopy() *Regex { + if in == nil { + return nil + } + out := new(Regex) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegexMatch) DeepCopyInto(out *RegexMatch) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegexMatch. +func (in *RegexMatch) DeepCopy() *RegexMatch { + if in == nil { + return nil + } + out := new(RegexMatch) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResponseFlagFilter) DeepCopyInto(out *ResponseFlagFilter) { *out = *in @@ -1194,7 +1693,7 @@ func (in *RoutePolicy) DeepCopyInto(out *RoutePolicy) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } @@ -1252,6 +1751,11 @@ func (in *RoutePolicyList) DeepCopyObject() runtime.Object { func (in *RoutePolicySpec) DeepCopyInto(out *RoutePolicySpec) { *out = *in out.TargetRef = in.TargetRef + if in.AI != nil { + in, out := &in.AI, &out.AI + *out = new(AIRoutePolicy) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RoutePolicySpec. @@ -1294,12 +1798,12 @@ func (in *SdsContainer) DeepCopyInto(out *SdsContainer) { } if in.SecurityContext != nil { in, out := &in.SecurityContext, &out.SecurityContext - *out = new(v1.SecurityContext) + *out = new(corev1.SecurityContext) (*in).DeepCopyInto(*out) } if in.Resources != nil { in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) + *out = new(corev1.ResourceRequirements) (*in).DeepCopyInto(*out) } if in.Bootstrap != nil { @@ -1339,7 +1843,7 @@ func (in *Service) DeepCopyInto(out *Service) { *out = *in if in.Type != nil { in, out := &in.Type, &out.Type - *out = new(v1.ServiceType) + *out = new(corev1.ServiceType) **out = **in } if in.ClusterIP != nil { @@ -1402,6 +1906,26 @@ func (in *ServiceAccount) DeepCopy() *ServiceAccount { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SingleAuthToken) DeepCopyInto(out *SingleAuthToken) { + *out = *in + if in.SecretRef != nil { + in, out := &in.SecretRef, &out.SecretRef + *out = new(corev1.LocalObjectReference) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SingleAuthToken. +func (in *SingleAuthToken) DeepCopy() *SingleAuthToken { + if in == nil { + return nil + } + out := new(SingleAuthToken) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StaticUpstream) DeepCopyInto(out *StaticUpstream) { *out = *in @@ -1544,6 +2068,11 @@ func (in *UpstreamSpec) DeepCopyInto(out *UpstreamSpec) { *out = new(StaticUpstream) (*in).DeepCopyInto(*out) } + if in.AI != nil { + in, out := &in.AI, &out.AI + *out = new(AIUpstream) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamSpec. @@ -1577,3 +2106,50 @@ func (in *UpstreamStatus) DeepCopy() *UpstreamStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VertexAIConfig) DeepCopyInto(out *VertexAIConfig) { + *out = *in + if in.AuthToken != nil { + in, out := &in.AuthToken, &out.AuthToken + *out = new(SingleAuthToken) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VertexAIConfig. +func (in *VertexAIConfig) DeepCopy() *VertexAIConfig { + if in == nil { + return nil + } + out := new(VertexAIConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Webhook) DeepCopyInto(out *Webhook) { + *out = *in + if in.Host != nil { + in, out := &in.Host, &out.Host + *out = new(Host) + **out = **in + } + if in.ForwardHeaders != nil { + in, out := &in.ForwardHeaders, &out.ForwardHeaders + *out = make([]v1.HTTPHeaderMatch, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Webhook. +func (in *Webhook) DeepCopy() *Webhook { + if in == nil { + return nil + } + out := new(Webhook) + in.DeepCopyInto(out) + return out +} diff --git a/install/helm/kgateway/crds/gateway.kgateway.dev_routepolicies.yaml b/install/helm/kgateway/crds/gateway.kgateway.dev_routepolicies.yaml index 831686232fb..8bdbaec9bea 100644 --- a/install/helm/kgateway/crds/gateway.kgateway.dev_routepolicies.yaml +++ b/install/helm/kgateway/crds/gateway.kgateway.dev_routepolicies.yaml @@ -34,6 +34,249 @@ spec: type: object spec: properties: + ai: + properties: + defaults: + items: + properties: + field: + minLength: 1 + type: string + override: + default: false + type: boolean + value: + minLength: 1 + type: string + required: + - field + - value + type: object + type: array + promptEnrichment: + properties: + append: + items: + properties: + content: + type: string + role: + type: string + type: object + type: array + prepend: + items: + properties: + content: + type: string + role: + type: string + type: object + type: array + type: object + promptGuard: + properties: + request: + properties: + customResponse: + properties: + message: + default: The request was rejected due to inappropriate + content + type: string + statusCode: + default: 403 + format: int32 + maximum: 599 + minimum: 200 + type: integer + type: object + moderation: + properties: + openAIModeration: + properties: + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) + ? 0 : 1)' + - message: Inline token must be set when kind + is Inline or SecretRef must be set when kind + is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) + || (self.kind == 'SecretRef' && has(self.secretRef)) + model: + default: omni-moderation-latest + type: string + type: object + required: + - openAIModeration + type: object + regex: + properties: + action: + default: MASK + type: string + builtins: + items: + enum: + - SSN + - CREDIT_CARD + - PHONE_NUMBER + - EMAIL + type: string + type: array + matches: + items: + properties: + name: + type: string + pattern: + type: string + type: object + type: array + type: object + webhook: + properties: + forwardHeaders: + items: + properties: + name: + maxLength: 256 + minLength: 1 + pattern: ^[A-Za-z0-9!#$%&'*+\-.^_\x60|~]+$ + type: string + type: + default: Exact + enum: + - Exact + - RegularExpression + type: string + value: + maxLength: 4096 + minLength: 1 + type: string + required: + - name + - value + type: object + type: array + host: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + required: + - host + type: object + type: object + response: + properties: + regex: + properties: + action: + default: MASK + type: string + builtins: + items: + enum: + - SSN + - CREDIT_CARD + - PHONE_NUMBER + - EMAIL + type: string + type: array + matches: + items: + properties: + name: + type: string + pattern: + type: string + type: object + type: array + type: object + webhook: + properties: + forwardHeaders: + items: + properties: + name: + maxLength: 256 + minLength: 1 + pattern: ^[A-Za-z0-9!#$%&'*+\-.^_\x60|~]+$ + type: string + type: + default: Exact + enum: + - Exact + - RegularExpression + type: string + value: + maxLength: 4096 + minLength: 1 + type: string + required: + - name + - value + type: object + type: array + host: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + required: + - host + type: object + type: object + type: object + routeType: + enum: + - CHAT + - CHAT_STREAMING + type: string + type: object targetRef: properties: group: diff --git a/install/helm/kgateway/crds/gateway.kgateway.dev_upstreams.yaml b/install/helm/kgateway/crds/gateway.kgateway.dev_upstreams.yaml index c4908b56cc2..c42c794a10c 100644 --- a/install/helm/kgateway/crds/gateway.kgateway.dev_upstreams.yaml +++ b/install/helm/kgateway/crds/gateway.kgateway.dev_upstreams.yaml @@ -33,6 +33,662 @@ spec: type: object spec: properties: + ai: + properties: + customHost: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + llm: + properties: + anthropic: + properties: + apiVersion: + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) + ? 0 : 1)' + - message: Inline token must be set when kind is Inline + or SecretRef must be set when kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) || + (self.kind == 'SecretRef' && has(self.secretRef)) + customHost: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + model: + type: string + required: + - authToken + type: object + azureopenai: + properties: + apiVersion: + minLength: 1 + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) + ? 0 : 1)' + - message: Inline token must be set when kind is Inline + or SecretRef must be set when kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) || + (self.kind == 'SecretRef' && has(self.secretRef)) + deploymentName: + minLength: 1 + type: string + endpoint: + minLength: 1 + type: string + required: + - apiVersion + - authToken + - deploymentName + - endpoint + type: object + gemini: + properties: + apiVersion: + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) + ? 0 : 1)' + - message: Inline token must be set when kind is Inline + or SecretRef must be set when kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) || + (self.kind == 'SecretRef' && has(self.secretRef)) + model: + type: string + required: + - apiVersion + - authToken + - model + type: object + mistral: + properties: + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) + ? 0 : 1)' + - message: Inline token must be set when kind is Inline + or SecretRef must be set when kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) || + (self.kind == 'SecretRef' && has(self.secretRef)) + customHost: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + model: + type: string + required: + - authToken + type: object + openai: + properties: + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) + ? 0 : 1)' + - message: Inline token must be set when kind is Inline + or SecretRef must be set when kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) || + (self.kind == 'SecretRef' && has(self.secretRef)) + customHost: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + model: + type: string + required: + - authToken + type: object + vertexai: + properties: + apiVersion: + minLength: 1 + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + (!has(self.secretRef) + ? 0 : 1)' + - message: Inline token must be set when kind is Inline + or SecretRef must be set when kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) || + (self.kind == 'SecretRef' && has(self.secretRef)) + location: + minLength: 1 + type: string + model: + minLength: 1 + type: string + modelPath: + type: string + projectId: + minLength: 1 + type: string + publisher: + enum: + - GOOGLE + type: string + required: + - apiVersion + - authToken + - location + - model + - projectId + type: object + type: object + x-kubernetes-validations: + - message: There must one and only one LLMProviders type set + rule: 1 == (self.openai != null?1:0) + (self.azureopenai != + null?1:0) + (self.anthropic != null?1:0) + (self.gemini != + null?1:0) + (self.vertexai != null?1:0) + (self.mistral != + null?1:0) + multipool: + properties: + priorities: + items: + properties: + pool: + items: + properties: + anthropic: + properties: + apiVersion: + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + + (!has(self.secretRef) ? 0 : 1)' + - message: Inline token must be set when kind + is Inline or SecretRef must be set when + kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) + || (self.kind == 'SecretRef' && has(self.secretRef)) + customHost: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + model: + type: string + required: + - authToken + type: object + azureopenai: + properties: + apiVersion: + minLength: 1 + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + + (!has(self.secretRef) ? 0 : 1)' + - message: Inline token must be set when kind + is Inline or SecretRef must be set when + kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) + || (self.kind == 'SecretRef' && has(self.secretRef)) + deploymentName: + minLength: 1 + type: string + endpoint: + minLength: 1 + type: string + required: + - apiVersion + - authToken + - deploymentName + - endpoint + type: object + gemini: + properties: + apiVersion: + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + + (!has(self.secretRef) ? 0 : 1)' + - message: Inline token must be set when kind + is Inline or SecretRef must be set when + kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) + || (self.kind == 'SecretRef' && has(self.secretRef)) + model: + type: string + required: + - apiVersion + - authToken + - model + type: object + mistral: + properties: + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + + (!has(self.secretRef) ? 0 : 1)' + - message: Inline token must be set when kind + is Inline or SecretRef must be set when + kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) + || (self.kind == 'SecretRef' && has(self.secretRef)) + customHost: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + model: + type: string + required: + - authToken + type: object + openai: + properties: + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + + (!has(self.secretRef) ? 0 : 1)' + - message: Inline token must be set when kind + is Inline or SecretRef must be set when + kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) + || (self.kind == 'SecretRef' && has(self.secretRef)) + customHost: + properties: + host: + maxLength: 253 + minLength: 1 + type: string + port: + format: int32 + maximum: 65535 + minimum: 1 + type: integer + required: + - host + - port + type: object + model: + type: string + required: + - authToken + type: object + vertexai: + properties: + apiVersion: + minLength: 1 + type: string + authToken: + properties: + inline: + type: string + kind: + enum: + - Inline + - SecretRef + - Passthrough + type: string + secretRef: + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + required: + - kind + type: object + x-kubernetes-validations: + - message: There must one and only one SingleAuthToken + type set + rule: '1 == (!has(self.inline) ? 0 : 1) + + (!has(self.secretRef) ? 0 : 1)' + - message: Inline token must be set when kind + is Inline or SecretRef must be set when + kind is SecretRef + rule: (self.kind == 'Inline' && has(self.inline)) + || (self.kind == 'SecretRef' && has(self.secretRef)) + location: + minLength: 1 + type: string + model: + minLength: 1 + type: string + modelPath: + type: string + projectId: + minLength: 1 + type: string + publisher: + enum: + - GOOGLE + type: string + required: + - apiVersion + - authToken + - location + - model + - projectId + type: object + type: object + x-kubernetes-validations: + - message: There must one and only one LLMProviders + type set + rule: 1 == (self.openai != null?1:0) + (self.azureopenai + != null?1:0) + (self.anthropic != null?1:0) + + (self.gemini != null?1:0) + (self.vertexai != + null?1:0) + (self.mistral != null?1:0) + maxItems: 20 + minItems: 1 + type: array + type: object + maxItems: 20 + minItems: 1 + type: array + required: + - priorities + type: object + type: object + x-kubernetes-validations: + - message: There must one and only one LLM or MultiPool can be set + rule: 1 == (self.llm != null?1:0) + (self.multipool != null?1:0) aws: properties: region: @@ -68,7 +724,8 @@ spec: type: object x-kubernetes-validations: - message: There must one and only one upstream type set - rule: 1 == (self.aws != null?1:0) + (self.static != null?1:0) + rule: 1 == (self.aws != null?1:0) + (self.static != null?1:0) + (self.ai + != null?1:0) status: properties: conditions: diff --git a/internal/kgateway/deployer/deployer_test.go b/internal/kgateway/deployer/deployer_test.go index d0b4a59dad6..a55c2747d6a 100644 --- a/internal/kgateway/deployer/deployer_test.go +++ b/internal/kgateway/deployer/deployer_test.go @@ -878,7 +878,7 @@ var _ = Describe("Deployer", func() { fullyDefinedValidationWithoutRunAsUser := func(objs clientObjects, inp *input) error { expectedGwp := inp.defaultGwp.Spec.Kube Expect(objs).NotTo(BeEmpty()) - // Check we have Deployment, Envoy ConfigMap, ServiceAccount, Service, AI Stats ConfigMap + // Check we have Deployment, Envoy ConfigMap, ServiceAccount, Service, AIRoutePolicy Stats ConfigMap Expect(objs).To(HaveLen(5)) dep := objs.findDeployment(defaultNamespace, defaultDeploymentName) Expect(dep).ToNot(BeNil()) @@ -941,7 +941,7 @@ var _ = Describe("Deployer", func() { Expect(istioContainer.Resources.Requests.Cpu()).To(Equal(expectedGwp.Istio.IstioProxyContainer.Resources.Requests.Cpu())) // TODO: assert on istio args (e.g. log level, istio meta fields, etc) - // assert AI extension container + // assert AIRoutePolicy extension container expectedAIExtension := fmt.Sprintf("%s/%s", *expectedGwp.AiExtension.Image.Registry, *expectedGwp.AiExtension.Image.Repository, @@ -1211,7 +1211,7 @@ var _ = Describe("Deployer", func() { }, &expectedOutput{ validationFunc: fullyDefinedValidationFloatingUserId, }), - Entry("correct deployment with sds and AI extension enabled", &input{ + Entry("correct deployment with sds and AIRoutePolicy extension enabled", &input{ dInputs: istioEnabledDeployerInputs(), gw: defaultGatewayWithGatewayParams(gwpOverrideName), defaultGwp: defaultGatewayParams(), @@ -1219,7 +1219,7 @@ var _ = Describe("Deployer", func() { }, &expectedOutput{ validationFunc: aiAndSdsValidationFunc, }), - Entry("correct deployment with sds, AI extension, and floatinguUserId enabled", &input{ + Entry("correct deployment with sds, AIRoutePolicy extension, and floatinguUserId enabled", &input{ dInputs: istioEnabledDeployerInputs(), gw: defaultGatewayWithGatewayParams(gwpOverrideName), defaultGwp: defaultGatewayParams(), diff --git a/internal/kgateway/deployer/values.go b/internal/kgateway/deployer/values.go index c46bb028aad..23284eaf6d9 100644 --- a/internal/kgateway/deployer/values.go +++ b/internal/kgateway/deployer/values.go @@ -62,7 +62,7 @@ type helmGateway struct { // stats values Stats *helmStatsConfig `json:"stats,omitempty"` - // AI extension values + // AIRoutePolicy extension values AIExtension *helmAIExtension `json:"aiExtension,omitempty"` // AWS values diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 7ce2f5911e4..4ceec0bf85a 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -16,14 +16,21 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIPromptEnrichment": schema_kgateway_v2_api_v1alpha1_AIPromptEnrichment(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIPromptGuard": schema_kgateway_v2_api_v1alpha1_AIPromptGuard(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIRoutePolicy": schema_kgateway_v2_api_v1alpha1_AIRoutePolicy(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIUpstream": schema_kgateway_v2_api_v1alpha1_AIUpstream(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AccessLog": schema_kgateway_v2_api_v1alpha1_AccessLog(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AccessLogFilter": schema_kgateway_v2_api_v1alpha1_AccessLogFilter(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AiExtension": schema_kgateway_v2_api_v1alpha1_AiExtension(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AiExtensionStats": schema_kgateway_v2_api_v1alpha1_AiExtensionStats(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AnthropicConfig": schema_kgateway_v2_api_v1alpha1_AnthropicConfig(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AwsUpstream": schema_kgateway_v2_api_v1alpha1_AwsUpstream(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AzureOpenAIConfig": schema_kgateway_v2_api_v1alpha1_AzureOpenAIConfig(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.CELFilter": schema_kgateway_v2_api_v1alpha1_CELFilter(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ComparisonFilter": schema_kgateway_v2_api_v1alpha1_ComparisonFilter(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.CustomLabel": schema_kgateway_v2_api_v1alpha1_CustomLabel(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.CustomResponse": schema_kgateway_v2_api_v1alpha1_CustomResponse(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.DirectResponse": schema_kgateway_v2_api_v1alpha1_DirectResponse(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.DirectResponseList": schema_kgateway_v2_api_v1alpha1_DirectResponseList(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.DirectResponseSpec": schema_kgateway_v2_api_v1alpha1_DirectResponseSpec(ref), @@ -31,12 +38,14 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.DurationFilter": schema_kgateway_v2_api_v1alpha1_DurationFilter(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EnvoyBootstrap": schema_kgateway_v2_api_v1alpha1_EnvoyBootstrap(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.EnvoyContainer": schema_kgateway_v2_api_v1alpha1_EnvoyContainer(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.FieldDefault": schema_kgateway_v2_api_v1alpha1_FieldDefault(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.FileSink": schema_kgateway_v2_api_v1alpha1_FileSink(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.FilterType": schema_kgateway_v2_api_v1alpha1_FilterType(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GatewayParameters": schema_kgateway_v2_api_v1alpha1_GatewayParameters(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GatewayParametersList": schema_kgateway_v2_api_v1alpha1_GatewayParametersList(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GatewayParametersSpec": schema_kgateway_v2_api_v1alpha1_GatewayParametersSpec(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GatewayParametersStatus": schema_kgateway_v2_api_v1alpha1_GatewayParametersStatus(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GeminiConfig": schema_kgateway_v2_api_v1alpha1_GeminiConfig(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GracefulShutdownSpec": schema_kgateway_v2_api_v1alpha1_GracefulShutdownSpec(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GrpcService": schema_kgateway_v2_api_v1alpha1_GrpcService(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GrpcStatusFilter": schema_kgateway_v2_api_v1alpha1_GrpcStatusFilter(ref), @@ -49,14 +58,26 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.IstioContainer": schema_kgateway_v2_api_v1alpha1_IstioContainer(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.IstioIntegration": schema_kgateway_v2_api_v1alpha1_IstioIntegration(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.KubernetesProxyConfig": schema_kgateway_v2_api_v1alpha1_KubernetesProxyConfig(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LLMProviders": schema_kgateway_v2_api_v1alpha1_LLMProviders(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ListenerPolicy": schema_kgateway_v2_api_v1alpha1_ListenerPolicy(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ListenerPolicyList": schema_kgateway_v2_api_v1alpha1_ListenerPolicyList(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ListenerPolicySpec": schema_kgateway_v2_api_v1alpha1_ListenerPolicySpec(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LocalPolicyTargetReference": schema_kgateway_v2_api_v1alpha1_LocalPolicyTargetReference(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Message": schema_kgateway_v2_api_v1alpha1_Message(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.MistralConfig": schema_kgateway_v2_api_v1alpha1_MistralConfig(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Moderation": schema_kgateway_v2_api_v1alpha1_Moderation(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.MultiPoolConfig": schema_kgateway_v2_api_v1alpha1_MultiPoolConfig(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.OpenAIConfig": schema_kgateway_v2_api_v1alpha1_OpenAIConfig(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.OpenAIModeration": schema_kgateway_v2_api_v1alpha1_OpenAIModeration(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Pod": schema_kgateway_v2_api_v1alpha1_Pod(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PolicyAncestorStatus": schema_kgateway_v2_api_v1alpha1_PolicyAncestorStatus(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PolicyStatus": schema_kgateway_v2_api_v1alpha1_PolicyStatus(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Priority": schema_kgateway_v2_api_v1alpha1_Priority(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PromptguardRequest": schema_kgateway_v2_api_v1alpha1_PromptguardRequest(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PromptguardResponse": schema_kgateway_v2_api_v1alpha1_PromptguardResponse(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ProxyDeployment": schema_kgateway_v2_api_v1alpha1_ProxyDeployment(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Regex": schema_kgateway_v2_api_v1alpha1_Regex(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.RegexMatch": schema_kgateway_v2_api_v1alpha1_RegexMatch(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ResponseFlagFilter": schema_kgateway_v2_api_v1alpha1_ResponseFlagFilter(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.RoutePolicy": schema_kgateway_v2_api_v1alpha1_RoutePolicy(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.RoutePolicyList": schema_kgateway_v2_api_v1alpha1_RoutePolicyList(ref), @@ -66,6 +87,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SelfManagedGateway": schema_kgateway_v2_api_v1alpha1_SelfManagedGateway(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Service": schema_kgateway_v2_api_v1alpha1_Service(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.ServiceAccount": schema_kgateway_v2_api_v1alpha1_ServiceAccount(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken": schema_kgateway_v2_api_v1alpha1_SingleAuthToken(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StaticUpstream": schema_kgateway_v2_api_v1alpha1_StaticUpstream(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StatsConfig": schema_kgateway_v2_api_v1alpha1_StatsConfig(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StatusCodeFilter": schema_kgateway_v2_api_v1alpha1_StatusCodeFilter(ref), @@ -73,6 +95,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.UpstreamList": schema_kgateway_v2_api_v1alpha1_UpstreamList(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.UpstreamSpec": schema_kgateway_v2_api_v1alpha1_UpstreamSpec(ref), "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.UpstreamStatus": schema_kgateway_v2_api_v1alpha1_UpstreamStatus(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.VertexAIConfig": schema_kgateway_v2_api_v1alpha1_VertexAIConfig(ref), + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Webhook": schema_kgateway_v2_api_v1alpha1_Webhook(ref), "k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource": schema_k8sio_api_core_v1_AWSElasticBlockStoreVolumeSource(ref), "k8s.io/api/core/v1.Affinity": schema_k8sio_api_core_v1_Affinity(ref), "k8s.io/api/core/v1.AppArmorProfile": schema_k8sio_api_core_v1_AppArmorProfile(ref), @@ -424,6 +448,156 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA } } +func schema_kgateway_v2_api_v1alpha1_AIPromptEnrichment(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AIPromptEnrichment defines the config to enrich requests sent to the LLM provider by appending and prepending system prompts. This can be configured only for LLM providers that use the CHAT API type.\n\nPrompt enrichment allows you to add additional context to the prompt before sending it to the model. Unlike RAG or other dynamic context methods, prompt enrichment is static and is applied to every request.\n\n**Note**: Some providers, including Anthropic, do not support SYSTEM role messages, and instead have a dedicated system field in the input JSON. In this case, use the [`defaults` setting](#fielddefault) to set the system field.\n\nThe following example prepends a system prompt of `Answer all questions in French.` and appends `Describe the painting as if you were a famous art critic from the 17th century.` to each request that is sent to the `openai` HTTPRoute. ```yaml\n\n\tname: openai-opt\n\tnamespace: kgateway-system\n\nspec:\n\n\ttargetRefs:\n\t- group: gateway.networking.k8s.io\n\t kind: HTTPRoute\n\t name: openai\n\taiRoutePolicy:\n\t promptEnrichment:\n\t prepend:\n\t - role: SYSTEM\n\t content: \"Answer all questions in French.\"\n\t append:\n\t - role: USER\n\t content: \"Describe the painting as if you were a famous art critic from the 17th century.\"\n\n```", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "prepend": { + SchemaProps: spec.SchemaProps{ + Description: "A list of messages to be prepended to the prompt sent by the client.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Message"), + }, + }, + }, + }, + }, + "append": { + SchemaProps: spec.SchemaProps{ + Description: "A list of messages to be appended to the prompt sent by the client.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Message"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Message"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_AIPromptGuard(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AIPromptGuard configures a prompt guards to block unwanted requests to the LLM provider and mask sensitive data. Prompt guards can be used to reject requests based on the content of the prompt, as well as mask responses based on the content of the response.\n\nThis example rejects any request prompts that contain the string \"credit card\", and masks any credit card numbers in the response. ```yaml promptGuard:\n\n\trequest:\n\t customResponse:\n\t message: \"Rejected due to inappropriate content\"\n\t regex:\n\t action: REJECT\n\t matches:\n\t - pattern: \"credit card\"\n\t name: \"CC\"\n\tresponse:\n\t regex:\n\t builtins:\n\t - CREDIT_CARD\n\t action: MASK\n\n```", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "request": { + SchemaProps: spec.SchemaProps{ + Description: "Prompt guards to apply to requests sent by the client.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PromptguardRequest"), + }, + }, + "response": { + SchemaProps: spec.SchemaProps{ + Description: "Prompt guards to apply to responses returned by the LLM provider.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PromptguardResponse"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PromptguardRequest", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.PromptguardResponse"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_AIRoutePolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AIRoutePolicy config is used to configure the behavior of the LLM provider on the level of individual routes. These route settings, such as prompt enrichment, retrieval augmented generation (RAG), and semantic caching, are applicable only for routes that send requests to an LLM provider backend.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "promptEnrichment": { + SchemaProps: spec.SchemaProps{ + Description: "Enrich requests sent to the LLM provider by appending and prepending system prompts. This can be configured only for LLM providers that use the `CHAT` API route type.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIPromptEnrichment"), + }, + }, + "promptGuard": { + SchemaProps: spec.SchemaProps{ + Description: "Set up prompt guards to block unwanted requests to the LLM provider and mask sensitive data. Prompt guards can be used to reject requests based on the content of the prompt, as well as mask responses based on the content of the response.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIPromptGuard"), + }, + }, + "defaults": { + SchemaProps: spec.SchemaProps{ + Description: "Provide defaults to merge with user input fields. Defaults do _not_ override the user input fields, unless you explicitly set `override` to `true`.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.FieldDefault"), + }, + }, + }, + }, + }, + "routeType": { + SchemaProps: spec.SchemaProps{ + Description: "The type of route to the LLM provider API. Currently, `CHAT` and `CHAT_STREAMING` are supported.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIPromptEnrichment", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIPromptGuard", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.FieldDefault"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_AIUpstream(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "customHost": { + SchemaProps: spec.SchemaProps{ + Description: "Send requests to a custom host and port, such as to proxy the request, or to use a different backend that is API-compliant with the upstream version.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host"), + }, + }, + "llm": { + SchemaProps: spec.SchemaProps{ + Description: "The LLM configures the AIRoutePolicy gateway to use a single LLM provider backend.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LLMProviders"), + }, + }, + "multipool": { + SchemaProps: spec.SchemaProps{ + Description: "The MultiPool configures the backends for multiple hosts or models from the same provider in one Upstream resource.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.MultiPoolConfig"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LLMProviders", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.MultiPoolConfig"}, + } +} + func schema_kgateway_v2_api_v1alpha1_AccessLog(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -548,7 +722,7 @@ func schema_kgateway_v2_api_v1alpha1_AiExtension(ref common.ReferenceCallback) c return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "Configuration for the AI extension.", + Description: "Configuration for the AIRoutePolicy extension.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "enabled": { @@ -606,7 +780,7 @@ func schema_kgateway_v2_api_v1alpha1_AiExtension(ref common.ReferenceCallback) c }, "stats": { SchemaProps: spec.SchemaProps{ - Description: "Additional stats config for AI Extension. This config can be useful for adding custom labels to the request metrics.\n\nExample: ```yaml stats:\n customLabels:\n - name: \"subject\"\n metadataNamespace: \"envoy.filters.http.jwt_authn\"\n metadataKey: \"principal:sub\"\n - name: \"issuer\"\n metadataNamespace: \"envoy.filters.http.jwt_authn\"\n metadataKey: \"principal:iss\"\n```", + Description: "Additional stats config for AIRoutePolicy Extension. This config can be useful for adding custom labels to the request metrics.\n\nExample: ```yaml stats:\n customLabels:\n - name: \"subject\"\n metadataNamespace: \"envoy.filters.http.jwt_authn\"\n metadataKey: \"principal:sub\"\n - name: \"issuer\"\n metadataNamespace: \"envoy.filters.http.jwt_authn\"\n metadataKey: \"principal:iss\"\n```", Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AiExtensionStats"), }, }, @@ -626,7 +800,7 @@ func schema_kgateway_v2_api_v1alpha1_AiExtensionStats(ref common.ReferenceCallba Properties: map[string]spec.Schema{ "customLabels": { SchemaProps: spec.SchemaProps{ - Description: "Set of custom labels to be added to the request metrics. These will be added on each request which goes through the AI Extension.", + Description: "Set of custom labels to be added to the request metrics. These will be added on each request which goes through the AIRoutePolicy Extension.", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ @@ -645,6 +819,48 @@ func schema_kgateway_v2_api_v1alpha1_AiExtensionStats(ref common.ReferenceCallba } } +func schema_kgateway_v2_api_v1alpha1_AnthropicConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AnthropicConfig settings for the [Anthropic](https://docs.anthropic.com/en/release-notes/api) LLM provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "The authorization token that the AIRoutePolicy gateway uses to access the Anthropic API. This token is automatically sent in the `x-api-key` header of the request.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"), + }, + }, + "customHost": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Send requests to a custom host and port, such as to proxy the request, or to use a different backend that is API-compliant with the upstream version.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host"), + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: A version header to pass to the Anthropic API. For more information, see the [Anthropic API versioning docs](https://docs.anthropic.com/en/api/versioning).", + Type: []string{"string"}, + Format: "", + }, + }, + "model": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Override the model name. If unset, the model name is taken from the request. This setting can be useful when testing model failover scenarios.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"authToken"}, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"}, + } +} + func schema_kgateway_v2_api_v1alpha1_AwsUpstream(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -671,6 +887,52 @@ func schema_kgateway_v2_api_v1alpha1_AwsUpstream(ref common.ReferenceCallback) c } } +func schema_kgateway_v2_api_v1alpha1_AzureOpenAIConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "AzureOpenAIConfig settings for the [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/) LLM provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "The authorization token that the AIRoutePolicy gateway uses to access the Azure OpenAI API. This token is automatically sent in the `api-key` header of the request.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"), + }, + }, + "endpoint": { + SchemaProps: spec.SchemaProps{ + Description: "The endpoint for the Azure OpenAI API to use, such as `my-endpoint.openai.azure.com`. If the scheme is included, it is stripped.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "deploymentName": { + SchemaProps: spec.SchemaProps{ + Description: "The name of the Azure OpenAI model deployment to use. For more information, see the [Azure OpenAI model docs](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "The version of the Azure OpenAI API to use. For more information, see the [Azure OpenAI API version reference](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"authToken", "endpoint", "deploymentName", "apiVersion"}, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"}, + } +} + func schema_kgateway_v2_api_v1alpha1_CELFilter(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -762,6 +1024,33 @@ func schema_kgateway_v2_api_v1alpha1_CustomLabel(ref common.ReferenceCallback) c } } +func schema_kgateway_v2_api_v1alpha1_CustomResponse(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "CustomResponse configures a response to return to the client if request content is matched against a regex pattern and the action is `REJECT`.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A custom response message to return to the client. If not specified, defaults to \"The request was rejected due to inappropriate content\".", + Type: []string{"string"}, + Format: "", + }, + }, + "statusCode": { + SchemaProps: spec.SchemaProps{ + Description: "The status code to return to the client. Defaults to 403.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + } +} + func schema_kgateway_v2_api_v1alpha1_DirectResponse(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -998,6 +1287,40 @@ func schema_kgateway_v2_api_v1alpha1_EnvoyContainer(ref common.ReferenceCallback } } +func schema_kgateway_v2_api_v1alpha1_FieldDefault(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FieldDefault provides defaults to merge with user input fields. Defaults do _not_ override the user input fields, unless you explicitly set `override` to `true`.\n\nExample overriding the system field for Anthropic: ```yaml # Anthropic doesn't support a system chat type defaults:\n - field: \"system\"\n value: \"answer all questions in French\"\n\n```\n\nExample setting the temperature and overriding `max_tokens`: ```yaml defaults:\n - field: \"temperature\"\n value: \"0.5\"\n - field: \"max_tokens\"\n value: \"100\"\n\n```\n\nExample overriding custom list: ```yaml defaults:\n - field: \"custom_list\"\n value: \"[a,b,c]\"\n\n```", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "field": { + SchemaProps: spec.SchemaProps{ + Description: "The name of the field.", + Type: []string{"string"}, + Format: "", + }, + }, + "value": { + SchemaProps: spec.SchemaProps{ + Description: "The field default value, which can be any JSON Data Type.", + Type: []string{"string"}, + Format: "", + }, + }, + "override": { + SchemaProps: spec.SchemaProps{ + Description: "Whether to override the field's value if it already exists. Defaults to false.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + } +} + func schema_kgateway_v2_api_v1alpha1_FileSink(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1227,6 +1550,44 @@ func schema_kgateway_v2_api_v1alpha1_GatewayParametersStatus(ref common.Referenc } } +func schema_kgateway_v2_api_v1alpha1_GeminiConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GeminiConfig settings for the [Gemini](https://ai.google.dev/gemini-api/docs) LLM provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "The authorization token that the AIRoutePolicy gateway uses to access the Gemini API. This token is automatically sent in the `key` query parameter of the request.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"), + }, + }, + "model": { + SchemaProps: spec.SchemaProps{ + Description: "The Gemini model to use. For more information, see the [Gemini models docs](https://ai.google.dev/gemini-api/docs/models/gemini).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "The version of the Gemini API to use. For more information, see the [Gemini API version docs](https://ai.google.dev/gemini-api/docs/api-versions).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"authToken", "model", "apiVersion"}, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"}, + } +} + func schema_kgateway_v2_api_v1alpha1_GracefulShutdownSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1746,7 +2107,7 @@ func schema_kgateway_v2_api_v1alpha1_KubernetesProxyConfig(ref common.ReferenceC }, "aiExtension": { SchemaProps: spec.SchemaProps{ - Description: "Configuration for the AI extension.", + Description: "Configuration for the AIRoutePolicy extension.", Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AiExtension"), }, }, @@ -1765,16 +2126,61 @@ func schema_kgateway_v2_api_v1alpha1_KubernetesProxyConfig(ref common.ReferenceC } } -func schema_kgateway_v2_api_v1alpha1_ListenerPolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_kgateway_v2_api_v1alpha1_LLMProviders(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, + Description: "LLMProviders configures the AIRoutePolicy gateway to use a single LLM provider backend.", + Type: []string{"object"}, Properties: map[string]spec.Schema{ - "kind": { + "openai": { SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.OpenAIConfig"), + }, + }, + "azureopenai": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AzureOpenAIConfig"), + }, + }, + "anthropic": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AnthropicConfig"), + }, + }, + "gemini": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GeminiConfig"), + }, + }, + "vertexai": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.VertexAIConfig"), + }, + }, + "mistral": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.MistralConfig"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AnthropicConfig", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AzureOpenAIConfig", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.GeminiConfig", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.MistralConfig", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.OpenAIConfig", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.VertexAIConfig"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_ListenerPolicy(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, Format: "", }, }, @@ -1923,6 +2329,181 @@ func schema_kgateway_v2_api_v1alpha1_LocalPolicyTargetReference(ref common.Refer } } +func schema_kgateway_v2_api_v1alpha1_Message(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "An entry for a message to prepend or append to each prompt.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "role": { + SchemaProps: spec.SchemaProps{ + Description: "Role of the message. The available roles depend on the backend LLM provider model, such as `SYSTEM` or `USER` in the OpenAI API.", + Type: []string{"string"}, + Format: "", + }, + }, + "content": { + SchemaProps: spec.SchemaProps{ + Description: "String content of the message.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_kgateway_v2_api_v1alpha1_MistralConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MistralConfig configures the settings for the [Mistral AIRoutePolicy](https://docs.mistral.ai/getting-started/quickstart/) LLM provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "The authorization token that the AIRoutePolicy gateway uses to access the OpenAI API. This token is automatically sent in the `Authorization` header of the request and prefixed with `Bearer`.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"), + }, + }, + "customHost": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Send requests to a custom host and port, such as to proxy the request, or to use a different backend that is API-compliant with the upstream version.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host"), + }, + }, + "model": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Override the model name. If unset, the model name is taken from the request. This setting can be useful when testing model failover scenarios.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"authToken"}, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_Moderation(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Moderation configures an external moderation model endpoint. This endpoint evaluates request prompt data against predefined content rules to determine if the content adheres to those rules.\n\nAny requests routed through the AIRoutePolicy Gateway are processed by the specified moderation model. If the model identifies the content as harmful based on its rules, the request is automatically rejected.\n\nYou can configure a moderation endpoint either as a standalone prompt guard setting or alongside other request and response guard settings.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "openAIModeration": { + SchemaProps: spec.SchemaProps{ + Description: "Pass prompt data through an external moderation model endpoint, which compares the request prompt input to predefined content rules. Configure an OpenAI moderation endpoint.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.OpenAIModeration"), + }, + }, + }, + Required: []string{"openAIModeration"}, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.OpenAIModeration"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_MultiPoolConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MultiPoolConfig configures the backends for multiple hosts or models from the same provider in one Upstream resource. This method can be useful for creating one logical endpoint that is backed by multiple hosts or models.\n\nIn the `priorities` section, the order of `pool` entries defines the priority of the backend endpoints. The `pool` entries can either define a list of backends or a single backend. Note: Only two levels of nesting are permitted. Any nested entries after the second level are ignored.\n\n```yaml multi:\n\n\tpriorities:\n\t- pool:\n\t - azureOpenai:\n\t deploymentName: gpt-4o-mini\n\t apiVersion: 2024-02-15-preview\n\t endpoint: ai-gateway.openai.azure.com\n\t authToken:\n\t secretRef:\n\t name: azure-secret\n\t namespace: kgateway-system\n\t- pool:\n\t - azureOpenai:\n\t deploymentName: gpt-4o-mini-2\n\t apiVersion: 2024-02-15-preview\n\t endpoint: ai-gateway-2.openai.azure.com\n\t authToken:\n\t secretRef:\n\t name: azure-secret-2\n\t namespace: kgateway-system\n\n```", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "priorities": { + SchemaProps: spec.SchemaProps{ + Description: "The priority list of backend pools. Each entry represents a set of LLM provider backends. The order defines the priority of the backend endpoints.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Priority"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Priority"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_OpenAIConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "OpenAIConfig settings for the [OpenAI](https://platform.openai.com/docs/api-reference/streaming) LLM provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "The authorization token that the AIRoutePolicy gateway uses to access the OpenAI API. This token is automatically sent in the `Authorization` header of the request and prefixed with `Bearer`.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"), + }, + }, + "customHost": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Send requests to a custom host and port, such as to proxy the request, or to use a different backend that is API-compliant with the upstream version.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host"), + }, + }, + "model": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: Override the model name, such as `gpt-4o-mini`. If unset, the model name is taken from the request. This setting can be useful when setting up model failover within the same LLM provider.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_OpenAIModeration(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "OpenAIModeration configure an OpenAI moderation endpoint.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "model": { + SchemaProps: spec.SchemaProps{ + Description: "The name of the OpenAI moderation model to use. Defaults to [`omni-moderation-latest`](https://platform.openai.com/docs/guides/moderation).", + Type: []string{"string"}, + Format: "", + }, + }, + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "The authorization token that the AIRoutePolicy gateway uses to access the OpenAI moderation model.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"}, + } +} + func schema_kgateway_v2_api_v1alpha1_Pod(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2152,6 +2733,101 @@ func schema_kgateway_v2_api_v1alpha1_PolicyStatus(ref common.ReferenceCallback) } } +func schema_kgateway_v2_api_v1alpha1_Priority(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Priority configures the priority of the backend endpoints.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pool": { + SchemaProps: spec.SchemaProps{ + Description: "A list of LLM provider backends within a single endpoint pool entry.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LLMProviders"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LLMProviders"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_PromptguardRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PromptguardRequest defines the prompt guards to apply to requests sent by the client.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "customResponse": { + SchemaProps: spec.SchemaProps{ + Description: "A custom response message to return to the client. If not specified, defaults to \"The request was rejected due to inappropriate content\".", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.CustomResponse"), + }, + }, + "regex": { + SchemaProps: spec.SchemaProps{ + Description: "Regular expression (regex) matching for prompt guards and data masking.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Regex"), + }, + }, + "webhook": { + SchemaProps: spec.SchemaProps{ + Description: "Configure a webhook to forward requests to for prompt guarding.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Webhook"), + }, + }, + "moderation": { + SchemaProps: spec.SchemaProps{ + Description: "Pass prompt data through an external moderation model endpoint, which compares the request prompt input to predefined content rules.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Moderation"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.CustomResponse", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Moderation", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Regex", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Webhook"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_PromptguardResponse(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PromptguardResponse configures the response that the prompt guard applies to responses returned by the LLM provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "regex": { + SchemaProps: spec.SchemaProps{ + Description: "Regular expression (regex) matching for prompt guards and data masking.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Regex"), + }, + }, + "webhook": { + SchemaProps: spec.SchemaProps{ + Description: "Configure a webhook to forward responses to for prompt guarding.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Webhook"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Regex", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Webhook"}, + } +} + func schema_kgateway_v2_api_v1alpha1_ProxyDeployment(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2172,6 +2848,84 @@ func schema_kgateway_v2_api_v1alpha1_ProxyDeployment(ref common.ReferenceCallbac } } +func schema_kgateway_v2_api_v1alpha1_Regex(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Regex configures the regular expression (regex) matching for prompt guards and data masking.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matches": { + SchemaProps: spec.SchemaProps{ + Description: "A list of regex patterns to match against the request or response. Matches and built-ins are additive.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.RegexMatch"), + }, + }, + }, + }, + }, + "builtins": { + SchemaProps: spec.SchemaProps{ + Description: "A list of built-in regex patterns to match against the request or response. Matches and built-ins are additive.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "action": { + SchemaProps: spec.SchemaProps{ + Description: "The action to take if a regex pattern is matched in a request or response. This setting applies only to request matches. PromptguardResponse matches are always masked by default. Defaults to `MASK`.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.RegexMatch"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_RegexMatch(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "RegexMatch configures the regular expression (regex) matching for prompt guards and data masking.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pattern": { + SchemaProps: spec.SchemaProps{ + Description: "The regex pattern to match against the request or response.", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "An optional name for this match, which can be used for debugging purposes.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + func schema_kgateway_v2_api_v1alpha1_ResponseFlagFilter(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2312,11 +3066,16 @@ func schema_kgateway_v2_api_v1alpha1_RoutePolicySpec(ref common.ReferenceCallbac Format: "int32", }, }, + "ai": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIRoutePolicy"), + }, + }, }, }, }, Dependencies: []string{ - "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LocalPolicyTargetReference"}, + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIRoutePolicy", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.LocalPolicyTargetReference"}, } } @@ -2493,6 +3252,43 @@ func schema_kgateway_v2_api_v1alpha1_ServiceAccount(ref common.ReferenceCallback } } +func schema_kgateway_v2_api_v1alpha1_SingleAuthToken(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SingleAuthToken configures the authorization token that the AIRoutePolicy gateway uses to access the LLM provider API. This token is automatically sent in a request header, depending on the LLM provider.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind specifies which type of authorization token is being used. Must be one of: \"Inline\", \"SecretRef\", \"Passthrough\".", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "inline": { + SchemaProps: spec.SchemaProps{ + Description: "Provide the token directly in the configuration for the Upstream. This option is the least secure. Only use this option for quick tests such as trying out AIRoutePolicy Gateway.", + Type: []string{"string"}, + Format: "", + }, + }, + "secretRef": { + SchemaProps: spec.SchemaProps{ + Description: "Store the API key in a Kubernetes secret in the same namespace as the Upstream. Then, refer to the secret in the Upstream configuration. This option is more secure than an inline token, because the API key is encoded and you can restrict access to secrets through RBAC rules. You might use this option in proofs of concept, controlled development and staging environments, or well-controlled prod environments that use secrets.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"kind"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + func schema_kgateway_v2_api_v1alpha1_StaticUpstream(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -2697,11 +3493,16 @@ func schema_kgateway_v2_api_v1alpha1_UpstreamSpec(ref common.ReferenceCallback) Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StaticUpstream"), }, }, + "ai": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIUpstream"), + }, + }, }, }, }, Dependencies: []string{ - "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AwsUpstream", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StaticUpstream"}, + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AIUpstream", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.AwsUpstream", "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.StaticUpstream"}, } } @@ -2740,6 +3541,110 @@ func schema_kgateway_v2_api_v1alpha1_UpstreamStatus(ref common.ReferenceCallback } } +func schema_kgateway_v2_api_v1alpha1_VertexAIConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "VertexAIConfig settings for the [Vertex AIRoutePolicy](https://cloud.google.com/vertex-ai/docs) LLM provider. To find the values for the project ID, project location, and publisher, you can check the fields of an API request, such as `https://{LOCATION}-aiplatform.googleapis.com/{VERSION}/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/{PROVIDER}/`.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "authToken": { + SchemaProps: spec.SchemaProps{ + Description: "The authorization token that the AIRoutePolicy gateway uses to access the Vertex AIRoutePolicy API. This token is automatically sent in the `key` header of the request.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"), + }, + }, + "model": { + SchemaProps: spec.SchemaProps{ + Description: "The Vertex AIRoutePolicy model to use. For more information, see the [Vertex AIRoutePolicy model docs](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "The version of the Vertex AIRoutePolicy API to use. For more information, see the [Vertex AIRoutePolicy API reference](https://cloud.google.com/vertex-ai/docs/reference#versions).", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "projectId": { + SchemaProps: spec.SchemaProps{ + Description: "The ID of the Google Cloud Project that you use for the Vertex AIRoutePolicy.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "location": { + SchemaProps: spec.SchemaProps{ + Description: "The location of the Google Cloud Project that you use for the Vertex AIRoutePolicy.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "modelPath": { + SchemaProps: spec.SchemaProps{ + Description: "Optional: The model path to route to. Defaults to the Gemini model path, `generateContent`.", + Type: []string{"string"}, + Format: "", + }, + }, + "publisher": { + SchemaProps: spec.SchemaProps{ + Description: "The type of publisher model to use. Currently, only Google is supported.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"authToken", "model", "apiVersion", "projectId", "location"}, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.SingleAuthToken"}, + } +} + +func schema_kgateway_v2_api_v1alpha1_Webhook(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Webhook configures a webhook to forward requests or responses to for prompt guarding.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "host": { + SchemaProps: spec.SchemaProps{ + Description: "Host to send the traffic to.", + Ref: ref("github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host"), + }, + }, + "forwardHeaders": { + SchemaProps: spec.SchemaProps{ + Description: "ForwardHeaders define headers to forward with the request to the webhook.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/gateway-api/apis/v1.HTTPHeaderMatch"), + }, + }, + }, + }, + }, + }, + Required: []string{"host"}, + }, + }, + Dependencies: []string{ + "github.com/kgateway-dev/kgateway/v2/api/v1alpha1.Host", "sigs.k8s.io/gateway-api/apis/v1.HTTPHeaderMatch"}, + } +} + func schema_k8sio_api_core_v1_AWSElasticBlockStoreVolumeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{