Documentation
¶
Overview ¶
Package go-hypher enables creating AI agents as computational graphs.
An agent is represented as a weighted Directed Acyclic Graph (DAG) which consists of nodes that perform a specific operation during agent execution aka Hypher Run.
Hypher Run executes all the nodes in the hypher Graph and computes the results of their operations. All the outputs of the nodes are then passed to theis successors which then use them as their inputs. This continues all the way down to the hypher graph output nodes where the agent result is stored and can be fetched from.
Given the agents are DAGs, they can form ensambles of agents through additional edges that link the agent DAGs as long as the resulting graph is also a DAG.
Index ¶
- type Adder
- type ConcMode
- type DOTEdge
- type DOTGraph
- type DOTNode
- type Edge
- type EdgeUpdater
- type Execer
- type Graph
- type Inputer
- type LabelSetter
- type Loader
- type Marshaler
- type Node
- type NodeUpdater
- type Nodes
- type Op
- type Option
- func WithAttrs(attrs map[string]any) Option
- func WithConcMode(mode ConcMode) Option
- func WithDotID(dotid string) Option
- func WithGraph(g Graph) Option
- func WithID(id int64) Option
- func WithLabel(label string) Option
- func WithOp(op Op) Option
- func WithUID(uid string) Option
- func WithWeight(weight float64) Option
- type Options
- type Outputer
- type Remover
- type Reseter
- type Runner
- type Syncer
- type UIDSetter
- type Unmarshaler
- type Updater
- type Value
- type WeightSetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adder ¶
type Adder interface {
Graph
graph.NodeAdder
graph.WeightedEdgeAdder
}
Adder allows to add edges and nodes to graph.
type DOTGraph ¶
type DOTGraph interface {
Graph
encoding.Attributer
// DOTID returns DOT ID.
DOTID() string
// SetDOTID sets DOT ID.
SetDOTID(dotid string)
// DOTAttributers sets DOT graph attributes.
DOTAttributers() (graph, node, edge encoding.Attributer)
}
DOTNGraph is Graphviz DOT graph.
type DOTNode ¶
type DOTNode interface {
Node
encoding.Attributer
// DOTID returns DOT ID.
DOTID() string
// SetDOTID sets DOT ID.
SetDOTID(dotid string)
}
DOTNode is Graphviz DOT node.
type Edge ¶
type Edge interface {
graph.WeightedEdge
// UID returns edge UID.
UID() string
// Label returns edge label.
Label() string
// Attrs returns node attributes.
Attrs() map[string]any
// String is useful for debugging.
String() string
}
Edge is a graph edge.
type EdgeUpdater ¶
type EdgeUpdater interface {
Graph
graph.WeightedEdgeAdder
graph.EdgeRemover
}
EdgeUpdater adds and removes edges.
type Execer ¶
type Execer interface {
// Exec executes an operation with the given inputs and returns the results.
Exec(ctx context.Context, inputs ...Value) ([]Value, error)
}
Execer executes a hypher operation. This usually means executing the hypher Node, by running its Op.
type Graph ¶
type Graph interface {
graph.Weighted
// UID returns graph UID.
UID() string
// Edges returns graph edges iterator.
Edges() graph.Edges
// Label returns graph label.
Label() string
// Attrs are graph attributes.
Attrs() map[string]any
// String is useful for debugging.
String() string
}
Graph is weighted graph.
type Inputer ¶
type Inputer interface {
// Inputs returns input values.
Inputs() []Value
}
Inputer returns its inputs.
type Node ¶
type Node interface {
graph.Node
// UID returns node UID.
UID() string
// Label returns node label.
Label() string
// Attrs returns node attributes.
Attrs() map[string]any
// String is useful for debugging.
String() string
}
Node is a graph node.
type NodeUpdater ¶
type NodeUpdater interface {
Graph
graph.NodeAdder
graph.NodeRemover
}
NodeUpdater adds and removes nodes.
type Op ¶
type Op interface {
// Type of the Op.
Type() string
// Desc describes the Op.
Desc() string
// Do runs the Op.
Do(ctx context.Context, inputs ...Value) ([]Value, error)
// String is useful for debugging.
String() string
}
Op is an operation run by a Node.
type Options ¶
type Options struct {
// ID configures ID
ID int64
// UID configures UID
UID string
// Label configures Label.
Label string
// Attrs configures Attrs.
Attrs map[string]any
// DotID configures DOT ID
DotID string
// Weight configures Edge weight.
Weight float64
// Graph configures Node's graph
Graph Graph
// ConcMode configures Graph run concurrency mode.
ConcMode ConcMode
// Op configures Node's Op.
Op Op
}
Options configure graph.
type Outputer ¶
type Outputer interface {
// Outputs returns output values.
Outputs() []Value
}
Outputer returns its outputs.
type Remover ¶
type Remover interface {
Graph
graph.NodeRemover
graph.EdgeRemover
}
Remover allows to remove nodes and edges from graph.
type Reseter ¶
type Reseter interface {
// Reset inputs and outputs.
Reset()
}
Reseter resets inputs and outputs.
type Runner ¶
type Runner interface {
// Run an operation with the given inputs and options.
Run(ctx context.Context, inputs map[string]Value, opts ...Option) error
}
Runner is used to trigger a hypher Run. This usually means running the hypher Graph, by executing all its nodes.
type Unmarshaler ¶
type Unmarshaler interface {
// Unmarshal unmarshals arbitrary bytes into graph.
Unmarshal([]byte, Graph) error
}
Unmarshaler is used for unmarshaling graphs.