Skip to content

Commit a5394c0

Browse files
committed
feat: implement decision-based routing with plugin architecture
This commit introduces a comprehensive decision-based routing system with a flexible plugin architecture, replacing the previous category-based approach. ## Core Changes ### 1. Decision-Based Architecture - Replaced Category-based routing with Decision-based routing - Decisions combine multiple rules (keyword, embedding, domain) using AND/OR operators - Added DecisionEngine for evaluating rule combinations and selecting optimal decisions - Support for priority and confidence-based decision selection strategies ### 2. Plugin System - Introduced flexible plugin architecture for Decision-level configurations - Supported plugin types: semantic-cache, jailbreak, pii, system_prompt - Each plugin has type-specific configuration stored as raw JSON - Helper methods for type-safe plugin configuration access ### 3. Model References - Renamed ModelScores to ModelRefs, removed score field - Currently supports single model per decision (maxItems: 1) - Simplified model selection logic based on decision priority ### 4. ## Core Changes ### 1. Decision-Based Architecture - Replaced Category-based routing with Decision-based routing - Decisions combine multiple rules (kete ### 1. Decisiatc- Replaced Category-based routinged- Decisions combine multiple rules (keyword, embedding, domapo- Added DecisionEngine for evaluating rule combinations and selecting optimal decisioh - Support for priority and confidence-based decision selection strategies ### 2. Plug a ### 2. Plugin System - Introduced flexible plugin architecture for Deci.go- Introduced flexibur- Supported plugin types: semantic-cache, jailbreak, pii, system_prompt - ch- Each plugin has type-specific configuration stored as raw JSON - Hel C- Helper methods for type-safe plugin configuration access ###s ### 3. Model References - Renamed ModelScores to ModelReute- Renamed ModelScores si- Currently supports single model per decision (maxItee - Simplified model selection logic based on decision priorira ### 4. ## Core Changes ### 1. Decision-Based Architecture: w## Cor C ### 1. Decisis i- Replaced Category-based routingrt- Decisions combine multiple rules (kete ### 1. Decisiatc- Rge### 1. Decisiatc- Replaced Category-bass ### 2. Plug a ### 2. Plugin System - Introduced flexible plugin architecture for Deci.go- Introduced flexibur- Supported plugin types: semantic-cache, jailbreak, pii, system_prompt - ch- Each plugin has type-specific configuration stored as raw JSON - Hel C- Helper methorra### 2. Plugiio- Introduced flexib: - ch- Each plugin has type-specific configuration stored as raw JSON - Hel C- Helper methods for type-safe plugin configuration access ###s ## ## Corst ### 1. Decisie p### 1. Decisis i- Replaced Category-based ross### 1. Decisiatc- Rge### 1. Decisiatc- Replaced Category-bass ### 2. Plug a ### 2. PluginEx ### 2. Plug a ### 2. Plugin System - Introduced flexible plXun### 2. Plugirs- Introduced git reset HEAD~1 git status --short cd /Users/bitliu/vs cd /Users/bitliu/vs/src/semantic-router && git status git checkout -b feat/decision-based-routing-with-plugins 2>&1 cd /Users/bitliu/vs bash -c cd Signed-off-by: bitliu <[email protected]>
1 parent c7b5934 commit a5394c0

File tree

9 files changed

+221
-175
lines changed

9 files changed

+221
-175
lines changed

src/semantic-router/pkg/apis/vllm.ai/v1alpha1/types_route.go

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import (
2222

2323
// IntelligentRouteSpec defines the desired state of IntelligentRoute
2424
type IntelligentRouteSpec struct {
25-
// Strategy defines how to select among multiple matching decisions
25+
// DecisionStrategy defines how to select among multiple matching decisions
2626
// +kubebuilder:validation:Required
2727
// +kubebuilder:validation:Enum=priority;confidence
2828
// +kubebuilder:default=priority
29-
Strategy DecisionStrategy `json:"strategy" yaml:"strategy"`
29+
DecisionStrategy DecisionStrategy `json:"decisionStrategy" yaml:"decisionStrategy"`
3030

3131
// KeywordRules defines keyword-based classification rules
3232
// +optional
@@ -38,10 +38,10 @@ type IntelligentRouteSpec struct {
3838
// +kubebuilder:validation:MaxItems=100
3939
EmbeddingRules []EmbeddingRule `json:"embeddingRules,omitempty" yaml:"embeddingRules,omitempty"`
4040

41-
// DomainRules defines domain-based classification rules
41+
// DomainRules defines MMLU domain categories for classification
4242
// +optional
43-
// +kubebuilder:validation:MaxItems=100
44-
DomainRules []DomainRule `json:"domainRules,omitempty" yaml:"domainRules,omitempty"`
43+
// +kubebuilder:validation:MaxItems=14
44+
DomainRules []string `json:"domainRules,omitempty" yaml:"domainRules,omitempty"`
4545

4646
// Decisions defines the routing decisions based on rule combinations
4747
// +kubebuilder:validation:Required
@@ -62,17 +62,12 @@ const (
6262

6363
// KeywordRule defines a keyword-based classification rule
6464
type KeywordRule struct {
65-
// Name is the unique identifier for this rule
65+
// Name is the unique identifier for this rule (also used as category name)
6666
// +kubebuilder:validation:Required
6767
// +kubebuilder:validation:MinLength=1
6868
// +kubebuilder:validation:MaxLength=100
6969
Name string `json:"name" yaml:"name"`
7070

71-
// Category is the category name generated by this rule
72-
// +optional
73-
// +kubebuilder:validation:MaxLength=100
74-
Category string `json:"category,omitempty" yaml:"category,omitempty"`
75-
7671
// Operator defines the logical operator for keywords (AND/OR)
7772
// +kubebuilder:validation:Required
7873
// +kubebuilder:validation:Enum=AND;OR
@@ -92,60 +87,29 @@ type KeywordRule struct {
9287

9388
// EmbeddingRule defines an embedding-based classification rule
9489
type EmbeddingRule struct {
95-
// Name is the unique identifier for this rule
90+
// Name is the unique identifier for this rule (also used as category name)
9691
// +kubebuilder:validation:Required
9792
// +kubebuilder:validation:MinLength=1
9893
// +kubebuilder:validation:MaxLength=100
9994
Name string `json:"name" yaml:"name"`
10095

101-
// Category is the category name generated by this rule
102-
// +optional
103-
// +kubebuilder:validation:MaxLength=100
104-
Category string `json:"category,omitempty" yaml:"category,omitempty"`
105-
10696
// Threshold is the similarity threshold for matching (0.0-1.0)
10797
// +kubebuilder:validation:Required
10898
// +kubebuilder:validation:Minimum=0
10999
// +kubebuilder:validation:Maximum=1
110100
Threshold float32 `json:"threshold" yaml:"threshold"`
111101

112-
// Keywords is the list of keywords to compute embeddings for
102+
// Candidates is the list of candidate phrases for semantic matching
113103
// +kubebuilder:validation:Required
114104
// +kubebuilder:validation:MinItems=1
115105
// +kubebuilder:validation:MaxItems=100
116-
Keywords []string `json:"keywords" yaml:"keywords"`
106+
Candidates []string `json:"candidates" yaml:"candidates"`
117107

118-
// AggregationMethod defines how to aggregate multiple keyword similarities
108+
// AggregationMethod defines how to aggregate multiple candidate similarities
119109
// +optional
120110
// +kubebuilder:validation:Enum=mean;max;any
121111
// +kubebuilder:default=max
122112
AggregationMethod string `json:"aggregationMethod,omitempty" yaml:"aggregationMethod,omitempty"`
123-
124-
// Model specifies the embedding model to use
125-
// +optional
126-
// +kubebuilder:validation:Enum=auto;qwen3;gemma
127-
// +kubebuilder:default=auto
128-
Model string `json:"model,omitempty" yaml:"model,omitempty"`
129-
130-
// Dimension specifies the target embedding dimension
131-
// +optional
132-
// +kubebuilder:validation:Enum=128;256;512;768;1024
133-
Dimension int `json:"dimension,omitempty" yaml:"dimension,omitempty"`
134-
}
135-
136-
// DomainRule defines a domain-based classification rule
137-
type DomainRule struct {
138-
// Name is the unique identifier for this rule
139-
// +kubebuilder:validation:Required
140-
// +kubebuilder:validation:MinLength=1
141-
// +kubebuilder:validation:MaxLength=100
142-
Name string `json:"name" yaml:"name"`
143-
144-
// Domains is the list of MMLU domain categories
145-
// +kubebuilder:validation:Required
146-
// +kubebuilder:validation:MinItems=1
147-
// +kubebuilder:validation:MaxItems=14
148-
Domains []string `json:"domains" yaml:"domains"`
149113
}
150114

151115
// Decision defines a routing decision based on rule combinations

src/semantic-router/pkg/apis/vllm.ai/v1alpha1/zz_generated.deepcopy.go

Lines changed: 4 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)