inference

package
v8.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Perform inference on a model

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath = errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

type Inference

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

func (Inference) Do

func (r Inference) Do(providedCtx context.Context) (*Response, error)

Do runs the request through the transport, handle the response and returns a inference.Response

func (*Inference) Header

func (r *Inference) Header(key, value string) *Inference

Header set a key, value pair in the Inference headers map.

func (*Inference) HttpRequest

func (r *Inference) HttpRequest(ctx context.Context) (*http.Request, error)

HttpRequest returns the http.Request object built from the given parameters.

func (*Inference) Input

func (r *Inference) Input(inputs ...string) *Inference

Input Text input to the model. Either a string or an array of strings. API name: input

func (Inference) Perform

func (r Inference) Perform(providedCtx context.Context) (*http.Response, error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*Inference) Raw

func (r *Inference) Raw(raw io.Reader) *Inference

Raw takes a json payload as input which is then passed to the http.Request If specified Raw takes precedence on Request method.

func (*Inference) Request

func (r *Inference) Request(req *Request) *Inference

Request allows to set the request property with the appropriate payload.

func (*Inference) TaskSettings

func (r *Inference) TaskSettings(tasksettings json.RawMessage) *Inference

TaskSettings Optional task settings API name: task_settings

func (*Inference) TaskType added in v8.13.0

func (r *Inference) TaskType(tasktype string) *Inference

TaskType The task type API Name: tasktype

type NewInference

type NewInference func(inferenceid string) *Inference

NewInference type alias for index.

func NewInferenceFunc

func NewInferenceFunc(tp elastictransport.Interface) NewInference

NewInferenceFunc returns a new instance of Inference with the provided transport. Used in the index of the library this allows to retrieve every apis in once place.

type Request

type Request struct {

	// Input Text input to the model.
	// Either a string or an array of strings.
	Input []string `json:"input"`
	// TaskSettings Optional task settings
	TaskSettings json.RawMessage `json:"task_settings,omitempty"`
}

Request holds the request body struct for the package inference

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/inference/inference/InferenceRequest.ts#L25-L53

func NewRequest

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON added in v8.12.1

func (s *Request) UnmarshalJSON(data []byte) error

type Response

type Response struct {
	SparseEmbedding    []types.SparseEmbeddingResult   `json:"sparse_embedding,omitempty"`
	TextEmbedding      []types.TextEmbeddingResult     `json:"text_embedding,omitempty"`
	TextEmbeddingBytes []types.TextEmbeddingByteResult `json:"text_embedding_bytes,omitempty"`
}

Response holds the response body struct for the package inference

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/inference/inference/InferenceResponse.ts#L22-L24

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

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