openinference

package
v0.0.0-...-70b8bd4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRESTPort     = 8080
	DefaultGRPCPort     = 9000
	DefaultModelName    = "model"
	DefaultModelVersion = "1"
)

Variables

This section is empty.

Functions

func BytesToTensor

func BytesToTensor(dataType string, data []byte, shape []int64) (any, error)

func Serialize

func Serialize(r *RESTInferenceRequest) ([]byte, error)

Types

type Configuration

type Configuration struct {
	trigger.Configuration

	// Server configuration
	RESTPort   int  `mapstructure:"rest_port"`
	GRPCPort   int  `mapstructure:"grpc_port"`
	EnableREST bool `mapstructure:"enable_rest"`
	EnableGRPC bool `mapstructure:"enable_grpc"`

	// Model configuration
	ModelName    string `mapstructure:"model_name"`
	ModelVersion string `mapstructure:"model_version"`

	// Tensor definitions
	InputTensors  []TensorDef `mapstructure:"input_tensors"`
	OutputTensors []TensorDef `mapstructure:"output_tensors"`
}

Configuration for OpenInference trigger

func NewConfiguration

func NewConfiguration(id string,
	triggerConfiguration *functionconfig.Trigger,
	runtimeConfiguration *runtime.Configuration) (*Configuration, error)

NewConfiguration creates a new OpenInference trigger configuration

type Event

type Event struct {
	nuclio.AbstractEvent
	// contains filtered or unexported fields
}

Event wraps an OpenInference inference request

func (*Event) GetBody

func (e *Event) GetBody() []byte

GetBody returns the request body

func (*Event) GetContentType

func (e *Event) GetContentType() string

GetContentType returns the content type

func (*Event) GetFieldByteSlice

func (e *Event) GetFieldByteSlice(key string) []byte

GetFieldByteSlice returns a field value as a byte slice

func (*Event) GetFieldInt

func (e *Event) GetFieldInt(key string) (int, error)

GetFieldInt returns a field value as an int

func (*Event) GetFieldString

func (e *Event) GetFieldString(key string) string

GetFieldString returns a field value as a string

func (*Event) GetHeader

func (e *Event) GetHeader(key string) any

GetHeader returns a header value as an any

func (*Event) GetHeaderByteSlice

func (e *Event) GetHeaderByteSlice(key string) []byte

GetHeaderByteSlice returns a header value as a byte slice

func (*Event) GetHeaders

func (e *Event) GetHeaders() map[string]any

GetHeaders returns all headers

func (*Event) GetMethod

func (e *Event) GetMethod() string

GetMethod returns the method

func (*Event) GetPath

func (e *Event) GetPath() string

GetPath returns an empty string

func (*Event) GetTimestamp

func (e *Event) GetTimestamp() time.Time

GetTimestamp returns the event timestamp

func (*Event) GetTriggerInfo

func (e *Event) GetTriggerInfo() nuclio.TriggerInfoProvider

GetTriggerInfo returns trigger information

func (*Event) GetURL

func (e *Event) GetURL() string

GetURL returns an empty string

type InvalidInputError

type InvalidInputError struct {
	Err error
}

InvalidInputError lets a runtime distinguish invalid tensor requests from execution failures.

func (*InvalidInputError) Error

func (e *InvalidInputError) Error() string

func (*InvalidInputError) Unwrap

func (e *InvalidInputError) Unwrap() error

type ModelMetadataResponse

type ModelMetadataResponse struct {
	Name     string               `json:"name"`
	Versions []string             `json:"versions,omitempty"`
	Platform string               `json:"platform,omitempty"`
	Inputs   []RESTTensorMetadata `json:"inputs,omitempty"`
	Outputs  []RESTTensorMetadata `json:"outputs,omitempty"`
}

type ModelReadyResponse

type ModelReadyResponse struct {
	Ready bool `json:"ready"`
}

type RESTInferInputTensor

type RESTInferInputTensor struct {
	Name       string         `json:"name"`
	Shape      []int64        `json:"shape"`
	Datatype   string         `json:"datatype"`
	Parameters map[string]any `json:"parameters,omitempty"`
	Data       any            `json:"data"`
}

type RESTInferOutputTensor

type RESTInferOutputTensor struct {
	Name       string         `json:"name"`
	Shape      []int64        `json:"shape,omitempty"`
	Datatype   string         `json:"datatype,omitempty"`
	Parameters map[string]any `json:"parameters,omitempty"`
	Data       any            `json:"data,omitempty"`
}

type RESTInferenceRequest

type RESTInferenceRequest struct {
	ID         string                  `json:"id,omitempty"`
	Parameters map[string]any          `json:"parameters,omitempty"`
	Inputs     []RESTInferInputTensor  `json:"inputs"`
	Outputs    []RESTInferOutputTensor `json:"outputs,omitempty"`
}

type RESTInferenceResponse

type RESTInferenceResponse struct {
	ModelName    string                  `json:"model_name"`
	ModelVersion string                  `json:"model_version,omitempty"`
	ID           string                  `json:"id,omitempty"`
	Parameters   map[string]any          `json:"parameters,omitempty"`
	Outputs      []RESTInferOutputTensor `json:"outputs"`
}

func Deserialize

func Deserialize(data []byte) (*RESTInferenceResponse, error)

type RESTTensorMetadata

type RESTTensorMetadata struct {
	Name     string  `json:"name"`
	Datatype string  `json:"datatype"`
	Shape    []int64 `json:"shape"`
	// Quantization params for int8/uint8 models, in the v2 `parameters` map.
	// Omitted for float models, so their response stays exactly as before.
	Parameters map[string]any `json:"parameters,omitempty"`
}

type ServerLiveResponse

type ServerLiveResponse struct {
	Live bool `json:"live"`
}

type ServerMetadataResponse

type ServerMetadataResponse struct {
	Name       string   `json:"name"`
	Version    string   `json:"version"`
	Extensions []string `json:"extensions,omitempty"`
}

type ServerReadyResponse

type ServerReadyResponse struct {
	Ready bool `json:"ready"`
}

type TensorDef

type TensorDef struct {
	Name     string  `mapstructure:"name"`
	DataType string  `mapstructure:"datatype"`
	Shape    []int64 `mapstructure:"shape"`
	// Affine quantization params, for quantized models (int8/uint8): a client
	// receiving int8 cannot map the values back to reals without them. Per-axis
	// quantization yields more than one entry, indexed by QuantizedDimension.
	Scale              []float64 `mapstructure:"scale"`
	ZeroPoint          []int64   `mapstructure:"zero_point"`
	QuantizedDimension int64     `mapstructure:"quantized_dimension"`
}

TensorDef defines the shape and data type of a tensor

type TensorMetadataProvider

type TensorMetadataProvider interface {
	ModelTensors() (inputs, outputs []TensorDef)
}

TensorMetadataProvider is implemented by runtimes that know their model's own signature (the TVM runtime reads it from metadata.json). The trigger prefers it over the tensors declared in the function config, so a function does not have to repeat — and risk contradicting — what the model already states. Runtimes that do not implement it keep the previous behaviour.

Jump to

Keyboard shortcuts

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