guest

package
v1.18.14 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package guest wasm application programming interface for guest module

Package guest is the wasm application programming interface for guest module

Index

Constants

This section is empty.

Variables

View Source
var (
	// DataTags sets handler observed data tags
	DataTags func() []uint32 = func() []uint32 { return []uint32{0} }
	// WantedTarget sets handler wanted target
	WantedTarget func() string = func() string { return "" }
	// Handler is the handler function for guest
	Handler func(ctx serverless.Context) = func(serverless.Context) {}
	// Init is the init function for guest
	Init func() error = func() error { return nil }
)
View Source
var (
	// ReadBuf is a buffer used to read data from the host.
	ReadBuf = make([]byte, ReadBufSize)
	// ReadBufPtr is a pointer to ReadBuf.
	ReadBufPtr = uintptr(unsafe.Pointer(&ReadBuf[0]))
	// ReadBufSize is the size of ReadBuf
	ReadBufSize = uint32(2048)
)

Functions

func ContextData

func ContextData(ptr uintptr, size uint32) uint32

ContextData returns the data of the context

func GetBytes

func GetBytes(fn func(ptr uintptr, size uint32) (len uint32)) (result []byte)

GetBytes returns a byte slice of the given size

Types

type GuestContext

type GuestContext struct{}

GuestContext is the context for guest

func (*GuestContext) Data

func (c *GuestContext) Data() []byte

Data returns the data of the context

func (*GuestContext) HTTP added in v1.13.1

func (c *GuestContext) HTTP() serverless.HTTP

HTTP is the interface for HTTP request, but it is not implemented in the server side

func (*GuestContext) LLMFunctionCall added in v1.18.10

func (c *GuestContext) LLMFunctionCall() (*ai.FunctionCall, error)

func (*GuestContext) Metadata added in v1.18.5

func (c *GuestContext) Metadata(key string) (string, bool)

Metadata returns the value of from metadata in key

func (*GuestContext) ReadLLMArguments added in v1.18.9

func (c *GuestContext) ReadLLMArguments(args any) error

func (*GuestContext) Tag

func (c *GuestContext) Tag() uint32

Tag returns the tag of the context

func (*GuestContext) Write

func (c *GuestContext) Write(tag uint32, data []byte) error

Write writes data to the context

func (*GuestContext) WriteLLMResult added in v1.18.9

func (c *GuestContext) WriteLLMResult(result string) error

func (*GuestContext) WriteWithTarget added in v1.17.4

func (c *GuestContext) WriteWithTarget(tag uint32, data []byte, target string) error

WriteWithTarget writes data with target to the context

type GuestHTTP added in v1.13.1

type GuestHTTP struct{}

GuestHTTP is the http client for guest

func (*GuestHTTP) Get added in v1.13.1

func (g *GuestHTTP) Get(url string) (*serverless.HTTPResponse, error)

Get send http GET request and return http response

func (*GuestHTTP) Post added in v1.13.1

func (g *GuestHTTP) Post(
	url string,
	contentType string,
	body []byte,
) (*serverless.HTTPResponse, error)

Post send http POST request and return http response

func (*GuestHTTP) Send added in v1.13.1

Send send http request and return http response

Jump to

Keyboard shortcuts

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