Documentation
¶
Index ¶
- Constants
- Variables
- func BuildActionArgs(manifest plugin_entities.PluginDeclaration, action string) (map[string]any, error)
- func BuildExtractData(result ExtractResult) map[string]any
- func RunExtract(cfg *SlimConfig, opts ExtractOptions, w io.Writer) error
- func RunLocal(ctx *InvokeContext, local *LocalConfig, out *OutputWriter) error
- func RunRemote(ctx *InvokeContext, remote *RemoteConfig, out *OutputWriter) error
- func TransformRequest(ctx *InvokeContext) ([]byte, string, error)
- type ActionRoute
- type DaemonClient
- type ErrorCode
- type ExtractArgs
- type ExtractOptions
- type ExtractResult
- type InvokeContext
- type LocalConfig
- type OutputWriter
- type RemoteConfig
- type RequestMeta
- type SlimConfig
- type SlimError
Constants ¶
View Source
const ( ExitOK = 0 ExitPluginError = 1 ExitInputError = 2 ExitNetworkError = 3 ExitDaemonError = 4 )
View Source
const ( ModeLocal = "local" ModeRemote = "remote" )
View Source
const OutputJSON = "json"
Variables ¶
View Source
var ActionRoutes = map[string]ActionRoute{
"invoke_tool": {Type: "tool", Path: "/tool/invoke"},
"validate_tool_credentials": {Type: "tool", Path: "/tool/validate_credentials"},
"get_tool_runtime_parameters": {Type: "tool", Path: "/tool/get_runtime_parameters"},
"invoke_llm": {Type: "model", Path: "/llm/invoke"},
"get_llm_num_tokens": {Type: "model", Path: "/llm/num_tokens"},
"invoke_text_embedding": {Type: "model", Path: "/text_embedding/invoke"},
"invoke_multimodal_embedding": {Type: "model", Path: "/multimodal_embedding/invoke"},
"get_text_embedding_num_tokens": {Type: "model", Path: "/text_embedding/num_tokens"},
"invoke_rerank": {Type: "model", Path: "/rerank/invoke"},
"invoke_multimodal_rerank": {Type: "model", Path: "/multimodal_rerank/invoke"},
"invoke_tts": {Type: "model", Path: "/tts/invoke"},
"get_tts_model_voices": {Type: "model", Path: "/tts/model/voices"},
"invoke_speech2text": {Type: "model", Path: "/speech2text/invoke"},
"invoke_moderation": {Type: "model", Path: "/moderation/invoke"},
"validate_provider_credentials": {Type: "model", Path: "/model/validate_provider_credentials"},
"validate_model_credentials": {Type: "model", Path: "/model/validate_model_credentials"},
"get_ai_model_schemas": {Type: "model", Path: "/model/schema"},
"invoke_agent_strategy": {Type: "agent_strategy", Path: "/agent_strategy/invoke"},
"invoke_endpoint": {Type: "endpoint", Path: "/endpoint/invoke"},
"get_authorization_url": {Type: "oauth", Path: "/oauth/get_authorization_url"},
"get_credentials": {Type: "oauth", Path: "/oauth/get_credentials"},
"refresh_credentials": {Type: "oauth", Path: "/oauth/refresh_credentials"},
"validate_datasource_credentials": {Type: "datasource", Path: "/datasource/validate_credentials"},
"invoke_website_datasource_get_crawl": {Type: "datasource", Path: "/datasource/get_website_crawl"},
"invoke_online_document_datasource_get_pages": {Type: "datasource", Path: "/datasource/get_online_document_pages"},
"invoke_online_document_datasource_get_page_content": {Type: "datasource", Path: "/datasource/get_online_document_page_content"},
"invoke_online_drive_browse_files": {Type: "datasource", Path: "/datasource/online_drive_browse_files"},
"invoke_online_drive_download_file": {Type: "datasource", Path: "/datasource/online_drive_download_file"},
"fetch_parameter_options": {Type: "dynamic_parameter", Path: "/dynamic_select/fetch_parameter_options"},
"invoke_trigger_event": {Type: "trigger", Path: "/trigger/invoke_event"},
"dispatch_trigger_event": {Type: "trigger", Path: "/trigger/dispatch_event"},
"subscribe_trigger": {Type: "trigger", Path: "/trigger/subscribe"},
"unsubscribe_trigger": {Type: "trigger", Path: "/trigger/unsubscribe"},
"refresh_trigger": {Type: "trigger", Path: "/trigger/refresh"},
"validate_trigger_credentials": {Type: "trigger", Path: "/trigger/validate_credentials"},
}
Functions ¶
func BuildActionArgs ¶
func BuildActionArgs(manifest plugin_entities.PluginDeclaration, action string) (map[string]any, error)
func BuildExtractData ¶
func BuildExtractData(result ExtractResult) map[string]any
func RunExtract ¶
func RunExtract(cfg *SlimConfig, opts ExtractOptions, w io.Writer) error
func RunLocal ¶
func RunLocal(ctx *InvokeContext, local *LocalConfig, out *OutputWriter) error
func RunRemote ¶
func RunRemote(ctx *InvokeContext, remote *RemoteConfig, out *OutputWriter) error
func TransformRequest ¶
func TransformRequest(ctx *InvokeContext) ([]byte, string, error)
Types ¶
type ActionRoute ¶
func LookupRoute ¶
func LookupRoute(action string) (ActionRoute, bool)
type DaemonClient ¶
type DaemonClient struct {
// contains filtered or unexported fields
}
func NewDaemonClient ¶
func NewDaemonClient(addr, key string) *DaemonClient
func (*DaemonClient) Dispatch ¶
func (c *DaemonClient) Dispatch(ctx *InvokeContext) (io.ReadCloser, error)
func (*DaemonClient) Extract ¶
func (c *DaemonClient) Extract(pluginID string) (*ExtractResult, error)
type ErrorCode ¶
type ErrorCode string
const ( ErrInvalidInput ErrorCode = "INVALID_INPUT" ErrInvalidArgsJSON ErrorCode = "INVALID_ARGS_JSON" ErrConfigLoad ErrorCode = "CONFIG_LOAD_ERROR" ErrConfigInvalid ErrorCode = "CONFIG_INVALID" ErrUnknownMode ErrorCode = "UNKNOWN_MODE" ErrUnknownAction ErrorCode = "UNKNOWN_ACTION" ErrNotImplemented ErrorCode = "NOT_IMPLEMENTED" ErrNetwork ErrorCode = "NETWORK_ERROR" ErrDaemon ErrorCode = "DAEMON_ERROR" ErrStreamRead ErrorCode = "STREAM_READ_ERROR" ErrStreamParse ErrorCode = "STREAM_PARSE_ERROR" ErrPluginNotFound ErrorCode = "PLUGIN_NOT_FOUND" ErrPluginInit ErrorCode = "PLUGIN_INIT_ERROR" ErrPluginExec ErrorCode = "PLUGIN_EXEC_ERROR" ErrPluginDownload ErrorCode = "PLUGIN_DOWNLOAD_ERROR" ErrPluginDownloadTimeout ErrorCode = "PLUGIN_DOWNLOAD_TIMEOUT" ErrPluginPackageInvalid ErrorCode = "PLUGIN_PACKAGE_INVALID" ErrPluginPackageTooLarge ErrorCode = "PLUGIN_PACKAGE_TOO_LARGE" ErrPluginExtract ErrorCode = "PLUGIN_EXTRACT_ERROR" )
type ExtractArgs ¶
type ExtractOptions ¶
type ExtractResult ¶
type ExtractResult struct {
UniqueIdentifier string `json:"unique_identifier,omitempty"`
Manifest plugin_entities.PluginDeclaration `json:"manifest"`
Verification *decoder.Verification `json:"verification,omitempty"`
}
func ExtractLocal ¶
func ExtractLocal(opts ExtractOptions, local *LocalConfig) (*ExtractResult, error)
func ExtractRemote ¶
func ExtractRemote(opts ExtractOptions, remote *RemoteConfig) (*ExtractResult, error)
type InvokeContext ¶
type InvokeContext struct {
PluginID string
Action string
Request RequestMeta
}
func NewInvokeContext ¶
func NewInvokeContext(id, action, argsJSON string) (*InvokeContext, error)
type LocalConfig ¶
type LocalConfig struct {
Folder string `json:"folder"`
PythonPath string `json:"python_path"`
UvPath string `json:"uv_path"`
PythonEnvInitTimeout int `json:"python_env_init_timeout"`
MaxExecutionTimeout int `json:"max_execution_timeout"`
PipMirrorURL string `json:"pip_mirror_url"`
PipExtraArgs string `json:"pip_extra_args"`
MarketplaceURL string `json:"marketplace_url"`
IgnoreUvLock bool `json:"ignore_uv_lock"`
}
type OutputWriter ¶
type OutputWriter struct {
// contains filtered or unexported fields
}
func NewOutputWriter ¶
func NewOutputWriter(w io.Writer) *OutputWriter
func (*OutputWriter) Chunk ¶
func (o *OutputWriter) Chunk(data json.RawMessage) error
func (*OutputWriter) Done ¶
func (o *OutputWriter) Done() error
type RemoteConfig ¶
type RequestMeta ¶
type RequestMeta struct {
TenantID string `json:"tenant_id"`
UserID string `json:"user_id"`
Data json.RawMessage `json:"data"`
}
type SlimConfig ¶
type SlimConfig struct {
Mode string `json:"mode"`
Local LocalConfig `json:"local"`
Remote RemoteConfig `json:"remote"`
}
func LoadConfig ¶
func LoadConfig() (*SlimConfig, error)
func LoadConfigFromFile ¶
func LoadConfigFromFile(path string) (*SlimConfig, error)
func LoadExtractConfig ¶
func LoadExtractConfig(configFile string, hasLocalPath bool) (*SlimConfig, error)
Click to show internal directories.
Click to hide internal directories.