itemcategorize

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Batch

func Batch(ctx context.Context, cfg config.Config, st *store.Store, opts Options) (Stats, []ItemResult, error)

Batch categorizes multiple items (those without user_tags unless force is set).

func BatchSources

func BatchSources(ctx context.Context, cfg config.Config, st *store.Store, opts Options) (Stats, []SourceResult, error)

BatchSources categorizes multiple sources (those without user_tags unless force is set).

func MergeUserTags

func MergeUserTags(existing string, r Result) string

MergeUserTags appends categorizer output to existing comma-separated user_tags while preserving the existing order and removing duplicates.

Types

type ItemResult

type ItemResult struct {
	Item   model.Item `json:"item"`
	Result Result     `json:"result,omitempty"`
	Error  string     `json:"error,omitempty"`
}

ItemResult pairs an item with its categorization result or error.

type Options

type Options struct {
	Model           string
	Timeout         time.Duration
	Concurrency     int
	Limit           int
	Force           bool
	Apply           bool // save result back to user_tags
	IncludeImages   bool // embed local or archived photos as base64 for vision models
	OpenRouterBase  string
	OpenRouterKey   string
	OpenRouterRef   string
	OpenRouterTitle string
	UserAgent       string
	OllamaBase      string
	OllamaKey       string
	// R2/S3 credentials for fetching archived photos not present locally.
	S3Endpoint  string
	S3Region    string
	S3AccessKey string
	S3SecretKey string
	// Vocab is the optional canonical vocabulary loaded from categories.yaml.
	Vocab categoryvocab.Vocab
	// OnStart is called after item selection, before worker goroutines start.
	OnStart func(total int)
	// OnResult is called from worker goroutines as each item completes.
	// It must be safe to call concurrently. Leave nil to skip streaming output.
	OnResult func(ItemResult)
	// OnSourceResult is called from worker goroutines as each source completes.
	// It must be safe to call concurrently. Leave nil to skip streaming output.
	OnSourceResult func(SourceResult)
}

Options configures a categorize run.

type Result

type Result struct {
	Categories      []string `json:"categories"`
	Tags            []string `json:"tags"`
	PrimaryCategory string   `json:"primary_category"`
	Model           string   `json:"model"`
	RawResponse     string   `json:"raw_response,omitempty"`
}

Result holds the LLM categorization output for one item.

func Run

func Run(ctx context.Context, cfg config.Config, st *store.Store, item model.Item, opts Options) (Result, error)

Run categorizes a single item and optionally saves the result.

func RunSource

func RunSource(ctx context.Context, cfg config.Config, st *store.Store, source model.SourceDocument, opts Options) (Result, error)

RunSource categorizes a single source and optionally saves the result.

type SourceResult

type SourceResult struct {
	Source model.SourceDocument `json:"source"`
	Result Result               `json:"result,omitempty"`
	Error  string               `json:"error,omitempty"`
}

SourceResult pairs a source with its categorization result or error.

type Stats

type Stats struct {
	Queued    int `json:"queued"`
	Succeeded int `json:"succeeded"`
	Applied   int `json:"applied"`
	Skipped   int `json:"skipped"`
	Errors    int `json:"errors"`
}

Stats summarises a batch categorize run.

Jump to

Keyboard shortcuts

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