@@ -66,14 +66,14 @@ func (r *OpenAIRouter) handleRequestBody(v *ext_proc.ProcessingRequest_RequestBo
6666
6767 // Perform decision evaluation and model selection once at the beginning
6868 // Use decision-based routing if decisions are configured, otherwise fall back to category-based
69- categoryName , classificationConfidence , reasoningDecision , selectedModel := r .performDecisionEvaluationAndModelSelection (originalModel , userContent , nonUserMessages , ctx )
69+ decisionName , classificationConfidence , reasoningDecision , selectedModel := r .performDecisionEvaluationAndModelSelection (originalModel , userContent , nonUserMessages , ctx )
7070
71- // Perform security checks with category -specific settings
72- if response , shouldReturn := r .performSecurityChecks (ctx , userContent , nonUserMessages , categoryName ); shouldReturn {
71+ // Perform security checks with decision -specific settings
72+ if response , shouldReturn := r .performSecurityChecks (ctx , userContent , nonUserMessages , decisionName ); shouldReturn {
7373 return response , nil
7474 }
7575
76- // Perform PII detection and policy check (if PII policy is enabled for the category )
76+ // Perform PII detection and policy check (if PII policy is enabled for the decision )
7777 // For auto models: this may modify selectedModel if the initially selected model violates PII policy
7878 // For non-auto models: this checks if the specified model passes PII policy
7979 isAutoModel := r .Config != nil && r .Config .IsAutoModelName (originalModel )
@@ -83,7 +83,7 @@ func (r *OpenAIRouter) handleRequestBody(v *ext_proc.ProcessingRequest_RequestBo
8383 modelToCheck = originalModel
8484 }
8585
86- allowedModel , piiResponse := r .performPIIDetection (ctx , userContent , nonUserMessages , categoryName , modelToCheck , isAutoModel )
86+ allowedModel , piiResponse := r .performPIIDetection (ctx , userContent , nonUserMessages , decisionName , modelToCheck , isAutoModel )
8787 if piiResponse != nil {
8888 // PII policy violation - return error response
8989 return piiResponse , nil
@@ -93,18 +93,18 @@ func (r *OpenAIRouter) handleRequestBody(v *ext_proc.ProcessingRequest_RequestBo
9393 selectedModel = allowedModel
9494 }
9595
96- // Handle caching with category -specific settings
97- if response , shouldReturn := r .handleCaching (ctx , categoryName ); shouldReturn {
96+ // Handle caching with decision -specific settings
97+ if response , shouldReturn := r .handleCaching (ctx , decisionName ); shouldReturn {
9898 return response , nil
9999 }
100100
101101 // Handle model selection and routing with pre-computed classification results and selected model
102- return r .handleModelRouting (openAIRequest , originalModel , categoryName , classificationConfidence , reasoningDecision , selectedModel , ctx )
102+ return r .handleModelRouting (openAIRequest , originalModel , decisionName , classificationConfidence , reasoningDecision , selectedModel , ctx )
103103}
104104
105105// handleModelRouting handles model selection and routing logic
106- // categoryName , classificationConfidence, reasoningDecision, and selectedModel are pre-computed from ProcessRequest
107- func (r * OpenAIRouter ) handleModelRouting (openAIRequest * openai.ChatCompletionNewParams , originalModel string , categoryName string , classificationConfidence float64 , reasoningDecision entropy.ReasoningDecision , selectedModel string , ctx * RequestContext ) (* ext_proc.ProcessingResponse , error ) {
106+ // decisionName , classificationConfidence, reasoningDecision, and selectedModel are pre-computed from ProcessRequest
107+ func (r * OpenAIRouter ) handleModelRouting (openAIRequest * openai.ChatCompletionNewParams , originalModel string , decisionName string , classificationConfidence float64 , reasoningDecision entropy.ReasoningDecision , selectedModel string , ctx * RequestContext ) (* ext_proc.ProcessingResponse , error ) {
108108 response := & ext_proc.ProcessingResponse {
109109 Response : & ext_proc.ProcessingResponse_RequestBody {
110110 RequestBody : & ext_proc.BodyResponse {
@@ -118,7 +118,7 @@ func (r *OpenAIRouter) handleModelRouting(openAIRequest *openai.ChatCompletionNe
118118 isAutoModel := r .Config != nil && r .Config .IsAutoModelName (originalModel )
119119
120120 if isAutoModel && selectedModel != "" {
121- return r .handleAutoModelRouting (openAIRequest , originalModel , categoryName , reasoningDecision , selectedModel , ctx , response )
121+ return r .handleAutoModelRouting (openAIRequest , originalModel , decisionName , reasoningDecision , selectedModel , ctx , response )
122122 } else if ! isAutoModel {
123123 return r .handleSpecifiedModelRouting (openAIRequest , originalModel , ctx )
124124 }
@@ -129,9 +129,9 @@ func (r *OpenAIRouter) handleModelRouting(openAIRequest *openai.ChatCompletionNe
129129}
130130
131131// handleAutoModelRouting handles routing for auto model selection
132- func (r * OpenAIRouter ) handleAutoModelRouting (openAIRequest * openai.ChatCompletionNewParams , originalModel string , categoryName string , reasoningDecision entropy.ReasoningDecision , selectedModel string , ctx * RequestContext , response * ext_proc.ProcessingResponse ) (* ext_proc.ProcessingResponse , error ) {
133- logging .Infof ("Using Auto Model Selection (model=%s), category =%s, selected=%s" ,
134- originalModel , categoryName , selectedModel )
132+ func (r * OpenAIRouter ) handleAutoModelRouting (openAIRequest * openai.ChatCompletionNewParams , originalModel string , decisionName string , reasoningDecision entropy.ReasoningDecision , selectedModel string , ctx * RequestContext , response * ext_proc.ProcessingResponse ) (* ext_proc.ProcessingResponse , error ) {
133+ logging .Infof ("Using Auto Model Selection (model=%s), decision =%s, selected=%s" ,
134+ originalModel , decisionName , selectedModel )
135135
136136 matchedModel := selectedModel
137137
@@ -142,10 +142,10 @@ func (r *OpenAIRouter) handleAutoModelRouting(openAIRequest *openai.ChatCompleti
142142 }
143143
144144 // Record routing decision with tracing
145- r .recordRoutingDecision (ctx , categoryName , originalModel , matchedModel , reasoningDecision )
145+ r .recordRoutingDecision (ctx , decisionName , originalModel , matchedModel , reasoningDecision )
146146
147147 // Track VSR decision information
148- r .trackVSRDecision (ctx , categoryName , matchedModel , reasoningDecision .UseReasoning )
148+ r .trackVSRDecision (ctx , decisionName , matchedModel , reasoningDecision .UseReasoning )
149149
150150 // Track model routing metrics
151151 metrics .RecordModelRouting (originalModel , matchedModel )
@@ -154,7 +154,7 @@ func (r *OpenAIRouter) handleAutoModelRouting(openAIRequest *openai.ChatCompleti
154154 selectedEndpoint := r .selectEndpointForModel (ctx , matchedModel )
155155
156156 // Modify request body with new model, reasoning mode, and system prompt
157- modifiedBody , err := r .modifyRequestBodyForAutoRouting (openAIRequest , matchedModel , categoryName , reasoningDecision .UseReasoning , ctx )
157+ modifiedBody , err := r .modifyRequestBodyForAutoRouting (openAIRequest , matchedModel , decisionName , reasoningDecision .UseReasoning , ctx )
158158 if err != nil {
159159 return nil , err
160160 }
@@ -163,7 +163,7 @@ func (r *OpenAIRouter) handleAutoModelRouting(openAIRequest *openai.ChatCompleti
163163 response = r .createRoutingResponse (matchedModel , selectedEndpoint , modifiedBody , ctx )
164164
165165 // Log routing decision
166- r .logRoutingDecision (ctx , "auto_routing" , originalModel , matchedModel , categoryName , reasoningDecision .UseReasoning , selectedEndpoint )
166+ r .logRoutingDecision (ctx , "auto_routing" , originalModel , matchedModel , decisionName , reasoningDecision .UseReasoning , selectedEndpoint )
167167
168168 // Handle route cache clearing
169169 if r .shouldClearRouteCache () {
@@ -242,7 +242,7 @@ func (r *OpenAIRouter) selectEndpointForModel(ctx *RequestContext, model string)
242242}
243243
244244// modifyRequestBodyForAutoRouting modifies the request body for auto routing
245- func (r * OpenAIRouter ) modifyRequestBodyForAutoRouting (openAIRequest * openai.ChatCompletionNewParams , matchedModel string , categoryName string , useReasoning bool , ctx * RequestContext ) ([]byte , error ) {
245+ func (r * OpenAIRouter ) modifyRequestBodyForAutoRouting (openAIRequest * openai.ChatCompletionNewParams , matchedModel string , decisionName string , useReasoning bool , ctx * RequestContext ) ([]byte , error ) {
246246 // Modify the model in the request
247247 openAIRequest .Model = matchedModel
248248
@@ -254,19 +254,19 @@ func (r *OpenAIRouter) modifyRequestBodyForAutoRouting(openAIRequest *openai.Cha
254254 return nil , status .Errorf (codes .Internal , "error serializing modified request: %v" , err )
255255 }
256256
257- if categoryName == "" {
257+ if decisionName == "" {
258258 return modifiedBody , nil
259259 }
260260 // Set reasoning mode
261- modifiedBody , err = r .setReasoningModeToRequestBody (modifiedBody , useReasoning , categoryName )
261+ modifiedBody , err = r .setReasoningModeToRequestBody (modifiedBody , useReasoning , decisionName )
262262 if err != nil {
263263 logging .Errorf ("Error setting reasoning mode %v to request: %v" , useReasoning , err )
264264 metrics .RecordRequestError (matchedModel , "serialization_error" )
265265 return nil , status .Errorf (codes .Internal , "error setting reasoning mode: %v" , err )
266266 }
267267
268- // Add category -specific system prompt if configured
269- modifiedBody , err = r .addSystemPromptIfConfigured (modifiedBody , categoryName , matchedModel , ctx )
268+ // Add decision -specific system prompt if configured
269+ modifiedBody , err = r .addSystemPromptIfConfigured (modifiedBody , decisionName , matchedModel , ctx )
270270 if err != nil {
271271 return nil , err
272272 }
0 commit comments