comments

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 17 Imported by: 1 module, 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

Overview

Package comments is the model stage that reads what a video's top comments say about it, when a person asks on the video's review card. It runs once per item and never as a batch: the route queues one task, a worker reads the source's top comments through the source's own reader and asks one model call through modelstage's dispatch-once protocol, and the answer is kept as the output's answer. A model wrote that answer over strangers' comments, so it ships as outsider text alone, and the comments themselves are not kept.

Index

Constants

View Source
const (
	// Capability is the capability of every comments task.
	Capability = store.StageComments
	// Producer names the stage's outputs, whose version is the prompt's.
	Producer = "comments"
	// SchemaVersion is the route's answer, schemas/item-comments.schema.json.
	SchemaVersion = 1
)
View Source
const (
	// DefaultModel and DefaultEffort are what the read's run is asked for
	// where config names neither. It reads short comments and answers a short
	// schema, so the smallest model does it.
	DefaultModel  = "haiku"
	DefaultEffort = "medium"
)

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(port modelport.Port, readers Readers, settings modelstage.Settings, log *slog.Logger) worker.Handler

NewHandler is the worker handler that reads each task's item's comments through the reader that readers opens for its media type, and asks port what they say under modelstage's dispatch-once protocol. A worker opens it only where it holds a model port and a reader.

func Reads

func Reads(mediaType string) bool

Reads says whether a registered source reads the comments of items of mediaType.

func Register

func Register(mediaType string)

Register records that this build reads the comments of items of mediaType through one of its sources, so the route queues a read for one. sources.Register calls it.

func Routes

func Routes(st *store.Store, log *slog.Logger) server.Routes

Routes is the route that asks for the read of an item's comments.

func StateOf

func StateOf(r store.ItemRecords, claimed map[string]bool) *server.ReviewComments

StateOf is how the read of the item's comments stands in r, where claimed holds each capability that a worker heard from lately claims. It is nil where no source of this build reads the item's comments and none were read. A done answer stands whatever a later task does.

Types

type Answer

type Answer struct {
	Summary   string   `json:"summary"`
	Praise    []string `json:"praise"`
	Criticism []string `json:"criticism"`
	Tone      string   `json:"tone"`
}

Answer is the model's answer, as prompts/comments/answer.schema.json holds it.

func DecodeAnswer

func DecodeAnswer(raw json.RawMessage) (Answer, error)

DecodeAnswer decodes a stored answer without checking it against this build's schema, which its run's schema checked when it arrived.

func ReadAnswer

func ReadAnswer(raw json.RawMessage) (Answer, error)

ReadAnswer checks raw against the schema of the prompt in force and decodes it.

type Read

type Read struct {
	Disabled bool
	Threads  []Thread
}

Read is an item's top comments, most relevant first, and Disabled where the item's owner turned its comments off.

type Reader

type Reader interface {
	Comments(ctx context.Context, key string) (Read, error)
}

Reader reads the top comments of an item that holds no bytes, by its key.

type Readers

type Readers map[string]Reader

Readers holds the reader opened for each media type, by the type.

type Source

type Source struct {
	MediaType string
	Open      func(api string, client *http.Client) Reader
}

Source is how a source reads comments: the media type of the items it reads them for, and how a worker opens its reader on the source's client.

type Thread

type Thread struct {
	Text    string
	Likes   int64
	Replies int64
}

Thread is one top-level comment as a source answers it: its text, and how many likes and replies it drew.

Jump to

Keyboard shortcuts

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