Documentation
¶
Overview ¶
Package knowledgenode implements the "knowledge" graph node and exposes a Register helper for binding it into a node.Factory.
The node fans search queries out across the configured datasets via a knowledge.Service and writes the resulting hits onto the board under "hits" / "by_dataset" (typed) and "results" (compat projection consumed by graphs that predate the typed hits API).
Index ¶
- Constants
- func Register(factory *node.Factory, svc *knowledge.Service)
- type Config
- type DatasetQuery
- type Node
- func (n *Node) Config() map[string]any
- func (n *Node) ExecuteBoard(ectx graph.ExecutionContext, board *graph.Board) error
- func (n *Node) ID() string
- func (n *Node) InputPorts() []graph.Port
- func (n *Node) OutputPorts() []graph.Port
- func (n *Node) SetConfig(c map[string]any)
- func (n *Node) Type() string
Constants ¶
const DefaultQueryKey = "query"
DefaultQueryKey is the board-var key the node reads when Config.QueryKey is empty. Held as a constant rather than a magic string so callers can reference it from BoardSeeders / tests without hard-coding "query".
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
QueryKey string `json:"query_key,omitempty"`
Scope knowledge.Scope `json:"scope,omitempty"`
Datasets []DatasetQuery `json:"datasets,omitempty"`
Mode knowledge.Mode `json:"mode,omitempty"`
Layer knowledge.Layer `json:"layer,omitempty"`
TopK int `json:"top_k,omitempty"`
Threshold float64 `json:"threshold,omitempty"`
}
Config configures a knowledge graph node.
Field semantics:
- QueryKey names the board var the node reads as the search query; empty means DefaultQueryKey ("query").
- Scope selects whether to search a specific dataset list (Datasets) or every known dataset (knowledge.ScopeAllDatasets).
- Datasets is consulted only when Scope == knowledge.ScopeSingleDataset; each entry can override TopK and choose a board key for its hits.
- Mode/Layer/TopK/Threshold are forwarded into knowledge.Query.
func ConfigFromMap ¶
ConfigFromMap parses map[string]any into Config. It tolerates a few surface-shape variations so hand-written and JSON-decoded configs both round-trip:
- "max_layer" is accepted as an alias for "layer" when "layer" is absent.
- Numeric "top_k" / "threshold" accept both float64 (JSON) and int.
- "scope" accepts "single" (default) and "all".
type DatasetQuery ¶ added in v0.3.0
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a graph node that retrieves documents from a knowledge.Service. It delegates to Service so contract guarantees (Mode/Layer normalisation, dataset fan-out, RRF fusion) live in one place.
func New ¶
New constructs a knowledge node. svc may be nil — in that case ExecuteBoard writes empty hits to the board instead of failing.
func (*Node) ExecuteBoard ¶
ExecuteBoard implements graph.Node. It runs one Service.Search per configured dataset (ScopeSingleDataset) or one global Search across every known dataset (ScopeAllDatasets), then publishes the hits onto the board under "hits" / "by_dataset" / "results".
func (*Node) InputPorts ¶
InputPorts implements graph.Node.
func (*Node) OutputPorts ¶
OutputPorts implements graph.Node. New callers should consume "hits" (typed []knowledge.Hit) and "by_dataset"; "results" carries the same content projected into []map[string]any for compatibility with older graphs that consume that key.