knowledgenode

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: 9 Imported by: 0

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

View Source
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

func Register

func Register(factory *node.Factory, svc *knowledge.Service)

Register binds the "knowledge" node builder onto factory. svc may be nil (the node will return empty hits at execution time).

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

func ConfigFromMap(m map[string]any) Config

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 DatasetQuery struct {
	DatasetID string `json:"dataset_id"`
	StateKey  string `json:"state_key"`
	TopK      int    `json:"top_k"`
}

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

func New(id string, svc *knowledge.Service, cfg Config) *Node

New constructs a knowledge node. svc may be nil — in that case ExecuteBoard writes empty hits to the board instead of failing.

func (*Node) Config

func (n *Node) Config() map[string]any

Config implements graph.Node.

func (*Node) ExecuteBoard

func (n *Node) ExecuteBoard(ectx graph.ExecutionContext, board *graph.Board) error

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) ID

func (n *Node) ID() string

ID implements graph.Node.

func (*Node) InputPorts

func (n *Node) InputPorts() []graph.Port

InputPorts implements graph.Node.

func (*Node) OutputPorts

func (n *Node) OutputPorts() []graph.Port

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.

func (*Node) SetConfig

func (n *Node) SetConfig(c map[string]any)

SetConfig implements graph.Node.

func (*Node) Type

func (n *Node) Type() string

Type implements graph.Node.

Jump to

Keyboard shortcuts

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