chain

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MulanPSL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOptionOutputKey = "output"
)
View Source
const (
	LLMRequestLimit = 10
)
View Source
const (
	ToolLLMRequestLimit = 10
)

Variables

This section is empty.

Functions

func InitChain

func InitChain(ch Chain, log utils.TraceLog, opt Option) (err error)

func InitLLMChain

func InitLLMChain(ch LLMChain, llm llms.LLM, log utils.TraceLog, opt Option) (err error)

func NewChainNode

func NewChainNode(desc string, ch Chain) *_ChainNode

Types

type Chain

type Chain interface {
	Desc() string

	SetTraceLog(utils.TraceLog) error
	GetTraceLog() utils.TraceLog

	SetOption(Option) error
	GetOption() Option

	Init() error
	Run(context.Context, *llms.Input) (*llms.Output, error)
}

type LLMChain

type LLMChain interface {
	Chain

	GetLLM() llms.LLM
	SetLLM(llms.LLM) error
}

type Option

type Option interface {
	SetParamManager(utils.ParamsChainManager) Option
	SetOutput(string) Option
	SetInput(...string) Option
	SetRoleName(string) Option

	GetParamManager() utils.ParamsChainManager
	GetOutput() string
	GetInput() []string
	GetRoleName() string
}

func NewOption

func NewOption() Option

type PromptChain

type PromptChain struct {
	SimpleLLMChain
	// contains filtered or unexported fields
}

func NewPromptChain

func NewPromptChain(tmp prompt.Prompt, llm llms.LLM, log utils.TraceLog, opt Option) (ret *PromptChain, err error)

func NewStringPromptChain

func NewStringPromptChain(tmp string, llm llms.LLM, log utils.TraceLog, opt Option) (ret *PromptChain, err error)

func NewTemplatePromptChain

func NewTemplatePromptChain(tmp string, llm llms.LLM, log utils.TraceLog, opt Option) (ret *PromptChain, err error)

func (*PromptChain) Desc

func (ch *PromptChain) Desc() string

func (*PromptChain) Run

func (ch *PromptChain) Run(ctx context.Context, input *llms.Input) (ret *llms.Output, err error)

func (*PromptChain) SetPrompt

func (ch *PromptChain) SetPrompt(val prompt.Prompt) error

type PromptToolChain added in v0.0.2

type PromptToolChain struct {
	PromptToolChainBase
}

func NewPromptToolChain added in v0.0.2

func NewPromptToolChain(tmp prompt.Prompt, llm llms.LLM, box llms.ToolBox, log utils.TraceLog, opt Option) (ret *PromptToolChain, err error)

func NewStringPromptToolChain added in v0.0.2

func NewStringPromptToolChain(tmp string, llm llms.LLM, box llms.ToolBox, log utils.TraceLog, opt Option) (ret *PromptToolChain, err error)

func NewTemplatePromptToolChain added in v0.0.2

func NewTemplatePromptToolChain(tmp string, llm llms.LLM, box llms.ToolBox, log utils.TraceLog, opt Option) (ret *PromptToolChain, err error)

func (*PromptToolChain) Run added in v0.0.2

func (ch *PromptToolChain) Run(ctx context.Context, input *llms.Input) (ret *llms.Output, err error)

type PromptToolChainBase added in v0.0.4

type PromptToolChainBase struct {
	PromptChain
	// contains filtered or unexported fields
}

func (*PromptToolChainBase) Desc added in v0.0.4

func (ch *PromptToolChainBase) Desc() string

func (*PromptToolChainBase) GetToolBox added in v0.0.4

func (ch *PromptToolChainBase) GetToolBox() llms.ToolBox

func (*PromptToolChainBase) SetLLM added in v0.0.4

func (ch *PromptToolChainBase) SetLLM(llm llms.LLM) error

func (*PromptToolChainBase) SetToolBox added in v0.0.4

func (ch *PromptToolChainBase) SetToolBox(box llms.ToolBox) error

type PromptToolChainEx added in v0.0.4

type PromptToolChainEx struct {
	PromptToolChainBase
}

func NewPromptToolChainEx added in v0.0.4

func NewPromptToolChainEx(tmp prompt.Prompt, llm llms.LLM, box llms.ToolBox, log utils.TraceLog, opt Option) (ret *PromptToolChainEx, err error)

func NewStringPromptToolChainEx added in v0.0.4

func NewStringPromptToolChainEx(tmp string, llm llms.LLM, box llms.ToolBox, log utils.TraceLog, opt Option) (ret *PromptToolChainEx, err error)

func NewTemplatePromptToolChainEx added in v0.0.4

func NewTemplatePromptToolChainEx(tmp string, llm llms.LLM, box llms.ToolBox, log utils.TraceLog, opt Option) (ret *PromptToolChainEx, err error)

func (*PromptToolChainEx) Run added in v0.0.4

func (ch *PromptToolChainEx) Run(ctx context.Context, input *llms.Input) (ret *llms.Output, err error)

type RouterChain

type RouterChain struct {
	SimpleLLMChain
	// contains filtered or unexported fields
}

func NewRouterChain

func NewRouterChain(llm llms.LLM, log utils.TraceLog, opt Option) (ret *RouterChain, err error)

func (*RouterChain) Add

func (ch *RouterChain) Add(name, desc string, node Chain)

func (*RouterChain) Delete

func (ch *RouterChain) Delete(name string)

func (*RouterChain) Desc

func (ch *RouterChain) Desc() string

func (*RouterChain) Init

func (ch *RouterChain) Init() error

func (*RouterChain) Run

func (ch *RouterChain) Run(ctx context.Context, input *llms.Input) (ret *llms.Output, err error)

func (*RouterChain) SetOption

func (ch *RouterChain) SetOption(opt Option) error

type RouterOption

type RouterOption struct {
	SimpleOption
	// contains filtered or unexported fields
}

func NewRouterOption

func NewRouterOption() *RouterOption

func (*RouterOption) GetInput

func (op *RouterOption) GetInput() []string

func (*RouterOption) GetOutput

func (op *RouterOption) GetOutput() string

func (*RouterOption) GetParamManager

func (op *RouterOption) GetParamManager() utils.ParamsChainManager

func (*RouterOption) GetRoleName

func (op *RouterOption) GetRoleName() string

func (*RouterOption) SetInput

func (op *RouterOption) SetInput(v ...string) Option

func (*RouterOption) SetOutput

func (op *RouterOption) SetOutput(v string) Option

func (*RouterOption) SetParamManager

func (op *RouterOption) SetParamManager(pm utils.ParamsChainManager) Option

func (*RouterOption) SetRoleName

func (op *RouterOption) SetRoleName(v string) Option

func (*RouterOption) SetRouterParser

func (op *RouterOption) SetRouterParser(router router.Parser) *RouterOption

type SequenceChain

type SequenceChain struct {
	SimpleChain
	// contains filtered or unexported fields
}

func NewSequenceChain

func NewSequenceChain(log utils.TraceLog, opt Option) (ret *SequenceChain, err error)

func (*SequenceChain) Desc

func (ch *SequenceChain) Desc() string

func (*SequenceChain) Pop

func (ch *SequenceChain) Pop()

func (*SequenceChain) Push

func (ch *SequenceChain) Push(desc string, node Chain)

func (*SequenceChain) Run

func (ch *SequenceChain) Run(ctx context.Context, input *llms.Input) (*llms.Output, error)

type SimpleChain

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

func (*SimpleChain) Desc

func (ch *SimpleChain) Desc() string

func (*SimpleChain) GetOption

func (ch *SimpleChain) GetOption() Option

func (*SimpleChain) GetTraceLog

func (ch *SimpleChain) GetTraceLog() utils.TraceLog

func (*SimpleChain) Init

func (ch *SimpleChain) Init() error

func (*SimpleChain) Run

func (ch *SimpleChain) Run(_ context.Context, _ *llms.Input) (*llms.Output, error)

func (*SimpleChain) SetOption

func (ch *SimpleChain) SetOption(opt Option) error

func (*SimpleChain) SetTraceLog

func (ch *SimpleChain) SetTraceLog(log utils.TraceLog) error

type SimpleLLMChain

type SimpleLLMChain struct {
	SimpleChain
	// contains filtered or unexported fields
}

func (*SimpleLLMChain) GetLLM

func (ch *SimpleLLMChain) GetLLM() llms.LLM

func (*SimpleLLMChain) Init

func (ch *SimpleLLMChain) Init() error

func (*SimpleLLMChain) SetLLM

func (ch *SimpleLLMChain) SetLLM(llm llms.LLM) error

type SimpleOption

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

func (*SimpleOption) GetInput

func (op *SimpleOption) GetInput() []string

func (*SimpleOption) GetOutput

func (op *SimpleOption) GetOutput() string

func (*SimpleOption) GetParamManager

func (op *SimpleOption) GetParamManager() utils.ParamsChainManager

func (*SimpleOption) GetRoleName

func (op *SimpleOption) GetRoleName() string

func (*SimpleOption) SetInput

func (op *SimpleOption) SetInput(v ...string) Option

func (*SimpleOption) SetOutput

func (op *SimpleOption) SetOutput(v string) Option

func (*SimpleOption) SetParamManager

func (op *SimpleOption) SetParamManager(pm utils.ParamsChainManager) Option

func (*SimpleOption) SetRoleName

func (op *SimpleOption) SetRoleName(v string) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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