Documentation
¶
Overview ¶
Package semantic observes possible completed-answer reuse. Shadow decisions are advisory: they never serve text, change claims, or authorize generation.
Index ¶
- Constants
- func Cosine(a, b []float32) (float64, error)
- func EntryID(e Entry) string
- func ValidatePut(p PutRequest) error
- func ValidateQuery(q Query) error
- type Candidate
- type Config
- type Embedder
- type Embedding
- type Entry
- type Index
- type Observation
- type OllamaEmbedder
- type PutRequest
- type Query
- type SearchResult
- type Source
Constants ¶
const ( DefaultMinSimilarity = 0.9 DefaultTopK = 3 DefaultMaxScan = 1000 DefaultMaxEntries = 1000 DefaultMaxInputBytes = 8192 DefaultTimeoutMS = 10000 MaxTopK = 10 MaxScan = 10000 MaxEntries = 10000 MaxInputBytes = 32768 MaxTimeoutMS = 60000 MaxDimensions = 4096 )
Variables ¶
This section is empty.
Functions ¶
func Cosine ¶
Cosine compares finite, nonzero vectors with matching bounded dimensions. float64 accumulation avoids overflowing when finite float32 values are large.
func EntryID ¶
EntryID binds an entry to its exact source snapshot within one embedding partition. Vectors and expiry do not create duplicate copies of that snapshot.
func ValidatePut ¶
func ValidatePut(p PutRequest) error
ValidatePut verifies identities, bounded vectors and the short-lived source pointer. The source artifact itself must also be checked by the index owner.
func ValidateQuery ¶
ValidateQuery checks the fully specified wire request; defaults belong to NormalizeConfig and are deliberately not inferred at the broker boundary.
Types ¶
type Config ¶
type Config struct {
Mode string `json:"mode"`
Family string `json:"family"`
Domain string `json:"domain"`
EvidenceRevision string `json:"evidence_revision"`
Bindings map[string]string `json:"bindings,omitempty"`
EmbeddingModel string `json:"embedding_model"`
MinSimilarity float64 `json:"min_similarity,omitempty"`
TopK int `json:"top_k,omitempty"`
MaxScan int `json:"max_scan,omitempty"`
MaxEntries int `json:"max_entries,omitempty"`
MaxInputBytes int `json:"max_input_bytes,omitempty"`
TimeoutMS int `json:"timeout_ms,omitempty"`
}
Config is opt-in. Mode accepts only "shadow" in this release.
func NormalizeConfig ¶
NormalizeConfig fills bounded defaults and rejects modes that could serve an answer. The returned bindings are a copy so later caller edits cannot alter it.
type Index ¶
type Index interface {
QuerySemantic(context.Context, Query) (SearchResult, error)
PutSemantic(context.Context, PutRequest) error
}
type Observation ¶
type Observation struct {
Mode string `json:"mode"`
Status string `json:"status"`
Partition string `json:"partition,omitempty"`
EmbeddingModelID string `json:"embedding_model_id,omitempty"`
EmbeddingInputTokens *int64 `json:"embedding_input_tokens"`
EmbeddingMS float64 `json:"embedding_ms,omitempty"`
TotalMS float64 `json:"total_ms"`
Search *SearchResult `json:"search,omitempty"`
Indexed bool `json:"indexed"`
GenerationAvoided bool `json:"generation_avoided"`
}
Observation deliberately has no reused/avoided tokens or alternative answer.
type OllamaEmbedder ¶
type OllamaEmbedder struct {
// contains filtered or unexported fields
}
OllamaEmbedder captures already-installed local weights and the Ollama runtime version. It never pulls models, follows redirects, or uses environment proxies. Its methods are safe for concurrent use; its pinned identity is immutable.
func NewOllamaEmbedder ¶
func NewOllamaEmbedder(baseURL, model string, maxInputBytes int) (*OllamaEmbedder, error)
NewOllamaEmbedder validates the installed model without generating a vector. The empty origin selects http://127.0.0.1:11434. Discovery is capped at 10s.
func NewOllamaEmbedderContext ¶
func NewOllamaEmbedderContext(ctx context.Context, baseURL, model string, maxInputBytes int) (*OllamaEmbedder, error)
NewOllamaEmbedderContext also includes metadata discovery in caller's deadline.
func (*OllamaEmbedder) Close ¶
func (p *OllamaEmbedder) Close()
Close releases idle local connections. It does not unload model weights.