agent

package
v0.0.0-...-72bbb21 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

agent package defines the interface for the agent, which is the basic unit of the pipeline or workflow. Each agent process input data and produce output data, then user can connect multiple agents to form a pipeline. The both input and output are json, with an optional desc field and a data field.

{
    "desc": An optional description json object
    "data": A json object
}

The data and desc json object are agent specific and should have been documented by each agent.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExecOneNA   = fmt.Errorf("ExecuteOne not implemented")
	ErrYieldDone   = fmt.Errorf("Yield done")
	ErrStreamBreak = fmt.Errorf("Stream break")
)

Functions

func NewJqAgent

func NewJqAgent(qstr string) (*jq, error)

Types

type Agent

type Agent interface {
	// Config the agent with a config file
	Config(bs []byte) error
	// Execute the agent with input data, return the output data and error
	Execute(it iter.Seq2[[]byte, error], dict map[string]string) (iter.Seq2[[]byte, error], error)
	// ExecuteOne
	ExecuteOne(input []byte, dict map[string]string, yield func([]byte, error) bool) error
	// Close the agent
	Close() error
	// Set a value
	SetValue(key string, value interface{}) error
}

type AgentFanOut

type AgentFanOut struct {
	NilKVAgent
	NilConfigAgent
	Agents []Agent
}

func (*AgentFanOut) Close

func (af *AgentFanOut) Close() error

func (*AgentFanOut) Execute

func (af *AgentFanOut) Execute(input iter.Seq2[[]byte, error], dict map[string]string) (iter.Seq2[[]byte, error], error)

func (*AgentFanOut) ExecuteOne

func (af *AgentFanOut) ExecuteOne(input []byte, dict map[string]string, yield func([]byte, error) bool) error

type AgentPipe

type AgentPipe struct {
	NilKVAgent
	NilCloseAgent
	// contains filtered or unexported fields
}

func (*AgentPipe) AddAgent

func (ap *AgentPipe) AddAgent(agent Agent)

func (*AgentPipe) Close

func (ap *AgentPipe) Close() error

func (*AgentPipe) Execute

func (ap *AgentPipe) Execute(it iter.Seq2[[]byte, error], dict map[string]string) (iter.Seq2[[]byte, error], error)

func (*AgentPipe) ExecuteOne

func (ap *AgentPipe) ExecuteOne(input []byte, dict map[string]string, yield func([]byte, error) bool) error

type NilCloseAgent

type NilCloseAgent struct {
}

func (*NilCloseAgent) Close

func (na *NilCloseAgent) Close() error

type NilConfigAgent

type NilConfigAgent struct {
}

func (*NilConfigAgent) Config

func (na *NilConfigAgent) Config(bs []byte) error

type NilKVAgent

type NilKVAgent struct {
}

func (*NilKVAgent) SetValue

func (na *NilKVAgent) SetValue(key string, value interface{}) error

type SimpleExecuteAgent

type SimpleExecuteAgent struct {
	Self Agent
}

func (*SimpleExecuteAgent) Execute

func (sa *SimpleExecuteAgent) Execute(input iter.Seq2[[]byte, error], dict map[string]string) (iter.Seq2[[]byte, error], error)

type StringArrayAgent

type StringArrayAgent struct {
	NilConfigAgent
	NilCloseAgent
	// contains filtered or unexported fields
}

func NewStringArrayAgent

func NewStringArrayAgent(values []string) *StringArrayAgent

func (*StringArrayAgent) Execute

func (sa *StringArrayAgent) Execute(input iter.Seq2[[]byte, error], dict map[string]string) (iter.Seq2[[]byte, error], error)

func (*StringArrayAgent) ExecuteOne

func (sa *StringArrayAgent) ExecuteOne(input []byte, dict map[string]string, yield func([]byte, error) bool) error

func (*StringArrayAgent) SetValue

func (sa *StringArrayAgent) SetValue(name string, value interface{}) error

Directories

Path Synopsis
Package dbagent implements a database agent that can read or write database.
Package dbagent implements a database agent that can read or write database.

Jump to

Keyboard shortcuts

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