runner

package
v0.8.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizerFunc added in v0.7.0

type AuthorizerFunc func(ctx engine.Context, input string) (AuthorizerResponse, error)

type AuthorizerResponse added in v0.7.0

type AuthorizerResponse struct {
	Accept  bool
	Message string
}

func DefaultAuthorizer added in v0.7.0

func DefaultAuthorizer(engine.Context, string) (AuthorizerResponse, error)

type ChatResponse added in v0.6.0

type ChatResponse struct {
	Done    bool      `json:"done"`
	Content string    `json:"content"`
	ToolID  string    `json:"toolID"`
	State   ChatState `json:"state"`
}

type ChatState added in v0.6.0

type ChatState interface{}

type Event

type Event struct {
	Time               time.Time              `json:"time,omitempty"`
	CallContext        *engine.CallContext    `json:"callContext,omitempty"`
	ToolSubCalls       map[string]engine.Call `json:"toolSubCalls,omitempty"`
	ToolResults        int                    `json:"toolResults,omitempty"`
	Type               EventType              `json:"type,omitempty"`
	ChatCompletionID   string                 `json:"chatCompletionId,omitempty"`
	ChatRequest        any                    `json:"chatRequest,omitempty"`
	ChatResponse       any                    `json:"chatResponse,omitempty"`
	Usage              types.Usage            `json:"usage,omitempty"`
	ChatResponseCached bool                   `json:"chatResponseCached,omitempty"`
	Content            string                 `json:"content,omitempty"`
}

type EventType

type EventType string
var (
	EventTypeRunStart     EventType = "runStart"
	EventTypeCallStart    EventType = "callStart"
	EventTypeCallContinue EventType = "callContinue"
	EventTypeCallSubCalls EventType = "callSubCalls"
	EventTypeCallProgress EventType = "callProgress"
	EventTypeChat         EventType = "callChat"
	EventTypeCallFinish   EventType = "callFinish"
	EventTypeRunFinish    EventType = "runFinish"
)

type Monitor

type Monitor interface {
	Event(event Event)
	Pause() func()
	Stop(output string, err error)
}

type MonitorFactory

type MonitorFactory interface {
	Start(ctx context.Context, prg *types.Program, env []string, input string) (Monitor, error)
	Pause() func()
}

type Needed added in v0.6.0

type Needed struct {
	Content string `json:"content,omitempty"`
	Input   string `json:"input,omitempty"`
}

type Options

type Options struct {
	MonitorFactory     MonitorFactory        `usage:"-"`
	RuntimeManager     engine.RuntimeManager `usage:"-"`
	StartPort          int64                 `usage:"-"`
	EndPort            int64                 `usage:"-"`
	CredentialOverride string                `usage:"-"`
	Sequential         bool                  `usage:"-"`
	Authorizer         AuthorizerFunc        `usage:"-"`
}

type Runner

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

func New

func New(client engine.Model, credCtx string, opts ...Options) (*Runner, error)

func (*Runner) Chat added in v0.6.0

func (r *Runner) Chat(ctx context.Context, prevState ChatState, prg types.Program, env []string, input string) (resp ChatResponse, err error)

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, prg types.Program, env []string, input string) (output string, err error)

type State added in v0.6.0

type State struct {
	Continuation       *engine.Return `json:"continuation,omitempty"`
	ContinuationToolID string         `json:"continuationToolID,omitempty"`
	Result             *string        `json:"result,omitempty"`

	ResumeInput *string         `json:"resumeInput,omitempty"`
	SubCalls    []SubCallResult `json:"subCalls,omitempty"`
	SubCallID   string          `json:"subCallID,omitempty"`

	InputContexts                       []engine.InputContext `json:"inputContexts,omitempty"`
	InputContextContinuation            *State                `json:"inputContextContinuation,omitempty"`
	InputContextContinuationInput       string                `json:"inputContextContinuationInput,omitempty"`
	InputContextContinuationResumeInput *string               `json:"inputContextContinuationResumeInput,omitempty"`
	StartContinuation                   bool                  `json:"startContinuation,omitempty"`
}

func (State) ContinuationContent added in v0.6.0

func (s State) ContinuationContent() (string, error)

func (State) ContinuationContentToolID added in v0.6.0

func (s State) ContinuationContentToolID() (string, error)

func (State) WithResumeInput added in v0.6.0

func (s State) WithResumeInput(input *string) *State

type SubCallResult added in v0.6.0

type SubCallResult struct {
	ToolID string `json:"toolId,omitempty"`
	CallID string `json:"callId,omitempty"`
	State  *State `json:"state,omitempty"`
}

Jump to

Keyboard shortcuts

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