action_structs

package
v0.0.0-...-66bbac4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SuccessMessage = []byte(`{"success":true}`)

Functions

This section is empty.

Types

type Action

type Action interface {
	// GetName Get the name of the action
	GetName() string

	// GetDescription Get the description of the action
	GetDescription() string

	// GetNotification  Get the notification message that will be sent when the action is executed
	GetNotification() string

	// SetParam Set the parameters of the action
	SetParam(string, string)

	// GetParam Get the value of a parameter
	GetParam(string) (string, error)

	// GetParams Get all parameters
	GetParams() []*ActionParameter

	// CheckRequiredParams Check if all required parameters are set
	CheckRequiredParams() error

	// SetMessage Set the message that triggered the action
	SetMessage(*memory.Message)

	// Execute The actual implementation of the action
	Execute(*ActionRequest) ([]*response_object_structs.ResponseObject, error)

	// RunPreActions Actions that will be executed before the action is executed
	RunPreActions(*ActionRequest) error

	// RunPostActions Actions that will be executed after the action is executed
	RunPostActions(*ActionRequest) error

	// GetSchema Get the schema of the action to be passed to `functions`
	GetSchema() *functions.FunctionDefinition

	// SkipFunctionCall Check if the action can be automatically executed by the AI
	SkipFunctionCall() bool
}

type ActionParameter

type ActionParameter struct {
	Name        string   `json:"-"`
	Description string   `json:"description"`
	Type        string   `json:"type"`
	Enum        []string `json:"enum,omitempty"`
	Required    bool     `json:"-"`
	Value       string   `json:"-"`
}

type ActionParameterSet

type ActionParameterSet struct {
	Params []*ActionParameter
}

func (*ActionParameterSet) AddParam

func (a *ActionParameterSet) AddParam(param *ActionParameter)

func (*ActionParameterSet) CheckRequiredParams

func (a *ActionParameterSet) CheckRequiredParams() error

func (*ActionParameterSet) GetParam

func (a *ActionParameterSet) GetParam(name string) (*ActionParameter, error)

func (*ActionParameterSet) GetParams

func (a *ActionParameterSet) GetParams() []*ActionParameter

func (*ActionParameterSet) SetParam

func (a *ActionParameterSet) SetParam(key, value string)

type ActionRequest

type ActionRequest struct {
	ID      string
	Context context.Context

	Writer              writer_structs.ChloeWriter
	SkipClose           bool
	AutomaticallyCalled bool

	ErrorChannel chan error

	Action string
	Params map[string]string

	Count int

	Message *memory.Message `json:"message,omitempty"`
}

func NewActionRequest

func NewActionRequest() *ActionRequest

func (*ActionRequest) GetContext

func (creq *ActionRequest) GetContext() context.Context

func (*ActionRequest) GetID

func (creq *ActionRequest) GetID() string

func (*ActionRequest) GetMessage

func (creq *ActionRequest) GetMessage() *memory.Message

func (*ActionRequest) GetSkipClose

func (creq *ActionRequest) GetSkipClose() bool

func (*ActionRequest) GetWriter

func (creq *ActionRequest) GetWriter() writer_structs.ChloeWriter

func (*ActionRequest) SetWriter

func (creq *ActionRequest) SetWriter(w writer_structs.ChloeWriter)

Jump to

Keyboard shortcuts

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