modules

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainOfThought

type ChainOfThought struct {
	Predict *Predict
}

func NewChainOfThought

func NewChainOfThought(signature core.Signature) *ChainOfThought

func (*ChainOfThought) Clone

func (c *ChainOfThought) Clone() core.Module

func (*ChainOfThought) Compose added in v0.1.0

func (c *ChainOfThought) Compose(next core.Module) core.Module

func (*ChainOfThought) GetSignature

func (c *ChainOfThought) GetSignature() core.Signature

func (*ChainOfThought) GetSubModules added in v0.1.0

func (c *ChainOfThought) GetSubModules() []core.Module

func (*ChainOfThought) Process

func (c *ChainOfThought) Process(ctx context.Context, inputs map[string]any, opts ...core.Option) (map[string]any, error)

func (*ChainOfThought) SetLLM

func (c *ChainOfThought) SetLLM(llm core.LLM)

func (*ChainOfThought) SetSignature added in v0.28.0

func (c *ChainOfThought) SetSignature(signature core.Signature)

SetSignature implements the core.Module interface.

func (*ChainOfThought) SetSubModules added in v0.1.0

func (c *ChainOfThought) SetSubModules(modules []core.Module)

func (*ChainOfThought) WithDefaultOptions added in v0.17.1

func (c *ChainOfThought) WithDefaultOptions(opts ...core.Option) *ChainOfThought

WithDefaultOptions sets default options by configuring the underlying Predict module.

type Module

type Module interface {
	Forward(inputs map[string]interface{}) (Predict, error)
}

type Predict

type Predict struct {
	core.BaseModule
	Demos []core.Example
	LLM   core.LLM
	// contains filtered or unexported fields
}

func NewPredict

func NewPredict(signature core.Signature) *Predict

func (*Predict) Clone

func (p *Predict) Clone() core.Module

func (*Predict) FormatOutputs

func (p *Predict) FormatOutputs(outputs map[string]interface{}) map[string]interface{}

func (*Predict) GetDemos

func (p *Predict) GetDemos() []core.Example

func (*Predict) GetLLMIdentifier added in v0.27.0

func (p *Predict) GetLLMIdentifier() map[string]string

GetLLMIdentifier implements the LMConfigProvider interface.

func (*Predict) GetSignature

func (p *Predict) GetSignature() core.Signature

func (*Predict) Process

func (p *Predict) Process(ctx context.Context, inputs map[string]interface{}, opts ...core.Option) (map[string]interface{}, error)

func (*Predict) SetDemos

func (p *Predict) SetDemos(demos []core.Example)

func (*Predict) SetLLM

func (p *Predict) SetLLM(llm core.LLM)

func (*Predict) ValidateInputs

func (p *Predict) ValidateInputs(inputs map[string]interface{}) error

func (*Predict) WithDefaultOptions added in v0.17.1

func (p *Predict) WithDefaultOptions(opts ...core.Option) *Predict

type ReAct

type ReAct struct {
	core.BaseModule
	Predict  *Predict
	Registry *tools.InMemoryToolRegistry
	MaxIters int
}

ReAct implements the ReAct agent loop (Reason, Action, Observation). It uses a Predict module to generate thoughts and actions, and executes tools.

func NewReAct

func NewReAct(signature core.Signature, registry *tools.InMemoryToolRegistry, maxIters int) *ReAct

NewReAct creates a new ReAct module. It takes a signature (which it modifies), a tool registry pointer, and max iterations.

func (*ReAct) Clone

func (r *ReAct) Clone() core.Module

Clone creates a copy of the ReAct module. Note: Predict module is cloned, but the LLM instance and ToolRegistry are shared. Cloning the registry itself might be complex and depends on the registry implementation. Sharing the registry is usually acceptable.

func (*ReAct) Process

func (r *ReAct) Process(ctx context.Context, inputs map[string]any, opts ...core.Option) (map[string]any, error)

Process executes the ReAct loop.

func (*ReAct) SetLLM

func (r *ReAct) SetLLM(llm core.LLM)

SetLLM sets the language model for both the base module and the internal Predict module.

func (*ReAct) WithDefaultOptions added in v0.17.1

func (r *ReAct) WithDefaultOptions(opts ...core.Option) *ReAct

WithDefaultOptions sets default options by configuring the underlying Predict module.

Jump to

Keyboard shortcuts

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