Help us shape the future of Go! Take the 2026 Go Developer Survey

classifier

package
v0.86.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string

Category represents a conversation classification category.

const (
	CategoryCrisis         Category = "crisis"
	CategoryGeneralSupport Category = "general-support"
	CategoryInformation    Category = "information"
	CategoryReferral       Category = "referral"
)

func AllCategories

func AllCategories() []Category

AllCategories returns all valid classification categories.

type Classification

type Classification struct {
	Category     Category  `json:"category"`
	Confidence   float64   `json:"confidence"`
	Priority     int       `json:"priority"` // 1 (highest) to 5 (lowest)
	Subcategory  string    `json:"subcategory,omitempty"`
	Tags         []string  `json:"tags,omitempty"`
	ClassifiedAt time.Time `json:"classifiedAt"`
}

Classification represents the result of classifying a conversation.

type Config

type Config struct {
	CacheTTL time.Duration
}

Config holds configuration for the ConversationClassifier.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default classifier configuration.

type ConversationClassifier

type ConversationClassifier struct {
	// contains filtered or unexported fields
}

ConversationClassifier classifies conversations into categories with priority scoring.

func NewConversationClassifier

func NewConversationClassifier(provider LLMProvider, cfg Config) *ConversationClassifier

NewConversationClassifier creates a new classifier. If provider is nil, only rule-based classification is used.

func (*ConversationClassifier) Classify

func (c *ConversationClassifier) Classify(ctx context.Context, conversationID string, messages []Message) (*Classification, error)

Classify classifies a conversation and returns its category with priority.

func (*ConversationClassifier) ClearCache

func (c *ConversationClassifier) ClearCache()

ClearCache removes all cached classifications.

func (*ConversationClassifier) InvalidateConversation

func (c *ConversationClassifier) InvalidateConversation(conversationID string)

InvalidateConversation removes the cached classification for a conversation.

type LLMProvider

type LLMProvider interface {
	Classify(ctx context.Context, systemPrompt, userPrompt string) (*Classification, error)
}

LLMProvider abstracts the AI classification backend.

type Message

type Message struct {
	Body string `json:"body"`
	Role string `json:"role"`
}

Message represents a conversation message for classification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL