@@ -47,8 +47,9 @@ const (
47
47
modelIdentifier = "model.aibrix.ai/name"
48
48
modelPortIdentifier = "model.aibrix.ai/port"
49
49
modelSupportedRoutesIdentifier = "model.aibrix.ai/supported-routes"
50
- modelEmbeddingsRoute = "embeddings"
51
- modelChatCompletionsRoute = "chat-completions"
50
+ modelRouteEmbeddings = "embeddings"
51
+ modelRouteChatCompletions = "chat-completions"
52
+ modelRouteDefault = modelRouteChatCompletions
52
53
// TODO (varun): parameterize it or dynamically resolve it
53
54
aibrixEnvoyGateway = "aibrix-eg"
54
55
aibrixEnvoyGatewayNamespace = "aibrix-system"
@@ -112,25 +113,26 @@ func Add(mgr manager.Manager, runtimeConfig config.RuntimeConfig) error {
112
113
return err
113
114
}
114
115
116
+ // getSupportedRoutesMatchFromLabelsOrDefault returns the HTTPRouteMatch based on the model route labels value
115
117
func getSupportedRoutesMatchFromLabelsOrDefault (labels map [string ]string , modelHeaderMatch gatewayv1.HTTPHeaderMatch ) []gatewayv1.HTTPRouteMatch {
116
- nameToRoutePathPrefix := map [string ][]string {
117
- modelEmbeddingsRoute : {"/v1/embeddings" },
118
- modelChatCompletionsRoute : {"/v1/completions" , "/v1/chat/completions" },
118
+ labelValueToRoutePathPrefix := map [string ][]string {
119
+ modelRouteEmbeddings : {"/v1/embeddings" },
120
+ modelRouteChatCompletions : {"/v1/completions" , "/v1/chat/completions" },
119
121
}
120
122
121
123
var pathPrefixes []string
122
124
if routesLabelValue , ok := labels [modelSupportedRoutesIdentifier ]; ok {
123
125
routes := strings .Split (routesLabelValue , "," )
124
- for k , route := range nameToRoutePathPrefix {
126
+ for k , route := range labelValueToRoutePathPrefix {
125
127
if slices .Contains (routes , k ) {
126
128
pathPrefixes = append (pathPrefixes , route ... )
127
129
}
128
130
}
129
131
}
130
132
131
- // completions and chat completions routes by default
133
+ // Add the default pathPrefixes if no route defines via labels
132
134
if len (pathPrefixes ) == 0 {
133
- pathPrefixes = append (pathPrefixes , nameToRoutePathPrefix [ modelChatCompletionsRoute ]... )
135
+ pathPrefixes = append (pathPrefixes , labelValueToRoutePathPrefix [ modelRouteDefault ]... )
134
136
}
135
137
136
138
var routesmatch []gatewayv1.HTTPRouteMatch
0 commit comments