Documentation
¶
Index ¶
- Variables
- func ChatCompletion(rpcMgr *GuestRPCManager, model string, msgs []payload.ChatMessageV2, ...) ([]payload.ChatMessageV2, error)
- func Embeddings(rpcMgr *GuestRPCManager, model, input string) ([]float64, error)
- func RPCManagerSendRequest[T any](rpcMgr *GuestRPCManager, method string, params interface{}) (*T, error)
- func TextToImage(rpcMgr *GuestRPCManager, model, prompt, format string) (*transform.ImageGenerationResponse, error)
- func TextToSpeech(rpcMgr *GuestRPCManager, model, voice, input, format string) (*transform.TextToSpeechResponse, error)
- type GuestRPCManager
- func (g *GuestRPCManager) ClearRequestCallback(id json.Number)
- func (g *GuestRPCManager) RegisterIncomingHandler(method string, handler RequestHandler) error
- func (g *GuestRPCManager) Run()
- func (g *GuestRPCManager) SendJsonRequest(req *JsonRPCRequest) (*JsonRPCResponse, error)
- func (g *GuestRPCManager) SendRequest(method string, params interface{}) (interface{}, error)
- func (g *GuestRPCManager) SetInput(i io.Reader)
- func (g *GuestRPCManager) SetOutput(o io.Writer)
- func (g *GuestRPCManager) SetRequestCallback(id json.Number, callback ResquestCallback, autoClear bool)
- type JsonRPCError
- type JsonRPCNotification
- type JsonRPCRequest
- func (r *JsonRPCRequest) CreateErrorResponse(code int, message string, data interface{}) *JsonRPCResponse
- func (r *JsonRPCRequest) CreateSuccessResponse(result interface{}) *JsonRPCResponse
- func (r *JsonRPCRequest) Marshal() ([]byte, error)
- func (r *JsonRPCRequest) Send(out io.Writer) error
- func (r *JsonRPCRequest) Unmarshal(data []byte) error
- type JsonRPCRequestHandler
- type JsonRPCResponse
- type JsonRPCResponseHandler
- type RequestHandler
- type ResquestCallback
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ResponseTimeout = time.Minute * 10 // 10 minutes timeout for requests
)
Functions ¶
func ChatCompletion ¶
func ChatCompletion(rpcMgr *GuestRPCManager, model string, msgs []payload.ChatMessageV2, tsId string) ([]payload.ChatMessageV2, error)
func Embeddings ¶
func Embeddings(rpcMgr *GuestRPCManager, model, input string) ([]float64, error)
func RPCManagerSendRequest ¶
func RPCManagerSendRequest[T any](rpcMgr *GuestRPCManager, method string, params interface{}) (*T, error)
func TextToImage ¶
func TextToImage(rpcMgr *GuestRPCManager, model, prompt, format string) (*transform.ImageGenerationResponse, error)
func TextToSpeech ¶
func TextToSpeech(rpcMgr *GuestRPCManager, model, voice, input, format string) (*transform.TextToSpeechResponse, error)
Types ¶
type GuestRPCManager ¶
type GuestRPCManager struct {
// contains filtered or unexported fields
}
func NewGuestRPCManager ¶
func NewGuestRPCManager(reqHandler JsonRPCRequestHandler, respHandler JsonRPCResponseHandler) *GuestRPCManager
func (*GuestRPCManager) ClearRequestCallback ¶
func (g *GuestRPCManager) ClearRequestCallback(id json.Number)
func (*GuestRPCManager) RegisterIncomingHandler ¶
func (g *GuestRPCManager) RegisterIncomingHandler(method string, handler RequestHandler) error
func (*GuestRPCManager) Run ¶
func (g *GuestRPCManager) Run()
func (*GuestRPCManager) SendJsonRequest ¶
func (g *GuestRPCManager) SendJsonRequest(req *JsonRPCRequest) (*JsonRPCResponse, error)
low level function to send a json request
func (*GuestRPCManager) SendRequest ¶
func (g *GuestRPCManager) SendRequest(method string, params interface{}) (interface{}, error)
high level function to send a request
func (*GuestRPCManager) SetInput ¶
func (g *GuestRPCManager) SetInput(i io.Reader)
func (*GuestRPCManager) SetOutput ¶
func (g *GuestRPCManager) SetOutput(o io.Writer)
func (*GuestRPCManager) SetRequestCallback ¶
func (g *GuestRPCManager) SetRequestCallback(id json.Number, callback ResquestCallback, autoClear bool)
type JsonRPCError ¶
type JsonRPCNotification ¶
type JsonRPCNotification struct {
Version string `json:"jsonrpc"`
Method *string `json:"method"`
Params interface{} `json:"params"`
}
func (*JsonRPCNotification) Marshal ¶
func (r *JsonRPCNotification) Marshal() ([]byte, error)
func (*JsonRPCNotification) Unmarshal ¶
func (r *JsonRPCNotification) Unmarshal(data []byte) error
type JsonRPCRequest ¶
type JsonRPCRequest struct {
Version string `json:"jsonrpc"`
Method *string `json:"method"`
Params interface{} `json:"params,omitempty"`
ID *json.Number `json:"id"`
}
func NewJsonRPCRequest ¶
func NewJsonRPCRequest(method string, params interface{}) *JsonRPCRequest
create request
func (*JsonRPCRequest) CreateErrorResponse ¶
func (r *JsonRPCRequest) CreateErrorResponse(code int, message string, data interface{}) *JsonRPCResponse
func (*JsonRPCRequest) CreateSuccessResponse ¶
func (r *JsonRPCRequest) CreateSuccessResponse(result interface{}) *JsonRPCResponse
func (*JsonRPCRequest) Marshal ¶
func (r *JsonRPCRequest) Marshal() ([]byte, error)
func (*JsonRPCRequest) Unmarshal ¶
func (r *JsonRPCRequest) Unmarshal(data []byte) error
type JsonRPCRequestHandler ¶
type JsonRPCRequestHandler func(req *JsonRPCRequest) (*JsonRPCResponse, error)
type JsonRPCResponse ¶
type JsonRPCResponse struct {
Version string `json:"jsonrpc"`
Result interface{} `json:"result,omitempty"`
Error *JsonRPCError `json:"error,omitempty"`
ID *json.Number `json:"id"`
}
func NewJsonRPCErrorResponse ¶
func NewJsonRPCErrorResponse(id json.Number, code int, message string, data interface{}) *JsonRPCResponse
func NewJsonRPCResponse ¶
func NewJsonRPCResponse(id json.Number, result interface{}) *JsonRPCResponse
func (*JsonRPCResponse) Marshal ¶
func (r *JsonRPCResponse) Marshal() ([]byte, error)
func (*JsonRPCResponse) Unmarshal ¶
func (r *JsonRPCResponse) Unmarshal(data []byte) error
type JsonRPCResponseHandler ¶
type JsonRPCResponseHandler func(resp *JsonRPCResponse) error
type RequestHandler ¶
type RequestHandler func(args interface{}) (interface{}, error)
type ResquestCallback ¶
type ResquestCallback func(resp *JsonRPCResponse) error
Click to show internal directories.
Click to hide internal directories.