agents

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package agents include BaseAgent

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent[T schema.Schema, O schema.Schema] struct {
	Config
}

Agent class for chat agents. This class provides the core functionality for handling chat interactions, including managing memory, generating system prompts, and obtaining responses from a language model.

func NewAgent

func NewAgent[I schema.Schema, O schema.Schema](options ...Option) *Agent[I, O]

NewAgent initializes the AgentAgent

func (*Agent[I, O]) RegisterSystemPromptContextProvider

func (a *Agent[I, O]) RegisterSystemPromptContextProvider(provider systemprompt.ContextProvider)

RegisterSystemPromptContextProvider registers a new context provider

func (*Agent[I, O]) ResetMemory

func (a *Agent[I, O]) ResetMemory()

ResetMemory resets the memory to its initial state

func (*Agent[I, O]) Run

func (a *Agent[I, O]) Run(ctx context.Context, userInput *I, output *O, apiResp *components.ApiResponse) error

Run runs the chat agent with the given user input synchronously.

func (*Agent[I, O]) SetClient

func (a *Agent[I, O]) SetClient(clt instructor.Instructor)

func (*Agent[I, O]) SetMaxTokens

func (a *Agent[I, O]) SetMaxTokens(maxTokens int)

func (*Agent[I, O]) SetMemory

func (a *Agent[I, O]) SetMemory(m *components.Memory)

func (*Agent[I, O]) SetModel

func (a *Agent[I, O]) SetModel(model string)

func (*Agent[I, O]) SetSystemPromptGenerator

func (a *Agent[I, O]) SetSystemPromptGenerator(g *systemprompt.Generator)

func (*Agent[I, O]) SetTemperature

func (a *Agent[I, O]) SetTemperature(temperature float32)

func (*Agent[I, O]) SystemPrompt

func (a *Agent[I, O]) SystemPrompt() string

SystemPrompt returns the system prompt

func (*Agent[I, O]) SystemPromptContextProvider

func (a *Agent[I, O]) SystemPromptContextProvider(title string) (systemprompt.ContextProvider, error)

SystemPromptContextProvider returns agent systemPromptGenerator's context provider

func (*Agent[I, O]) UnregisterSystemPromptContextProvider

func (a *Agent[I, O]) UnregisterSystemPromptContextProvider(title string)

RegisterSystemPromptContextProvider Unregisters an existing context provider.

type AgentSetter

type AgentSetter interface {
	SetClient(clt instructor.Instructor)
	SetMemory(m *components.Memory)
	SetSystemPromptGenerator(g *systemprompt.Generator)
	SetModel(model string)
	SetTemperature(temperature float32)
	SetMaxTokens(maxTokens int)
}

type Config

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

Config represents general agents configuration

type Option

type Option func(a *Config)

func WithClient

func WithClient(clt instructor.Instructor) Option

func WithMaxTokens

func WithMaxTokens(maxTokens int) Option

func WithMemory

func WithMemory(m *components.Memory) Option

func WithModel

func WithModel(model string) Option

func WithSystemPromptGenerator

func WithSystemPromptGenerator(g *systemprompt.Generator) Option

func WithTemperature

func WithTemperature(temperature float32) Option

Jump to

Keyboard shortcuts

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