Skip to content

Commit 82cbd16

Browse files
committed
address review comment
Signed-off-by: Huamin Chen <[email protected]>
1 parent c4c3f82 commit 82cbd16

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ func ReplaceGlobalConfig(newCfg *RouterConfig) {
418418

419419
// GetConfig returns the current configuration
420420
func GetConfig() *RouterConfig {
421+
configMu.RLock()
422+
defer configMu.RUnlock()
421423
return config
422424
}
423425

src/semantic-router/pkg/extproc/request_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ func (r *OpenAIRouter) handleModelRouting(openAIRequest *openai.ChatCompletionNe
623623
observability.Infof("Added category-specific system prompt for category: %s (mode: %s)", categoryName, mode)
624624
}
625625

626-
// Log the complete message structure after system prompt injection
627-
observability.Infof("Complete request body after system prompt injection: %s", string(modifiedBody))
626+
// Log metadata about system prompt injection (avoid logging sensitive user data)
627+
observability.Infof("System prompt injection completed for category: %s, body size: %d bytes", categoryName, len(modifiedBody))
628628
} else if category != nil && category.SystemPrompt != "" && !category.IsSystemPromptEnabled() {
629629
observability.Infof("System prompt disabled for category: %s", categoryName)
630630
}

src/semantic-router/pkg/services/classification.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package services
33
import (
44
"fmt"
55
"os"
6+
"sync"
67
"time"
78

89
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/config"
@@ -18,6 +19,7 @@ type ClassificationService struct {
1819
classifier *classification.Classifier
1920
unifiedClassifier *classification.UnifiedClassifier // New unified classifier
2021
config *config.RouterConfig
22+
configMutex sync.RWMutex // Protects config access
2123
}
2224

2325
// NewClassificationService creates a new classification service
@@ -488,11 +490,15 @@ func (s *ClassificationService) GetUnifiedClassifierStats() map[string]interface
488490

489491
// GetConfig returns the current configuration
490492
func (s *ClassificationService) GetConfig() *config.RouterConfig {
493+
s.configMutex.RLock()
494+
defer s.configMutex.RUnlock()
491495
return s.config
492496
}
493497

494498
// UpdateConfig updates the configuration
495499
func (s *ClassificationService) UpdateConfig(newConfig *config.RouterConfig) {
500+
s.configMutex.Lock()
501+
defer s.configMutex.Unlock()
496502
s.config = newConfig
497503
// Update the global config as well
498504
config.ReplaceGlobalConfig(newConfig)

0 commit comments

Comments
 (0)