vectorindex

package
v1.4.14 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package vectorindex is the swappable vector-search seam behind the runbook-RAG find_runbook tool. The OSS build ships an in-memory cosine top-K index (Memory) that holds the whole runbook corpus in process — no external vector database, so an operator's data never leaves the box. The Index interface is the seam an enterprise hosted/scalable vector backend swaps in without forking the tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

type Doc struct {
	ID      string
	Title   string
	Service string
	Source  string
	Excerpt string
	Vector  []float32
}

Doc is one indexed runbook excerpt plus its cached embedding vector. The vector is computed once at ingestion and reloaded at boot, so the index never needs to re-embed the corpus.

type Index

type Index interface {
	Search(query []float32, service string, limit int) []Result
}

Index is the read-only search seam the find_runbook tool depends on (via a local interface in the tools package). Implementations return the top-`limit` documents most similar to `query`, optionally restricted to a single service. A nil/empty index yields no results and no error.

type Memory

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

Memory is the in-memory cosine top-K index. It is safe to build once at boot and read concurrently afterwards; it is not written to after construction (ingestion rewrites the backing store and the index is rebuilt at the next boot).

func NewMemory

func NewMemory(maxDocs int) *Memory

NewMemory returns an empty in-memory index bounded at maxDocs documents (Add silently drops documents beyond the bound so a runaway corpus cannot exhaust memory). A non-positive maxDocs applies the built-in default.

func (*Memory) Add

func (m *Memory) Add(d Doc)

Add appends a document to the index. Documents with an empty vector are skipped (they could never match). Documents beyond the configured bound are dropped.

func (*Memory) Len

func (m *Memory) Len() int

Len reports how many documents are indexed.

func (*Memory) Search

func (m *Memory) Search(query []float32, service string, limit int) []Result

Search implements Index. It scores every document by cosine similarity against query, optionally filters by service (case-insensitive exact match), sorts by descending score, and returns at most limit results. A non-positive limit applies a default of 5. An empty index or empty query yields no results.

type Result

type Result struct {
	Doc
	Score float32
}

Result is one search hit: the matched Doc plus its cosine similarity score in [-1, 1] (higher is more similar).

Jump to

Keyboard shortcuts

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