engine

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const DaemonURLSuffix = ".daemon.gptscript.local"

Variables

This section is empty.

Functions

func CloseDaemons

func CloseDaemons()

func IsChatFinishMessage added in v0.8.4

func IsChatFinishMessage(msg string) error

func SetPorts added in v0.7.1

func SetPorts(start, end int64)

func WithToolCategory added in v0.7.0

func WithToolCategory(ctx context.Context, toolCategory ToolCategory) context.Context

Types

type Call

type Call struct {
	Missing bool   `json:"missing,omitempty"`
	ToolID  string `json:"toolID,omitempty"`
	Input   string `json:"input,omitempty"`
}

type CallContext added in v0.6.0

type CallContext struct {
	ToolName    string `json:"toolName,omitempty"`
	ParentID    string `json:"parentID,omitempty"`
	DisplayText string `json:"displayText,omitempty"`
	// contains filtered or unexported fields
}

type CallResult

type CallResult struct {
	ToolID string `json:"toolID,omitempty"`
	CallID string `json:"callID,omitempty"`
	Result string `json:"result,omitempty"`
	User   string `json:"user,omitempty"`
}

type ChatHistory added in v0.7.0

type ChatHistory struct {
	History []ChatHistoryCall `json:"history,omitempty"`
}

type ChatHistoryCall added in v0.7.0

type ChatHistoryCall struct {
	ID         string                  `json:"id,omitempty"`
	Tool       types.Tool              `json:"tool,omitempty"`
	Completion types.CompletionRequest `json:"completion,omitempty"`
}

type Context

type Context struct {
	Ctx           context.Context
	Parent        *Context
	LastReturn    *Return
	CurrentReturn *Return
	Program       *types.Program
	// Input is saved only so that we can render display text, don't use otherwise
	Input string
	// contains filtered or unexported fields
}

func FromContext added in v0.4.2

func FromContext(ctx context.Context) (*Context, bool)

func NewContext

func NewContext(ctx context.Context, prg *types.Program, input string) (Context, error)

func (*Context) CurrentAgent added in v0.9.0

func (c *Context) CurrentAgent() types.ToolReference

func (*Context) GetCallContext added in v0.6.0

func (c *Context) GetCallContext() *CallContext

func (*Context) MarshalJSON

func (c *Context) MarshalJSON() ([]byte, error)

func (*Context) ParentID

func (c *Context) ParentID() string

func (*Context) SubCallContext added in v0.8.4

func (c *Context) SubCallContext(ctx context.Context, input, toolID, callID string, toolCategory ToolCategory) (Context, error)

func (*Context) UnmarshalJSON

func (c *Context) UnmarshalJSON([]byte) error

func (*Context) WrappedContext added in v0.4.2

func (c *Context) WrappedContext() context.Context

type Engine

type Engine struct {
	Model          Model
	RuntimeManager RuntimeManager
	Env            []string
	Progress       chan<- types.CompletionStatus
}

func (*Engine) Continue

func (e *Engine) Continue(ctx Context, state *State, results ...CallResult) (*Return, error)

func (*Engine) Start

func (e *Engine) Start(ctx Context, input string) (ret *Return, _ error)

type ErrChatFinish added in v0.8.4

type ErrChatFinish struct {
	Message string
}

func (*ErrChatFinish) Error added in v0.8.4

func (e *ErrChatFinish) Error() string

type InputContext added in v0.5.0

type InputContext struct {
	ToolID  string `json:"toolID,omitempty"`
	Content string `json:"content,omitempty"`
}

type Model added in v0.1.4

type Model interface {
	Call(ctx context.Context, messageRequest types.CompletionRequest, status chan<- types.CompletionStatus) (*types.CompletionMessage, error)
}

type Ports added in v0.4.0

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

type Return

type Return struct {
	State  *State          `json:"state,omitempty"`
	Calls  map[string]Call `json:"calls,omitempty"`
	Result *string         `json:"result,omitempty"`
}

type RuntimeManager added in v0.2.0

type RuntimeManager interface {
	GetContext(ctx context.Context, tool types.Tool, cmd, env []string) (string, []string, error)
	EnsureCredentialHelpers(ctx context.Context) error
	SetUpCredentialHelpers(ctx context.Context, cliCfg *config.CLIConfig, env []string) error
}

type State

type State struct {
	Input      string                              `json:"input,omitempty"`
	Completion types.CompletionRequest             `json:"completion,omitempty"`
	Pending    map[string]types.CompletionToolCall `json:"pending,omitempty"`
	Results    map[string]CallResult               `json:"results,omitempty"`
}

type ToolCategory added in v0.6.0

type ToolCategory string
const (
	ProviderToolCategory   ToolCategory = "provider"
	CredentialToolCategory ToolCategory = "credential"
	ContextToolCategory    ToolCategory = "context"
	InputToolCategory      ToolCategory = "input"
	OutputToolCategory     ToolCategory = "output"
	NoCategory             ToolCategory = ""
)

func ToolCategoryFromContext added in v0.8.5

func ToolCategoryFromContext(ctx context.Context) ToolCategory

Jump to

Keyboard shortcuts

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