search

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package search performs server-side transcript search: targeted retrieval instead of paging a 50KB blob into the agent's context.

Index

Constants

View Source
const (
	DefaultContextCues = 1
	DefaultMaxMatches  = 10
	MaxMatchesLimit    = 50
)

Variables

This section is empty.

Functions

func NormalizeText

func NormalizeText(s string) string

NormalizeText lowercases and normalizes typography for matching and for advisory content checks.

Types

type Match

type Match struct {
	CueIndex     int     `json:"cue_index"`
	StartSeconds float64 `json:"start_seconds"`
	Timestamp    string  `json:"timestamp"`
	Text         string  `json:"text"`
	Before       string  `json:"before,omitempty"`
	After        string  `json:"after,omitempty"`
}

Match is one matching cue with optional surrounding context.

type Mode

type Mode string

Mode decides how a multi-word query is satisfied.

All (default) preserves the original behaviour: every term must appear within the cue window. Any exists because a literal AND returns a false negative when the speaker paraphrases. Phrase requires adjacency.

const (
	All    Mode = "all"
	Any    Mode = "any"
	Phrase Mode = "phrase"
)

func ParseMode

func ParseMode(s string) (Mode, bool)

ParseMode reports whether the caller supplied a known mode, so a typo fails loudly instead of silently scanning with the default.

type Options

type Options struct {
	Query       string
	ContextCues int
	MaxMatches  int
	StartCue    int
	MatchMode   Mode
}

Options are the search parameters resolved at the adapter boundary.

type Result

type Result struct {
	Matches      []Match `json:"matches"`
	TotalMatches int     `json:"total_matches"`
	Truncated    bool    `json:"truncated"`
	// NextCue is set when Truncated: pass it back as StartCue to continue.
	NextCue   *int       `json:"next_cue,omitempty"`
	MatchMode string     `json:"match_mode,omitempty"`
	Terms     []TermStat `json:"terms,omitempty"`
	Notes     []string   `json:"notes,omitempty"`
}

Result is the complete search response.

func Segments

func Segments(segs []transcript.Segment, opts Options) Result

Segments searches a transcript's cues.

type TermStat

type TermStat struct {
	Term    string `json:"term"`
	Matches int    `json:"matches"`
}

TermStat makes a zero result explainable: the agent can see that a term is absent from the transcript instead of guessing why nothing matched.

Jump to

Keyboard shortcuts

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