factory

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: May 17, 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 deprecated

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").

Deprecated: NewLocal wires FSChunkRepo + FSLayerRepo, both demo-grade backends whose O(N) per-doc ingest does not scale beyond unit-test / small-fixture sizes (see #134). Use NewRetrieval with an in-process sdk/retrieval/memory.Index for tests and a production retrieval.Index (sdkx/retrieval/{sqlite,postgres,workspace}) for real workloads. FSDocumentRepo is NOT deprecated and remains the canonical document store for both factories. Slated for removal in v0.5.0; see docs/migrations/v0.5.0.md for the one-liner migration recipe.

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 deprecated

type LocalOption func(*localConfig)

LocalOption configures NewLocal.

Deprecated: see NewLocal. Use RetrievalOption with NewRetrieval instead; slated for removal in v0.5.0.

func WithLocalChunker deprecated

func WithLocalChunker(c knowledge.Chunker) LocalOption

WithLocalChunker overrides the chunker used by the local service.

Deprecated: use WithRetrievalChunker with NewRetrieval. Slated for removal in v0.5.0.

func WithLocalEmbedder deprecated

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.

Deprecated: use WithRetrievalEmbedder with NewRetrieval. Slated for removal in v0.5.0.

func WithLocalPrefix deprecated

func WithLocalPrefix(prefix string) LocalOption

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

Deprecated: NewRetrieval has no equivalent — the retrieval.Index owns chunk/layer storage and is independent of the workspace filesystem prefix used by FSDocumentRepo. Slated for removal in v0.5.0.

func WithLocalTokenizer deprecated

func WithLocalTokenizer(tok textsearch.Tokenizer) LocalOption

WithLocalTokenizer overrides the BM25 tokenizer (default CJKTokenizer).

Deprecated: the tokenizer used by NewRetrieval is owned by the configured retrieval.Index (e.g. sdk/retrieval/memory.Index uses CJKTokenizer; sdkx/retrieval/{sqlite,postgres} expose backend-native analyzers). Configure tokenization at the Index constructor instead. Slated for removal in v0.5.0.

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