Documentation
¶
Overview ¶
Package weave adapts the Weave RAG engine to the cortex knowledge.Provider interface.
Every call runs under a weave tenant, taken from the run's scope by a cortex.TenantFunc, so a run only ever reads its own tenant's collections plus the shared ones the host lists. The adapter never writes, and a call whose scope names no tenant fails before weave is asked anything.
A collection named that doesn't exist yet, the run's or a shared one, reads as no results rather than an error, and in a search over several collections a missing one contributes nothing while the others still answer. Creating collections stays with whatever ingests into them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EngineOption ¶
EngineOption returns an engine.Option that auto-discovers a Weave engine from the DI container and configures the Cortex engine's knowledge provider. If no Weave engine is found, returns a no-op option (safe to always include).
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements knowledge.Provider by delegating to a weave Engine.
func New ¶
func New(eng *weaveengine.Engine, opts ...Option) *Adapter
New creates a new Weave adapter from an engine instance.
func (*Adapter) ListCollections ¶
ListCollections returns the run tenant's collections and the configured shared ones, with statistics, each read under its own tenant. A shared collection weave can't find is left out.
func (*Adapter) Retrieve ¶
func (a *Adapter) Retrieve(ctx context.Context, query string, params *knowledge.RetrieveParams) ([]knowledge.ScoredChunk, error)
Retrieve performs a semantic search and returns scored chunks. A collection named that doesn't exist yet returns no chunks and no error. A search that names no collection leaves out any shared collection weave can't find, and still returns the rest.
type Option ¶ added in v1.10.0
type Option func(*Adapter)
Option configures an Adapter.
func WithShared ¶ added in v1.10.0
func WithShared(collections ...SharedCollection) Option
WithShared lists collections, each under its own tenant, that every run may also search. They are read only. A retrieval that names no collection searches them along with the run's tenant, and one that names a listed collection reads it under its tenant.
func WithTenant ¶ added in v1.10.0
func WithTenant(f cortex.TenantFunc) Option
WithTenant sets how the adapter names the weave tenant a run reads under, from the run's scope. The default is cortex.RootTenant, the value of the scope's first level, which only works when that value is the weave tenant. An empty result is refused like a missing scope.
type SharedCollection ¶ added in v1.10.0
SharedCollection names a read-only collection that every run may search besides its own tenant's, such as a product documentation tenant.