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) 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) 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) 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 {
UserID int32 // User ID for personalized suggestions
MemoID string // Optional: memo ID when editing existing memo
Content string // Memo content
Title string // Memo title (optional)
MaxTags int // Maximum tags to return (default: 5)
UseLLM bool // Whether to use LLM layer (default: true)
}
SuggestRequest contains parameters for tag suggestion.
type SuggestResponse ¶
type SuggestResponse struct {
Tags []Suggestion `json:"tags"`
Latency time.Duration `json:"latency"`
Sources []string `json:"sources"` // ["statistics", "rules", "llm"]
}
SuggestResponse contains tag suggestions and metadata.
type Suggestion ¶
type Suggestion struct {
Name string `json:"name"`
Confidence float64 `json:"confidence"` // 0.0 - 1.0
Source string `json:"source"` // "statistics", "rules", "llm"
Reason string `json:"reason,omitempty"`
}
Suggestion represents a single tag suggestion.
type TagFrequency ¶
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 ¶
TagWithSimilarity represents a tag from similar memo.