engine

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	SupportedMIMETypes     = []string{"application/json", "text/plain", "multipart/form-data"}
	SupportedSecurityTypes = []string{"apiKey", "http"}
)

Functions

This section is empty.

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
	InputContext      []InputContext
	CredentialContext string
	// IsCredential indicates that the current call is for a credential tool
	IsCredential bool
}

func FromContext added in v0.4.2

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

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, isCredentialTool bool) (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
	Ports          *Ports
}

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 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 OpenAPIInstructions added in v0.4.0

type OpenAPIInstructions struct {
	Server           string           `json:"server"`
	Path             string           `json:"path"`
	Method           string           `json:"method"`
	BodyContentMIME  string           `json:"bodyContentMIME"`
	SecurityInfos    [][]SecurityInfo `json:"apiKeyInfos"`
	QueryParameters  []Parameter      `json:"queryParameters"`
	PathParameters   []Parameter      `json:"pathParameters"`
	HeaderParameters []Parameter      `json:"headerParameters"`
	CookieParameters []Parameter      `json:"cookieParameters"`
}

type Parameter added in v0.4.0

type Parameter struct {
	Name    string `json:"name"`
	Style   string `json:"style"`
	Explode *bool  `json:"explode"`
}

type Ports added in v0.4.0

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

func (*Ports) CloseDaemons added in v0.4.0

func (p *Ports) CloseDaemons()

func (*Ports) NextPort added in v0.4.0

func (p *Ports) NextPort() int64

func (*Ports) SetPorts added in v0.4.2

func (p *Ports) SetPorts(start, end int64)

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 SecurityInfo added in v0.4.0

type SecurityInfo struct {
	Name       string `json:"name"`       // name as defined in the security schemes
	Type       string `json:"type"`       // http or apiKey
	Scheme     string `json:"scheme"`     // bearer or basic, for type==http
	APIKeyName string `json:"apiKeyName"` // name of the API key, for type==apiKey
	In         string `json:"in"`         // header, query, or cookie, for type==apiKey
}

A SecurityInfo represents a security scheme in OpenAPI.

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