Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ classifier:
threshold: 0.7
use_cpu: true
pii_mapping_path: "models/pii_classifier_modernbert-base_presidio_token_model/pii_type_mapping.json"
load_aware: false
categories:
- name: business
use_reasoning: false
Expand Down
1 change: 0 additions & 1 deletion deploy/kubernetes/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ classifier:
threshold: 0.7
use_cpu: true
pii_mapping_path: "models/pii_classifier_modernbert-base_presidio_token_model/pii_type_mapping.json"
load_aware: false
categories:
- name: business
model_scores:
Expand Down
1 change: 0 additions & 1 deletion src/semantic-router/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type RouterConfig struct {
UseCPU bool `yaml:"use_cpu"`
PIIMappingPath string `yaml:"pii_mapping_path"`
} `yaml:"pii_model"`
LoadAware bool `yaml:"load_aware"`
} `yaml:"classifier"`

// Categories for routing queries
Expand Down
2 changes: 0 additions & 2 deletions src/semantic-router/pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ classifier:
use_cpu: true
use_modernbert: false
pii_mapping_path: "/path/to/pii.json"
load_aware: true
categories:
- name: "general"
Expand Down Expand Up @@ -138,7 +137,6 @@ tools:
// Verify classifier config
Expect(cfg.Classifier.CategoryModel.ModelID).To(Equal("test-category-model"))
Expect(cfg.Classifier.CategoryModel.UseModernBERT).To(BeTrue())
Expect(cfg.Classifier.LoadAware).To(BeTrue())

// Verify categories
Expect(cfg.Categories).To(HaveLen(1))
Expand Down
3 changes: 0 additions & 3 deletions src/semantic-router/pkg/extproc/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,6 @@ func (r *OpenAIRouter) handleModelRouting(openAIRequest *openai.ChatCompletionNe
effortForMetrics := r.getReasoningEffort(categoryName)
metrics.RecordReasoningDecision(categoryName, matchedModel, useReasoning, effortForMetrics)

// Track the model load for the selected model
r.Classifier.IncrementModelLoad(matchedModel)

// Track the model routing change
metrics.RecordModelRouting(originalModel, matchedModel)

Expand Down
1 change: 0 additions & 1 deletion src/semantic-router/pkg/extproc/response_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func (r *OpenAIRouter) handleResponseBody(v *ext_proc.ProcessingRequest_Response
float64(completionTokens),
)
metrics.RecordModelCompletionLatency(ctx.RequestModel, completionLatency.Seconds())
r.Classifier.DecrementModelLoad(ctx.RequestModel)

// Compute and record cost if pricing is configured
if r.Config != nil {
Expand Down
3 changes: 1 addition & 2 deletions src/semantic-router/pkg/extproc/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ func NewOpenAIRouter(configPath string) (*OpenAIRouter, error) {

// Create utility components
piiChecker := pii.NewPolicyChecker(cfg, cfg.ModelConfig)
modelTTFT := make(map[string]float64) // Empty TTFT map since load balancing is disabled
classifier := classification.NewClassifier(cfg, categoryMapping, piiMapping, jailbreakMapping, modelTTFT)
classifier := classification.NewClassifier(cfg, categoryMapping, piiMapping, jailbreakMapping)

// Create global classification service for API access
services.NewClassificationService(classifier, cfg)
Expand Down
8 changes: 4 additions & 4 deletions src/semantic-router/pkg/extproc/security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = Describe("Security Checks", func() {
},
}
router.PIIChecker = pii.NewPolicyChecker(cfg, cfg.ModelConfig)
router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, router.Classifier.PIIMapping, nil, router.Classifier.ModelTTFT)
router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, router.Classifier.PIIMapping, nil)
})

It("should allow requests with no PII", func() {
Expand Down Expand Up @@ -97,7 +97,7 @@ var _ = Describe("Security Checks", func() {
piiMapping, err := classification.LoadPIIMapping(cfg.Classifier.PIIModel.PIIMappingPath)
Expect(err).NotTo(HaveOccurred())

router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, piiMapping, nil, router.Classifier.ModelTTFT)
router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, piiMapping, nil)
})

Describe("ClassifyPII method", func() {
Expand Down Expand Up @@ -339,7 +339,7 @@ var _ = Describe("Security Checks", func() {
piiMapping, err := classification.LoadPIIMapping(cfg.Classifier.PIIModel.PIIMappingPath)
Expect(err).NotTo(HaveOccurred())

router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, piiMapping, nil, router.Classifier.ModelTTFT)
router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, piiMapping, nil)
})

Describe("Error handling and edge cases", func() {
Expand Down Expand Up @@ -524,7 +524,7 @@ var _ = Describe("Security Checks", func() {
IdxToLabel: map[string]string{"0": "benign", "1": "jailbreak"},
}

router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, router.Classifier.PIIMapping, jailbreakMapping, router.Classifier.ModelTTFT)
router.Classifier = classification.NewClassifier(cfg, router.Classifier.CategoryMapping, router.Classifier.PIIMapping, jailbreakMapping)
})

It("should process potential jailbreak attempts", func() {
Expand Down
8 changes: 1 addition & 7 deletions src/semantic-router/pkg/extproc/test_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func CreateTestConfig() *config.RouterConfig {
UseCPU bool `yaml:"use_cpu"`
PIIMappingPath string `yaml:"pii_mapping_path"`
} `yaml:"pii_model"`
LoadAware bool `yaml:"load_aware"`
}{
CategoryModel: struct {
ModelID string `yaml:"model_id"`
Expand All @@ -119,7 +118,6 @@ func CreateTestConfig() *config.RouterConfig {
UseCPU: true,
PIIMappingPath: "../../../../models/pii_classifier_modernbert-base_presidio_token_model/pii_type_mapping.json",
},
LoadAware: true,
},
Categories: []config.Category{
{
Expand Down Expand Up @@ -220,11 +218,7 @@ func CreateTestRouter(cfg *config.RouterConfig) (*extproc.OpenAIRouter, error) {
toolsDatabase := tools.NewToolsDatabase(toolsOptions)

// Create classifier
modelTTFT := map[string]float64{
"model-a": 2.5,
"model-b": 1.8,
}
classifier := classification.NewClassifier(cfg, categoryMapping, piiMapping, nil, modelTTFT)
classifier := classification.NewClassifier(cfg, categoryMapping, piiMapping, nil)

// Create PII checker
piiChecker := pii.NewPolicyChecker(cfg, cfg.ModelConfig)
Expand Down
Loading
Loading