8b2202e8ec
- internal/router/classifier.go: TaskClassifier interface with Classify(ctx, prompt, history) signature. HeuristicClassifier wraps the existing ClassifyTask() with zero behavior change. - engine.Config.Classifier: injectable TaskClassifier; nil defaults to HeuristicClassifier. Engine.classify() helper handles nil + error fallback transparently. - loop.go: all four router.ClassifyTask() call sites replaced with e.classify(ctx, prompt). SLMClassifier slots in without further changes to the engine.
23 lines
761 B
Go
23 lines
761 B
Go
package router
|
|
|
|
import (
|
|
"context"
|
|
|
|
"somegit.dev/Owlibou/gnoma/internal/message"
|
|
)
|
|
|
|
// TaskClassifier classifies a user prompt into a Task for routing decisions.
|
|
// The history slice provides prior conversation context; implementations may
|
|
// ignore it (HeuristicClassifier) or use it for richer inference (SLMClassifier).
|
|
type TaskClassifier interface {
|
|
Classify(ctx context.Context, prompt string, history []message.Message) (Task, error)
|
|
}
|
|
|
|
// HeuristicClassifier is the default classifier. It wraps the keyword-based
|
|
// ClassifyTask function and ignores conversation history.
|
|
type HeuristicClassifier struct{}
|
|
|
|
func (HeuristicClassifier) Classify(_ context.Context, prompt string, _ []message.Message) (Task, error) {
|
|
return ClassifyTask(prompt), nil
|
|
}
|