Documentation
¶
Overview ¶
Package guest wasm application programming interface for guest module
Package guest is the wasm application programming interface for guest module
Index ¶
- Variables
- func ContextData(ptr uintptr, size uint32) uint32
- func GetBytes(fn func(ptr uintptr, size uint32) (len uint32)) (result []byte)
- type GuestContext
- func (c *GuestContext) Data() []byte
- func (c *GuestContext) HTTP() serverless.HTTP
- func (c *GuestContext) LLMFunctionCall() (*ai.FunctionCall, error)
- func (c *GuestContext) Metadata(key string) (string, bool)
- func (c *GuestContext) ReadLLMArguments(args any) error
- func (c *GuestContext) Tag() uint32
- func (c *GuestContext) Write(tag uint32, data []byte) error
- func (c *GuestContext) WriteLLMResult(result string) error
- func (c *GuestContext) WriteWithTarget(tag uint32, data []byte, target string) error
- type GuestHTTP
Constants ¶
This section is empty.
Variables ¶
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 } )
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 ¶
ContextData returns the data of the context
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) 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
func (g *GuestHTTP) Send(req *serverless.HTTPRequest) (*serverless.HTTPResponse, error)
Send send http request and return http response