http

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(url string, verbose bool, connectionTimeout float64, networkTimeout float64, ssl bool, insecure bool, httpClient *http.Client, logger *log.Logger) (base.Client, error)

NewClient creates a new httpInferenceServerClient.

func NewInferInput

func NewInferInput(name string, datatype string, shape []int64, parameters map[string]any) base.InferInput

NewInferInput creates a new HTTP InferInput instance with the given parameters.

func NewInferOutput

func NewInferOutput(name string, parameters map[string]any) base.InferOutput

NewInferOutput creates a new instance of InferOutput with the given name and parameters.

func NewInferResult

func NewInferResult(response base.ResponseWrapper, verbose bool) (base.InferResult, error)

NewInferResult creates a new HTTP InferResult instance.

func NewResponseWrapper

func NewResponseWrapper(response *http.Response) base.ResponseWrapper

Types

type InferInput

type InferInput struct {
	*base.BaseInferInput
}

InferInput is the HTTP implementation of the base.InferInput interface.

func (*InferInput) GetBinaryData

func (input *InferInput) GetBinaryData() []byte

GetBinaryData returns the raw binary data of the input tensor.

func (*InferInput) GetTensor

func (input *InferInput) GetTensor() any

type InferOutput

type InferOutput struct {
	*base.BaseInferOutput
}

func (*InferOutput) GetTensor

func (output *InferOutput) GetTensor() any

GetTensor returns a tensor representation of the InferOutput with its name and parameters.

type InferResult

type InferResult struct {
	*base.BaseInferResult
}

InferResult represents the result of an inference operation using HTTP.

func (*InferResult) AsBoolSlice added in v0.1.0

func (r *InferResult) AsBoolSlice(name string) ([]bool, error)

func (*InferResult) AsByteSlice added in v0.1.0

func (r *InferResult) AsByteSlice(name string) ([]string, error)

func (*InferResult) AsFloat16Slice added in v0.1.0

func (r *InferResult) AsFloat16Slice(name string) ([]float64, error)

func (*InferResult) AsFloat32Slice added in v0.1.0

func (r *InferResult) AsFloat32Slice(name string) ([]float32, error)

func (*InferResult) AsFloat64Slice added in v0.1.0

func (r *InferResult) AsFloat64Slice(name string) ([]float64, error)

func (*InferResult) AsInt16Slice added in v0.1.0

func (r *InferResult) AsInt16Slice(name string) ([]int16, error)

func (*InferResult) AsInt32Slice added in v0.1.0

func (r *InferResult) AsInt32Slice(name string) ([]int32, error)

func (*InferResult) AsInt64Slice added in v0.1.0

func (r *InferResult) AsInt64Slice(name string) ([]int64, error)

func (*InferResult) AsInt8Slice added in v0.1.0

func (r *InferResult) AsInt8Slice(name string) ([]int8, error)

func (*InferResult) AsUint16Slice added in v0.1.0

func (r *InferResult) AsUint16Slice(name string) ([]uint16, error)

func (*InferResult) AsUint32Slice added in v0.1.0

func (r *InferResult) AsUint32Slice(name string) ([]uint32, error)

func (*InferResult) AsUint64Slice added in v0.1.0

func (r *InferResult) AsUint64Slice(name string) ([]uint64, error)

func (*InferResult) AsUint8Slice added in v0.1.0

func (r *InferResult) AsUint8Slice(name string) ([]uint8, error)

type RequestWrapper

type RequestWrapper struct {
	BaseURL      string
	ModelName    string
	ModelVersion string
	Inputs       []base.InferInput
	Outputs      []base.InferOutput
	Marshaller   base.Marshaller
	Options      *options.InferOptions
}

RequestWrapper is a struct that encapsulates all necessary data to create and manage an HTTP request for a model inference. It includes model details, inputs, outputs, request-specific configurations, and parameters.

func NewRequestWrapper

func NewRequestWrapper(
	baseURL, modelName, modelVersion string,
	inputs []base.InferInput,
	outputs []base.InferOutput,
	marshaller base.Marshaller,
	opts *options.InferOptions,
) *RequestWrapper

NewRequestWrapper initializes and returns a new RequestWrapper instance with the provided base URL, model details, inputs, outputs, and other configurations.

func (*RequestWrapper) PrepareRequest

func (w *RequestWrapper) PrepareRequest() (*http.Request, error)

PrepareRequest prepares the HTTP request for model inference. It serializes the inference request body, sets appropriate headers, and constructs the request URI based on model name and version.

type ResponseWrapper

type ResponseWrapper struct {
	Response *http.Response
}

ResponseWrapper wraps an HTTP response to implement the UnifiedResponse interface, providing methods to retrieve headers and body content from the HTTP response.

func (*ResponseWrapper) GetBody

func (h *ResponseWrapper) GetBody() ([]byte, error)

GetBody reads and returns the entire body of the HTTP response as a byte slice. It returns an error if reading the body fails.

func (*ResponseWrapper) GetHeader

func (h *ResponseWrapper) GetHeader(key string) string

GetHeader retrieves the value of a specified header key from the wrapped HTTP response. It uses the standard http.Header Get method to return the value associated with the key.

func (*ResponseWrapper) GetRawOutputContents

func (h *ResponseWrapper) GetRawOutputContents() [][]byte

GetRawOutputContents reads the entire body of the HTTP response and returns it as a slice of byte slices. In this implementation, it returns a slice containing a single byte slice with the full response body.

func (*ResponseWrapper) GetResponse

func (g *ResponseWrapper) GetResponse() any

GetResponse retrieves the response.

Jump to

Keyboard shortcuts

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