From c2042c5fa04372c571db2bcc002a0d02b7102378 Mon Sep 17 00:00:00 2001 From: Yossi Ovadia Date: Thu, 2 Oct 2025 10:06:38 -0700 Subject: [PATCH] fix: use unified classifier in intent classification API when available The Classification API's /api/v1/classify/intent endpoint was returning placeholder "general" category responses with 0.5 confidence instead of performing actual classification using the unified classifier. Changes: - Update handleIntentClassification() to check for unified classifier availability first - Use ClassifyIntentUnified() when unified classifier is available - Fall back to legacy ClassifyIntent() when unified classifier not available - Maintain backward compatibility with existing API contract This resolves the issue where the single classification API always returned hardcoded placeholder responses instead of performing actual BERT-based classification. Fixes #303 Signed-off-by: Yossi Ovadia --- src/semantic-router/pkg/api/server.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/semantic-router/pkg/api/server.go b/src/semantic-router/pkg/api/server.go index a281a811..d0611ef1 100644 --- a/src/semantic-router/pkg/api/server.go +++ b/src/semantic-router/pkg/api/server.go @@ -232,7 +232,16 @@ func (s *ClassificationAPIServer) handleIntentClassification(w http.ResponseWrit return } - response, err := s.classificationSvc.ClassifyIntent(req) + // Use unified classifier if available, otherwise fall back to legacy + var response *services.IntentResponse + var err error + + if s.classificationSvc.HasUnifiedClassifier() { + response, err = s.classificationSvc.ClassifyIntentUnified(req) + } else { + response, err = s.classificationSvc.ClassifyIntent(req) + } + if err != nil { s.writeErrorResponse(w, http.StatusInternalServerError, "CLASSIFICATION_ERROR", err.Error()) return