nodes

package
v0.0.0-...-157f31e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentNode

type AgentNode struct {
	*BaseNode
	// contains filtered or unexported fields
}

func NewAgentNode

func NewAgentNode(name, description string, agent agents.Agent, inputs ...*core.Variable) *AgentNode

func (*AgentNode) Execute

func (a *AgentNode) Execute(ctx core.Context) error

type BaseNode

type BaseNode struct {
	// contains filtered or unexported fields
}

BaseNode 基础节点实现

func NewBaseNode

func NewBaseNode(name, description string, inputs ...*core.Variable) *BaseNode

NewBaseNode 创建新的基础节点

func (*BaseNode) AddInputs

func (n *BaseNode) AddInputs(variables ...*core.Variable)

AddInputs 添加输入变量

func (*BaseNode) Description

func (n *BaseNode) Description() string

Description 返回节点的描述

func (*BaseNode) Execute

func (n *BaseNode) Execute(ctx core.Context) error

Execute 执行节点逻辑(基础实现,子类需要重写)

func (*BaseNode) GetInputValues

func (n *BaseNode) GetInputValues(ctx core.Context) (map[string]any, error)

func (*BaseNode) GetNodeContext

func (n *BaseNode) GetNodeContext(ctx core.Context) (*core.NodeContext, error)

func (*BaseNode) ID

func (n *BaseNode) ID() string

ID 返回节点的唯一标识符

func (*BaseNode) InputVariables

func (n *BaseNode) InputVariables() []*core.Variable

InputVariables 返回节点的输入变量列表

func (*BaseNode) Name

func (n *BaseNode) Name() string

Name 返回节点的名称

func (*BaseNode) SetID

func (n *BaseNode) SetID(id string)

SetID 设置节点的ID

type BranchNode

type BranchNode struct {
	*BaseNode
	// contains filtered or unexported fields
}

BranchNode 分支节点实现

func NewBranchNode

func NewBranchNode(name, description, expression string) *BranchNode

NewBranchNode 创建新的分支节点

func (*BranchNode) AddTarget

func (b *BranchNode) AddTarget(expressionResult any, targetNodeId string)

AddTarget 添加分支目标

func (*BranchNode) Execute

func (b *BranchNode) Execute(ctx core.Context) error

Execute 执行分支节点逻辑

type ChatNode

type ChatNode struct {
	*BaseNode
	// contains filtered or unexported fields
}

ChatNode LLM节点实现

func NewChatNode

func NewChatNode(name, description string, options ...ChatNodeOption) *ChatNode

NewChatNode 创建新的LLM节点

func (*ChatNode) Execute

func (l *ChatNode) Execute(ctx core.Context) error

Execute 执行LLM节点逻辑

type ChatNodeOption

type ChatNodeOption func(*ChatNode)

func WithCallOption

func WithCallOption(callOptions ...llms.CallOption) ChatNodeOption

func WithInputs

func WithInputs(inputs ...*core.Variable) ChatNodeOption

func WithLLMModel

func WithLLMModel(model llms.Model) ChatNodeOption

func WithPromptTemplates

func WithPromptTemplates(templates ...*ChatTemplate) ChatNodeOption

type ChatTemplate

type ChatTemplate struct {
	Content        string
	Role           llms.ChatMessageType
	InputVariables []string
}

type Function

type Function func(node *FunctionNode, ctx core.Context) error

type FunctionNode

type FunctionNode struct {
	*BaseNode
	// contains filtered or unexported fields
}

FunctionNode 函数节点实现

func NewFunctionNode

func NewFunctionNode(name, description string, executeFn Function, inputs ...*core.Variable) *FunctionNode

NewFunctionNode 创建新的函数节点

func (*FunctionNode) Execute

func (f *FunctionNode) Execute(ctx core.Context) error

Execute 执行函数节点逻辑

type InputNode

type InputNode struct {
	*BaseNode
}

func NewInputNode

func NewInputNode(name, description string, inputs ...*core.Variable) *InputNode

func (*InputNode) Execute

func (n *InputNode) Execute(ctx core.Context) error

type Register

type Register struct {
	// contains filtered or unexported fields
}

func NewRegister

func NewRegister() *Register

func (*Register) GetFunction

func (r *Register) GetFunction(name string) (Function, error)

func (*Register) GetService

func (r *Register) GetService(name string) (Service, error)

func (*Register) RegisterFunction

func (r *Register) RegisterFunction(name string, fn Function)

func (*Register) RegisterService

func (r *Register) RegisterService(name string, service Service)

type Service

type Service interface {
	Name() string
	Execute(node core.Node, ctx core.Context) error
}

type ServiceNode

type ServiceNode struct {
	*BaseNode
	// contains filtered or unexported fields
}

func NewServiceNode

func NewServiceNode(name, description string, service Service, inputs ...*core.Variable) *ServiceNode

func (*ServiceNode) Execute

func (s *ServiceNode) Execute(ctx core.Context) error

Jump to

Keyboard shortcuts

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