openinference

package
v0.0.0-...-cfd2245 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 23 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 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"`
}

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"`
}

TensorDef defines the shape and data type of a tensor

Jump to

Keyboard shortcuts

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