schema

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgTypeMsg      = "MSG"
	MsgTypeCreative = "CREATIVE"
	MsgTypeSOP      = "SOP"
	MsgTypeEnd      = "END"
)
View Source
const (
	MsgAllReceiver = "ALL"
)

Variables

View Source
var (
	ErrMissingLLM          = errors.New("missing field LLM")
	ErrMissingEnv          = errors.New("missing field Env")
	ErrMissingPrompt       = errors.New("missing fill in prompt")
	ErrMissingName         = errors.New("missing agent name")
	ErrMissingDesc         = errors.New("missing agent desc")
	ErrMissingSop          = errors.New("missing sop")
	ErrAgentNoReturn       = errors.New("no actions or finish was returned by the agent")
	ErrNotFinished         = errors.New("agent not finished before max iterations")
	ErrParsePromptTemplate = errors.New("parse prompt template error")
)

Functions

func ConvertAgentDescriptions

func ConvertAgentDescriptions(agents []Agent) string

func ConvertAgentNames

func ConvertAgentNames(agents []Agent) string

func ConvertConstructScratchPad

func ConvertConstructScratchPad(name, self string, messages []Message, steps []StepAction) string

func ConvertToolDescriptions

func ConvertToolDescriptions(actions []tool.Tool) string

func ConvertToolNames

func ConvertToolNames(actions []tool.Tool) string

Types

type Agent

type Agent interface {
	Run(ctx context.Context, messages []Message, opts ...llm.GenerateOption) (*Generation, error)

	Name() string

	Description() string

	WithEnv(env Environment)

	Env() Environment

	Tools() []tool.Tool
}

Agent is the interface all agents must implement.

type Document

type Document struct {
	PageContent string
	Metadata    map[string]any
	Score       float32
}

Document is the interface for interacting with a document.

type Environment

type Environment interface {
	// Produce produce msg
	Produce(ctx context.Context, msgs ...Message) error
	// Consume consume msg
	Consume(ctx context.Context) *Message

	// SOP task SOP
	SOP() string
	// GetTeam all team members
	GetTeam() []Agent
	// GetTeamLeader team Leader
	GetTeamLeader() Agent

	// LoadMemory get Agent's historical msg
	LoadMemory(ctx context.Context, receiver Agent) []Message

	GetSubscribeAgents(_ context.Context, subscribed Agent) []Agent
}

type Generation

type Generation struct {
	// Generated text output.
	Messages []Message
	// Raw generation info response from the provider.
	// May include things like reason for finishing (e.g. in OpenAI).
	TotalTokens int
}

Generation is the output of a single generation.

type Memory

type Memory interface {
	Load(ctx context.Context, filter func(index, consumption int, message Message) bool) []Message

	// LoadNext load next msg,filter check next msg,if not passed,then do not return
	LoadNext(ctx context.Context, filter func(message Message) bool) *Message

	Save(ctx context.Context, msg Message) error
	// Clear memory contents.
	Clear(ctx context.Context) error
}

Memory is the interface for memory in chains.

type Message

type Message struct {
	Type      string `json:"cate"`
	Thought   string `json:"thought"`
	Content   string `json:"content"`
	Sender    string `json:"sender"`
	Receiver  string `json:"receiver"`
	Condition string `json:"condition"`
	Token     int    `json:"token"`
	Log       string
	// control msg, to remove and update Agent
	MngInfo     *MngInfo
	AllReceiver []string
}

func (*Message) IsCreative

func (m *Message) IsCreative() bool

func (*Message) IsEnd

func (m *Message) IsEnd() bool

func (*Message) IsMsg

func (m *Message) IsMsg() bool

func (*Message) IsSOP

func (m *Message) IsSOP() bool

func (*Message) Receivers

func (m *Message) Receivers() []string

type MngInfo

type MngInfo struct {
	Create []struct {
		Name        string   `json:"name"`
		Description string   `json:"description"`
		Tools       []string `json:"tools"`
		Prompt      string   `json:"prompt"`
	} `json:"create"`
	Select []string `json:"select"`
	Remove []string `json:"remove"`
}

type StepAction

type StepAction struct {
	Id          string `json:"id"`
	Action      string `json:"action"`
	Thought     string `json:"thought"`
	Input       string `json:"input"`
	Feedback    string `json:"feedback"`
	Log         string `json:"log"`
	Observation string `json:"observation"`
}

StepAction is the agent's action to take.

type StepActionInput added in v0.2.0

type StepActionInput struct {
	Input any `json:"input"`
}

type StepFeedback

type StepFeedback struct {
	Feedback string `json:"feedback"`
	Log      string
}

StepFeedback is the agent's action to take.

type StepType

type StepType struct {
	Type string `json:"type"`
}

type Subscribe

type Subscribe struct {
	Subscribed Agent
	Subscriber Agent
	Condition  string
}

Jump to

Keyboard shortcuts

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