@@ -37,26 +37,34 @@ import (
37
37
modelv1alpha1 "github.com/vllm-project/aibrix/api/model/v1alpha1"
38
38
orchestrationv1alpha1 "github.com/vllm-project/aibrix/api/orchestration/v1alpha1"
39
39
"github.com/vllm-project/aibrix/pkg/config"
40
+ aibrixgateway "github.com/vllm-project/aibrix/pkg/plugins/gateway"
40
41
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
41
42
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
42
43
)
43
44
44
45
const (
45
46
// TODO (varun): cleanup model related identifiers and establish common consensus
46
- modelHeaderIdentifier = "model"
47
- modelIdentifier = "model.aibrix.ai/name"
48
- modelPortIdentifier = "model.aibrix.ai/port"
49
- modelSupportedRoutesIdentifier = "model.aibrix.ai/supported-routes"
50
- modelRouteEmbeddings = "embeddings"
51
- modelRouteChatCompletions = "chat-completions"
52
- modelRouteDefault = modelRouteChatCompletions
47
+ modelHeaderIdentifier = "model"
48
+ modelIdentifier = "model.aibrix.ai/name"
49
+ modelPortIdentifier = "model.aibrix.ai/port"
50
+ modelSupportedRequestTypeIdentifier = "model.aibrix.ai/supported-request-types"
53
51
// TODO (varun): parameterize it or dynamically resolve it
54
52
aibrixEnvoyGateway = "aibrix-eg"
55
53
aibrixEnvoyGatewayNamespace = "aibrix-system"
56
54
57
55
defaultModelServingPort = 8000
58
56
)
59
57
58
+ var (
59
+ requestTypeIdentifierToSupportedRoutePathPrefix = map [string ][]string {
60
+ string (aibrixgateway .OpenAiRequestEmbeddingsType ): {string (aibrixgateway .OpenAiRequestEmbeddingsPath )},
61
+ string (aibrixgateway .OpenAiRequestChatCompletionsType ): {string (aibrixgateway .OpenAiRequestCompletionsPath ), string (aibrixgateway .OpenAiRequestChatCompletionsPath )},
62
+ string (aibrixgateway .OpenAiRequestCompletionsType ): {string (aibrixgateway .OpenAiRequestCompletionsPath ), string (aibrixgateway .OpenAiRequestChatCompletionsPath )},
63
+ }
64
+
65
+ defaultSupportedRequestType = string (aibrixgateway .OpenAiRequestChatCompletionsType )
66
+ )
67
+
60
68
//+kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
61
69
//+kubebuilder:rbac:groups=orchestration.aibrix.ai,resources=rayclusterfleets,verbs=get;list;watch;create;update;patch;delete
62
70
//+kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=httproutes,verbs=get;list;watch;create;update;patch;delete
@@ -115,24 +123,19 @@ func Add(mgr manager.Manager, runtimeConfig config.RuntimeConfig) error {
115
123
116
124
// getSupportedRoutesMatchFromLabelsOrDefault returns the HTTPRouteMatch based on the model route labels value
117
125
func getSupportedRoutesMatchFromLabelsOrDefault (labels map [string ]string , modelHeaderMatch gatewayv1.HTTPHeaderMatch ) []gatewayv1.HTTPRouteMatch {
118
- labelValueToRoutePathPrefix := map [string ][]string {
119
- modelRouteEmbeddings : {"/v1/embeddings" },
120
- modelRouteChatCompletions : {"/v1/completions" , "/v1/chat/completions" },
121
- }
122
-
123
126
var pathPrefixes []string
124
- if routesLabelValue , ok := labels [modelSupportedRoutesIdentifier ]; ok {
125
- routes := strings .Split (routesLabelValue , "," )
126
- for k , route := range labelValueToRoutePathPrefix {
127
- if slices .Contains (routes , k ) {
128
- pathPrefixes = append (pathPrefixes , route ... )
127
+ if routesLabelValue , ok := labels [modelSupportedRequestTypeIdentifier ]; ok {
128
+ routesIdentifier := strings .Split (routesLabelValue , "," )
129
+ for id , paths := range requestTypeIdentifierToSupportedRoutePathPrefix {
130
+ if slices .Contains (routesIdentifier , id ) {
131
+ pathPrefixes = append (pathPrefixes , paths ... )
129
132
}
130
133
}
131
134
}
132
135
133
136
// Add the default pathPrefixes if no route defines via labels
134
137
if len (pathPrefixes ) == 0 {
135
- pathPrefixes = append (pathPrefixes , labelValueToRoutePathPrefix [ modelRouteDefault ]... )
138
+ pathPrefixes = append (pathPrefixes , requestTypeIdentifierToSupportedRoutePathPrefix [ defaultSupportedRequestType ]... )
136
139
}
137
140
138
141
var routesmatch []gatewayv1.HTTPRouteMatch
0 commit comments