@@ -18,8 +18,8 @@ import (
18
18
19
19
const (
20
20
// 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.
23
23
DefaultMCPThreshold = 0.5
24
24
)
25
25
@@ -222,8 +222,7 @@ func createMCPCategoryInference(initializer MCPCategoryInitializer) MCPCategoryI
222
222
// IsMCPCategoryEnabled checks if MCP-based category classification is properly configured
223
223
func (c * Classifier ) IsMCPCategoryEnabled () bool {
224
224
return c .Config .Classifier .MCPCategoryModel .Enabled &&
225
- c .Config .Classifier .MCPCategoryModel .ToolName != "" &&
226
- c .mcpCategoryInitializer != nil
225
+ c .Config .Classifier .MCPCategoryModel .ToolName != ""
227
226
}
228
227
229
228
// initializeMCPCategoryClassifier initializes the MCP category classification model
@@ -232,6 +231,10 @@ func (c *Classifier) initializeMCPCategoryClassifier() error {
232
231
return fmt .Errorf ("MCP category classification is not properly configured" )
233
232
}
234
233
234
+ if c .mcpCategoryInitializer == nil {
235
+ return fmt .Errorf ("MCP category initializer is not set" )
236
+ }
237
+
235
238
if err := c .mcpCategoryInitializer .Init (c .Config ); err != nil {
236
239
return fmt .Errorf ("failed to initialize MCP category classifier: %w" , err )
237
240
}
@@ -246,6 +249,10 @@ func (c *Classifier) classifyCategoryMCP(text string) (string, float64, error) {
246
249
return "" , 0.0 , fmt .Errorf ("MCP category classification is not properly configured" )
247
250
}
248
251
252
+ if c .mcpCategoryInference == nil {
253
+ return "" , 0.0 , fmt .Errorf ("MCP category inference is not initialized" )
254
+ }
255
+
249
256
// Create context with timeout
250
257
ctx := context .Background ()
251
258
if c .Config .Classifier .MCPCategoryModel .TimeoutSeconds > 0 {
@@ -302,6 +309,10 @@ func (c *Classifier) classifyCategoryWithEntropyMCP(text string) (string, float6
302
309
return "" , 0.0 , entropy.ReasoningDecision {}, fmt .Errorf ("MCP category classification is not properly configured" )
303
310
}
304
311
312
+ if c .mcpCategoryInference == nil {
313
+ return "" , 0.0 , entropy.ReasoningDecision {}, fmt .Errorf ("MCP category inference is not initialized" )
314
+ }
315
+
305
316
// Create context with timeout
306
317
ctx := context .Background ()
307
318
if c .Config .Classifier .MCPCategoryModel .TimeoutSeconds > 0 {
0 commit comments