predict

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasInputComponent added in v0.22.0

func HasInputComponent(schema *openapi3.T, isTrain bool) bool

HasInputComponent reports whether the schema has the Input (or TrainingInput) component needed by preflight validation, so callers can fall back to the runtime schema for images with minimal or missing labels.

func ValidateInputMapForMode added in v0.22.0

func ValidateInputMapForMode(input map[string]any, schema *openapi3.T, isTrain bool) error

ValidateInputMapForMode validates an already JSON-shaped input map.

func ValidateInputNamesForMode added in v0.22.0

func ValidateInputNamesForMode(input map[string]any, schema *openapi3.T, isTrain bool) error

ValidateInputNamesForMode validates top-level input names without reading or converting values.

func ValidateInputsForMode added in v0.22.0

func ValidateInputsForMode(inputs Inputs, schema *openapi3.T, isTrain bool) error

ValidateInputsForMode validates CLI inputs after schema-directed coercion.

Types

type HealthcheckResponse added in v0.7.0

type HealthcheckResponse struct {
	Status string `json:"status"`
}

type HelpResponse

type HelpResponse struct {
	Arguments map[string]*config.RunArgument `json:"arguments"`
}

type Input

type Input struct {
	String *string
	File   *string
	Array  *[]any
	Json   *json.RawMessage
	Float  *float32
	Int    *int32
	Bool   *bool
}

type Inputs

type Inputs map[string]Input

func NewInputsForMode added in v0.17.0

func NewInputsForMode(keyVals map[string][]string, schema *openapi3.T, isTrain bool) (Inputs, error)

type Predictor

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

func NewPredictor

func NewPredictor(_ context.Context, opts PredictorOptions) (*Predictor, error)

NewPredictor constructs a Predictor. See PredictorOptions for the meaning of each field.

func (*Predictor) GetSchema added in v0.1.0

func (p *Predictor) GetSchema() (*openapi3.T, error)

func (*Predictor) Predict

func (p *Predictor) Predict(inputs Inputs, context RequestContext) (*Response, error)

func (*Predictor) Start

func (p *Predictor) Start(ctx context.Context, logsWriter io.Writer, timeout time.Duration) (retErr error)

func (*Predictor) Stop

func (p *Predictor) Stop(ctx context.Context) error

type PredictorOptions added in v0.19.3

type PredictorOptions struct {
	RunOptions    command.RunOptions
	IsTrain       bool
	Docker        command.Command
	WeightManager *weights.Manager
}

PredictorOptions configures a Predictor.

RunOptions carries everything the user supplied (image, volumes, env, GPUs, ports). If WeightManager is non-nil, Predictor.Start will call Prepare and merge the resulting read-only mounts into RunOptions.Volumes before launching the container; Stop will Release them afterwards. A nil WeightManager preserves the historical behavior for callers that don't deal with managed weights.

type Request added in v0.1.0

type Request struct {
	// TODO: could this be Inputs?
	Input   map[string]any `json:"input"`
	Context RequestContext `json:"context"`
}

type RequestContext added in v0.15.1

type RequestContext struct {
	ReplicateAPIToken string `json:"replicate_api_token,omitempty"`
}

type Response added in v0.1.0

type Response struct {
	Status  status         `json:"status"`
	Output  *any           `json:"output"`
	Error   string         `json:"error"`
	Metrics map[string]any `json:"metrics,omitempty"`
}

type ValidationErrorResponse added in v0.1.0

type ValidationErrorResponse struct {
	Detail []struct {
		Location []string `json:"loc"`
		Message  string   `json:"msg"`
		Type     string   `json:"type"`
	} `json:"detail"`
}

Jump to

Keyboard shortcuts

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