Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertAgentDescriptions(agents []Agent) string
- func ConvertAgentNames(agents []Agent) string
- func ConvertConstructScratchPad(name, self string, messages []Message, steps []StepAction) string
- func ConvertToolDescriptions(actions []tool.Tool) string
- func ConvertToolNames(actions []tool.Tool) string
- type Agent
- type Document
- type Environment
- type Generation
- type Memory
- type Message
- type MngInfo
- type StepAction
- type StepActionInput
- type StepFeedback
- type StepType
- type Subscribe
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 ConvertAgentNames ¶
func ConvertConstructScratchPad ¶
func ConvertConstructScratchPad(name, self string, messages []Message, steps []StepAction) string
func ConvertToolDescriptions ¶
func ConvertToolNames ¶
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 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 ¶
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 ¶
StepFeedback is the agent's action to take.
Click to show internal directories.
Click to hide internal directories.