Files
gnoma/internal/router/classifier.go
T
vikingowl 8b2202e8ec feat(classifier): Wave A — TaskClassifier interface + HeuristicClassifier
- 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.
2026-05-07 16:11:20 +02:00

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
}