program

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FunCallPrompt = `` /* 414-byte string literal not displayed */
View Source
var MaxIterationNum = 50
View Source
var ReactPrompt = `` /* 2740-byte string literal not displayed */

Functions

func COT

func COT() *predictor

COT ...

func FunCall

func FunCall(opts ...option) *funcall

FunCall ...

func NewPredictor

func NewPredictor(i string, inputs map[string]string, opts ...option) *predictor

NewPredictor ...

func NewPredictorWithPrompt

func NewPredictorWithPrompt(prompt *Promptx, opts ...option) *predictor

NewPredictorWithPrompt ...

func Predictor

func Predictor(opts ...option) *predictor

Predictor ...

func ReAct

func ReAct(opts ...option) *react

ReAct ...

func SetLLM

func SetLLM(provider, model string)

SetLLM can not set concurrent

func WithInstruction

func WithInstruction(info string) option

WithInstruction ...

func WithLLM

func WithLLM(provider string, model string) option

func WithOutput

func WithOutput(tuple ...any) option

WithOutput ...

Types

type Adapter

type Adapter interface {
	Format(p *predictor, inputs map[string]any, target any) ([]llm.Message, error)
	Parse(string, any) error
}

Adapter ...

type Extra

type Extra struct {
	Responder   string
	ResponderID string
}

Extra ...

type Field

type Field struct {
	Name        string
	Type        reflect.Kind
	Description string
	Marker      string
	Kind        string // input or output
}

Field represents an input or output field in a signature

type JSONAdapter

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

JSONAdapter ...

func (*JSONAdapter) Format

func (ada *JSONAdapter) Format(p *predictor, inputs map[string]any, target any) ([]llm.Message, error)

Format ...

func (*JSONAdapter) Parse

func (ada *JSONAdapter) Parse(completion string, target any) error

Parse ...

type MarkableAdapter

type MarkableAdapter struct {
}

MarkableAdapter ...

func (*MarkableAdapter) Format

func (ada *MarkableAdapter) Format(p *predictor, inputs map[string]any) ([]llm.Message, error)

Format ...

func (*MarkableAdapter) Parse

func (ada *MarkableAdapter) Parse(completion string) map[string]any

Parse ...

type Memory

type Memory interface {
	FetchMemories(context.Context, int64) ([]llm.Message, error)
	SaveMemory(context.Context, int64, string, *Extra) error
}

Memory ...

type Program

type Program interface {
	Prompt() *Promptx
	Update(...option)
	Forward(context.Context, map[string]any) (any, error)
}

Program defines the interface for a program

type ProgramFunc

type ProgramFunc func(context.Context, string) (string, error)

ProgramFunc is a function that implements the Program interface

type Promptx

type Promptx struct {
	Name         string
	Description  string
	Instruction  string
	InputFields  map[string]*Field
	OutputFields map[string]*Field
}

Promptx defines the instruction and input/output about a program

func (*Promptx) ValidateInputs

func (m *Promptx) ValidateInputs(inputs map[string]any) error

ValidateInputs checks if the provided inputs match the signature

func (*Promptx) ValidateOutputs

func (m *Promptx) ValidateOutputs(outputs map[string]any) error

ValidateOutputs checks if the outputs match the signature

type RawAdapter

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

RawAdapter ...

func (*RawAdapter) Format

func (ada *RawAdapter) Format(p *predictor, inputs map[string]any, _ any) ([]llm.Message, error)

Format ...

func (*RawAdapter) Parse

func (ada *RawAdapter) Parse(completion string, target any) error

Parse ...

type ReactResult

type ReactResult struct {
	Tool *struct {
		Name string         `json:"name"`
		Args map[string]any `json:"args"`
	}
	Thoughts *struct {
		SelfReason string `json:"self_reason"`
		Text       string `json:"text"`
		Reason     string `json:"reasoning"`
		Plan       any    `json:"plan"`
		Critism    string `json:"criticism"`
		Speak      string `json:"speak"`
	} `json:"thoughts"`
}

type Result

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

func (*Result) Completion

func (r *Result) Completion() string

func (*Result) Error

func (r *Result) Error() error

func (*Result) Get

func (r *Result) Get(value any) error

func (*Result) Stream

func (r *Result) Stream() chan any

Jump to

Keyboard shortcuts

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