Skip to content

Commit 2df8461

Browse files
committed
feat: implement decision-based routing with plugin architecture
Signed-off-by: bitliu <[email protected]>
1 parent c7aa690 commit 2df8461

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/semantic-router/pkg/config/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package config
33
import (
44
"encoding/json"
55
"fmt"
6+
7+
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/observability/logging"
68
)
79

810
// ConfigSource defines where to load dynamic configuration from
@@ -609,7 +611,7 @@ func (d *Decision) GetSemanticCacheConfig() *SemanticCachePluginConfig {
609611

610612
result := &SemanticCachePluginConfig{}
611613
if err := unmarshalPluginConfig(config, result); err != nil {
612-
// Log error but return nil to maintain backward compatibility
614+
logging.Errorf("Failed to unmarshal semantic-cache config: %v", err)
613615
return nil
614616
}
615617
return result
@@ -624,6 +626,7 @@ func (d *Decision) GetJailbreakConfig() *JailbreakPluginConfig {
624626

625627
result := &JailbreakPluginConfig{}
626628
if err := unmarshalPluginConfig(config, result); err != nil {
629+
logging.Errorf("Failed to unmarshal jailbreak config: %v", err)
627630
return nil
628631
}
629632
return result
@@ -638,6 +641,7 @@ func (d *Decision) GetPIIConfig() *PIIPluginConfig {
638641

639642
result := &PIIPluginConfig{}
640643
if err := unmarshalPluginConfig(config, result); err != nil {
644+
logging.Errorf("Failed to unmarshal pii config: %v", err)
641645
return nil
642646
}
643647
return result
@@ -652,6 +656,7 @@ func (d *Decision) GetSystemPromptConfig() *SystemPromptPluginConfig {
652656

653657
result := &SystemPromptPluginConfig{}
654658
if err := unmarshalPluginConfig(config, result); err != nil {
659+
logging.Errorf("Failed to unmarshal system_prompt config: %v", err)
655660
return nil
656661
}
657662
return result
@@ -666,6 +671,7 @@ func (d *Decision) GetHeaderMutationConfig() *HeaderMutationPluginConfig {
666671

667672
result := &HeaderMutationPluginConfig{}
668673
if err := unmarshalPluginConfig(config, result); err != nil {
674+
logging.Errorf("Failed to unmarshal header_mutation config: %v", err)
669675
return nil
670676
}
671677
return result

src/semantic-router/pkg/utils/pii/policy.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ func NewPolicyChecker(cfg *config.RouterConfig) *PolicyChecker {
4444

4545
// CheckPolicy checks if the detected PII types are allowed for the given decision
4646
func (pc *PolicyChecker) CheckPolicy(decisionName string, detectedPII []string) (bool, []string, error) {
47+
if !pc.IsPIIEnabled(decisionName) {
48+
logging.Infof("PII detection is disabled for decision %s, allowing request", decisionName)
49+
return true, nil, nil
50+
}
51+
4752
decision := pc.Config.GetDecisionByName(decisionName)
4853
if decision == nil {
4954
logging.Infof("Decision %s not found, allowing request", decisionName)
5055
return true, nil, nil
5156
}
5257

53-
// Get PII policy for this decision
54-
// GetDecisionPIIPolicy returns a default policy (AllowByDefault: true) if no PII config exists
5558
policy := decision.GetDecisionPIIPolicy()
5659
var deniedPII []string
5760

0 commit comments

Comments
 (0)