factory

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package factory wires the canonical knowledge.Service stacks. It lives in a subpackage to break the import cycle that would arise if the top-level knowledge package depended on backend/fs and backend/retrieval (both of which depend on knowledge for the repo interfaces).

Use NewLocal for a fully filesystem-backed Service; NewRetrieval when chunks/layers should live inside an existing retrieval.Index.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLocal

func NewLocal(ws workspace.Workspace, opts ...LocalOption) *knowledge.Service

NewLocal assembles a knowledge.Service backed entirely by the workspace filesystem. ChunkRepo.Load is called eagerly so BM25 indexes rehydrate from disk before the first search; load errors are swallowed (treated as "empty index").

func NewRetrieval

func NewRetrieval(docs knowledge.DocumentRepo, idx retrieval.Index, opts ...RetrievalOption) *knowledge.Service

NewRetrieval assembles a knowledge.Service whose chunks/layers live inside a retrieval.Index, while documents stay in the supplied DocumentRepo (Q8=B: retrieval indexes are not authoritative document stores).

Typical pairing:

docs := fs.NewDocumentRepo(ws, "knowledge")
idx  := memory.New()
svc  := factory.NewRetrieval(docs, idx)

Types

type LocalOption

type LocalOption func(*localConfig)

LocalOption configures NewLocal.

func WithLocalChunker

func WithLocalChunker(c knowledge.Chunker) LocalOption

WithLocalChunker overrides the chunker used by the local service.

func WithLocalEmbedder

func WithLocalEmbedder(e knowledge.Embedder, sig string) LocalOption

WithLocalEmbedder enables vector-aware indexing on the local backend. When sig is empty, the embedder's Go type name is used as the EmbedSig; pass an explicit identifier for production wiring.

func WithLocalPrefix

func WithLocalPrefix(prefix string) LocalOption

WithLocalPrefix overrides the workspace prefix (default "knowledge").

func WithLocalTokenizer

func WithLocalTokenizer(tok textsearch.Tokenizer) LocalOption

WithLocalTokenizer overrides the BM25 tokenizer (default CJKTokenizer).

type RetrievalOption

type RetrievalOption func(*retrievalConfig)

RetrievalOption configures NewRetrieval.

func WithRetrievalChunker

func WithRetrievalChunker(c knowledge.Chunker) RetrievalOption

WithRetrievalChunker overrides the chunker.

func WithRetrievalEmbedder

func WithRetrievalEmbedder(e knowledge.Embedder, sig string) RetrievalOption

WithRetrievalEmbedder enables vector indexing inside the retrieval namespace. When sig is empty, the embedder's Go type name is used.

Jump to

Keyboard shortcuts

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