tags

package
v0.80.4 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tags provides intelligent tag suggestion for memos. P2-C001: Three-layer progressive tag suggestion system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLMLayer

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

LLMLayer provides tag suggestions using LLM. Layer 3: ~300ms latency, optional, graceful degradation.

func NewLLMLayer

func NewLLMLayer(llmService ai.LLMService) *LLMLayer

NewLLMLayer creates a new LLM layer.

func (*LLMLayer) Name

func (l *LLMLayer) Name() string

Name returns the layer name.

func (*LLMLayer) Suggest

func (l *LLMLayer) Suggest(ctx context.Context, req *SuggestRequest) []Suggestion

Suggest returns tag suggestions using LLM.

type Layer

type Layer interface {
	// Name returns the layer name for logging/metrics.
	Name() string
	// Suggest returns suggestions from this layer.
	Suggest(ctx context.Context, req *SuggestRequest) []Suggestion
}

Layer represents a single layer in the suggestion pipeline.

type RulesLayer

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

RulesLayer provides tag suggestions based on pattern matching. Layer 2: ~10ms latency, uses tech terms, emotion words, and date patterns.

func NewRulesLayer

func NewRulesLayer() *RulesLayer

NewRulesLayer creates a new rules layer with predefined patterns.

func (*RulesLayer) Name

func (l *RulesLayer) Name() string

Name returns the layer name.

func (*RulesLayer) Suggest

func (l *RulesLayer) Suggest(ctx context.Context, req *SuggestRequest) []Suggestion

Suggest returns tag suggestions based on pattern matching.

type StatisticsLayer

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

StatisticsLayer provides tag suggestions based on user statistics. Layer 1: 0ms latency, uses high-frequency tags, recent tags, and similar memo tags.

func NewStatisticsLayer

func NewStatisticsLayer(s *store.Store, c cache.CacheService) *StatisticsLayer

NewStatisticsLayer creates a new statistics layer.

func (*StatisticsLayer) Name

func (l *StatisticsLayer) Name() string

Name returns the layer name.

func (*StatisticsLayer) Suggest

func (l *StatisticsLayer) Suggest(ctx context.Context, req *SuggestRequest) []Suggestion

Suggest returns tag suggestions based on user statistics. Optimized to query memos only once per request.

type SuggestRequest

type SuggestRequest struct {
	MemoID  string
	Content string
	Title   string
	MaxTags int
	UserID  int32
	UseLLM  bool
}

SuggestRequest contains parameters for tag suggestion.

type SuggestResponse

type SuggestResponse struct {
	Tags    []Suggestion  `json:"tags"`
	Sources []string      `json:"sources"`
	Latency time.Duration `json:"latency"`
}

SuggestResponse contains tag suggestions and metadata.

type Suggestion

type Suggestion struct {
	Name       string  `json:"name"`
	Source     string  `json:"source"`
	Reason     string  `json:"reason,omitempty"`
	Confidence float64 `json:"confidence"`
}

Suggestion represents a single tag suggestion.

type TagFrequency

type TagFrequency struct {
	Name  string
	Count int
}

TagFrequency represents tag usage frequency.

type TagSuggester

type TagSuggester interface {
	// Suggest returns tag suggestions based on content, user history, and rules.
	Suggest(ctx context.Context, req *SuggestRequest) (*SuggestResponse, error)
}

TagSuggester provides tag suggestions for memo content.

func NewTagSuggester

func NewTagSuggester(s *store.Store, llmService ai.LLMService, c cache.CacheService) TagSuggester

NewTagSuggester creates a new TagSuggester with all three layers.

type TagWithSimilarity

type TagWithSimilarity struct {
	Name       string
	Similarity float64
}

TagWithSimilarity represents a tag from similar memo.

Jump to

Keyboard shortcuts

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