@@ -18,8 +18,8 @@ import (
1818
1919const (
2020 // DefaultMCPThreshold is the default confidence threshold for MCP classification.
21- // A value of 0.5 is commonly used as it represents a neutral cutoff for binary or probabilistic classification,
22- // meaning predictions with confidence above 50% are considered positive . Adjust as needed for your use case.
21+ // For multi-class classification, a value of 0.5 means that a predicted class must have more than 50% confidence
22+ // to be selected . Adjust this threshold as needed for your use case.
2323 DefaultMCPThreshold = 0.5
2424)
2525
@@ -222,8 +222,7 @@ func createMCPCategoryInference(initializer MCPCategoryInitializer) MCPCategoryI
222222// IsMCPCategoryEnabled checks if MCP-based category classification is properly configured
223223func (c * Classifier ) IsMCPCategoryEnabled () bool {
224224 return c .Config .Classifier .MCPCategoryModel .Enabled &&
225- c .Config .Classifier .MCPCategoryModel .ToolName != "" &&
226- c .mcpCategoryInitializer != nil
225+ c .Config .Classifier .MCPCategoryModel .ToolName != ""
227226}
228227
229228// initializeMCPCategoryClassifier initializes the MCP category classification model
@@ -232,6 +231,10 @@ func (c *Classifier) initializeMCPCategoryClassifier() error {
232231 return fmt .Errorf ("MCP category classification is not properly configured" )
233232 }
234233
234+ if c .mcpCategoryInitializer == nil {
235+ return fmt .Errorf ("MCP category initializer is not set" )
236+ }
237+
235238 if err := c .mcpCategoryInitializer .Init (c .Config ); err != nil {
236239 return fmt .Errorf ("failed to initialize MCP category classifier: %w" , err )
237240 }
@@ -246,6 +249,10 @@ func (c *Classifier) classifyCategoryMCP(text string) (string, float64, error) {
246249 return "" , 0.0 , fmt .Errorf ("MCP category classification is not properly configured" )
247250 }
248251
252+ if c .mcpCategoryInference == nil {
253+ return "" , 0.0 , fmt .Errorf ("MCP category inference is not initialized" )
254+ }
255+
249256 // Create context with timeout
250257 ctx := context .Background ()
251258 if c .Config .Classifier .MCPCategoryModel .TimeoutSeconds > 0 {
@@ -302,6 +309,10 @@ func (c *Classifier) classifyCategoryWithEntropyMCP(text string) (string, float6
302309 return "" , 0.0 , entropy.ReasoningDecision {}, fmt .Errorf ("MCP category classification is not properly configured" )
303310 }
304311
312+ if c .mcpCategoryInference == nil {
313+ return "" , 0.0 , entropy.ReasoningDecision {}, fmt .Errorf ("MCP category inference is not initialized" )
314+ }
315+
305316 // Create context with timeout
306317 ctx := context .Background ()
307318 if c .Config .Classifier .MCPCategoryModel .TimeoutSeconds > 0 {
0 commit comments