Documentation
¶
Index ¶
- Constants
- func WithPersonality(personality string) func(kw *newKwargs)
- func WithSkills(skills ...Skill) func(kw *newKwargs)
- func WithTools(tools ...Tool) func(kw *newKwargs)
- type Agent
- type AgentMode
- type AgentModelBuilder
- type AvailableToolDefinition
- type FragmentSelectorModelBuilder
- type InsertedSkill
- type Message
- type MessageStreamer
- type ModelBuilder
- type NewOpt
- type Notification
- type SendMessageOpt
- type SerialisedMessage
- type SerialisedMessageKind
- type Skill
- type SkillSelector
- type TextStreamer
- type Tool
- type ToolCall
- type ToolCallArg
- type ToolResponse
Constants ¶
View Source
const ( ModeCollectContext = iota ModeReasonAct ModeAnswerUser )
Variables ¶
This section is empty.
Functions ¶
func WithPersonality ¶ added in v0.0.6
func WithPersonality(personality string) func(kw *newKwargs)
func WithSkills ¶ added in v0.0.6
func WithSkills(skills ...Skill) func(kw *newKwargs)
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.0.6
func New(mb ModelBuilder, opts ...NewOpt) *Agent
func NewFromSaved ¶ added in v0.0.6
func NewFromSaved(mb ModelBuilder, messages []Message, opts ...NewOpt) *Agent
type AgentModelBuilder ¶
type AvailableToolDefinition ¶
type InsertedSkill ¶ added in v0.0.6
type Message ¶
type Message interface {
// contains filtered or unexported methods
}
Message is a sum type defining the structured data that can live in agent history.
func DeserialiseMessages ¶ added in v0.0.8
func DeserialiseMessages(smsgs []SerialisedMessage) []Message
type MessageStreamer ¶
type MessageStreamer interface {
// Try to send a message, ignoring errors.
TrySendMessage(msg Message)
}
MessageStreamer defines a callback interface that can be used to listen to new messages that the agent creates.
type ModelBuilder ¶
type ModelBuilder interface {
AgentModelBuilder
FragmentSelectorModelBuilder
}
type Notification ¶ added in v0.0.8
type SendMessageOpt ¶
type SendMessageOpt func(*sendMessageKwargs)
func WithMessageStreamer ¶
func WithMessageStreamer(streamer MessageStreamer) SendMessageOpt
In addition to other message streamers, use the provided streamer.
func WithNotifications ¶
func WithNotifications(notifications ...Notification) SendMessageOpt
func WithResponseStreamer ¶
func WithResponseStreamer(streamer TextStreamer) SendMessageOpt
In addition to other response streamers, use the provided streamer.
type SerialisedMessage ¶ added in v0.0.8
type SerialisedMessage struct {
Kind SerialisedMessageKind `json:"kind"`
Content string `json:"content,omitempty"`
Reasoning string `json:"reasoning,omitempty"`
NotificationKind string `json:"notification_kind,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
Responses []ToolResponse `json:"responses,omitempty"`
Skills []InsertedSkill `json:"skills,omitempty"`
AvailableTools []AvailableToolDefinition `json:"available_tools,omitempty"`
Mode AgentMode `json:"mode,omitempty"`
Personality string `json:"personality,omitempty"`
}
func SerialiseMessages ¶ added in v0.0.8
func SerialiseMessages(msgs []Message) []SerialisedMessage
type SerialisedMessageKind ¶ added in v0.0.8
type SerialisedMessageKind string
const ( KindSystem SerialisedMessageKind = "system" KindUser SerialisedMessageKind = "user" KindAgent SerialisedMessageKind = "agent" KindToolCalls SerialisedMessageKind = "tool_calls" KindToolResponse SerialisedMessageKind = "tool_response" KindNotification SerialisedMessageKind = "notification" KindSkills SerialisedMessageKind = "skills" KindAvailableTools SerialisedMessageKind = "available_tools" KindModeSwitch SerialisedMessageKind = "mode_switch" KindPersonality SerialisedMessageKind = "personality" )
type Skill ¶ added in v0.0.4
type Skill struct {
// A sensible snake_case key
Key string
// When should this be applied? If empty will always be applied.
When string
// The content that is not seen by the selector but is seen by the agent when chosen.
Content string
// How many turns after the turn it is inserted will the skill remain in context
RemainFor int
}
func (Skill) IsConditional ¶ added in v0.0.4
type SkillSelector ¶ added in v0.0.4
type SkillSelector interface {
// Select any relevant [Skill]s that should be added to the conversation.
SelectSkills([]Skill, []Message) ([]Skill, error)
}
SkillSelector defines an object that can choose relevant [Skill]s to a conversation.
func NewSkillSelector ¶ added in v0.0.4
func NewSkillSelector(modelBuilder FragmentSelectorModelBuilder) SkillSelector
type TextStreamer ¶
type TextStreamer interface {
// Try to send a response text chunk back, ignoring errors.
TrySendTextChunk(chunk string)
}
TextStreamer defines a callback interface that can be used to listen to text being streamed back from the final agent response.
type Tool ¶
type Tool interface {
// The name of the tool to be used by the agent. Should probably be snake_case.
Name() string
// Describe the tool in short bullet points to the agent.
// Includes which parameters to provide.
// Parameters can be described as any json type.
Description() []string
// Call the tool, providing a formatted response or an error if the tool call failed.
// The values of the args will be the direct result of json decoding the tool call args.
Call(map[string]any) (string, error)
}
Tool is a runnable object that can be both described to and called by an agent.
type ToolCall ¶
type ToolCall struct {
ToolName string
ToolArgs []ToolCallArg
}
type ToolCallArg ¶
type ToolResponse ¶
type ToolResponse struct {
Response string
}
Click to show internal directories.
Click to hide internal directories.