engine

package
v0.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func CloseDaemons

func CloseDaemons()

func PickToolName added in v0.1.5

func PickToolName(toolName string, existing map[string]struct{}) string

func ToolNormalizer added in v0.1.5

func ToolNormalizer(tool string) string

Types

type Call

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

type CallResult

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

type Context

type Context struct {
	ID      string
	Ctx     context.Context
	Parent  *Context
	Program *types.Program
	Tool    types.Tool
	// contains filtered or unexported fields
}

func NewContext

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

func (*Context) MarshalJSON

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

func (*Context) ParentID

func (c *Context) ParentID() string

func (*Context) SubCall

func (c *Context) SubCall(ctx context.Context, toolID, callID string) (Context, error)

func (*Context) UnmarshalJSON

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

type Engine

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

func (*Engine) Continue

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

func (*Engine) Start

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

type ErrToolNotFound

type ErrToolNotFound struct {
	ToolName string
}

func (*ErrToolNotFound) Error

func (e *ErrToolNotFound) Error() string

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 Return

type Return struct {
	State  *State
	Calls  map[string]Call
	Result *string
}

type RuntimeManager added in v0.2.0

type RuntimeManager interface {
	GetContext(ctx context.Context, tool types.Tool, cmd, env []string) (string, []string, error)
}

type State

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

Jump to

Keyboard shortcuts

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