Documentation
¶
Index ¶
- Constants
- type Credentials
- type DeleteModelRequest
- type DeleteRequest
- type EngineConfig
- type EngineRecommendConfig
- type EngineStatus
- type EngineVersionResponse
- type HealthStatus
- type InvokeRequest
- type InvokeResponse
- type ListModelsResponse
- type ListResponse
- type LoadModelRequest
- type LoadRequest
- type LocalTime
- type ModelDetails
- type ModelInfo
- type OllamaResources
- type PlatformConfig
- type PluginError
- type PluginManifest
- func (m *PluginManifest) GetPlatformConfig(goos, goarch string) (*PlatformConfig, error)
- func (m *PluginManifest) GetServiceByName(serviceName string) (*ServiceDef, error)
- func (m *PluginManifest) ListServiceNames() []string
- func (m *PluginManifest) SaveManifest(pluginDir string, format string) error
- type PluginStatus
- type ProgressResponse
- type ProviderInfo
- type PullModelRequest
- type PullProgressFunc
- type RecommendModelData
- type ResourcesConfig
- type ServiceCapabilities
- type ServiceDef
- type StreamChunk
- type UnloadModelRequest
Constants ¶
const ( // PluginTypeLocal represents local engine plugins (manage local AI engines). PluginTypeLocal = "local" // PluginTypeRemote represents remote API plugins (integrate with cloud AI services). PluginTypeRemote = "remote" )
Plugin types
const ( ProtocolHTTP = "http" ProtocolHTTPS = "https" ProtocolGRPC = "grpc" ProtocolGRPCWeb = "grpc-web" ProtocolWebSocket = "websocket" ProtocolWSS = "wss" )
Protocol types
const ( ServiceTypeChat = "chat" ServiceTypeEmbed = "embed" ServiceTypeGenerate = "generate" ServiceTypeTextToImage = "text-to-image" ServiceTypeImageToImage = "image-to-image" ServiceTypeImageToVideo = "image-to-video" ServiceTypeTextToVideo = "text-to-video" ServiceTypeTextToSpeech = "text-to-speech" ServiceTypeSpeechToText = "speech-to-text" ServiceTypeVision = "vision" )
Service types
const ( AuthTypeNone = "none" AuthTypeAPIKey = "apikey" AuthTypeToken = "token" AuthTypeOAuth = "oauth" AuthTypeSign = "sign" )
Authentication types
const ( GPUTypeNone = "none" GPUTypeNvidia = "nvidia" GPUTypeAmd = "amd" GPUTypeIntelArc = "intel_arc" )
GPU types
const ( // General error codes ErrCodeSuccess = 0 ErrCodeUnknown = 1 ErrCodeInvalidArgument = 2 ErrCodeNotFound = 3 ErrCodeAlreadyExists = 4 ErrCodePermissionDenied = 5 ErrCodeResourceExhausted = 6 ErrCodeFailedPrecondition = 7 ErrCodeAborted = 8 ErrCodeOutOfRange = 9 ErrCodeUnimplemented = 10 ErrCodeInternal = 11 ErrCodeDataLoss = 13 ErrCodeUnauthenticated = 14 // Plugin-specific error codes (1000-1999) ErrCodePluginNotFound = 1000 ErrCodePluginLoadFailed = 1001 ErrCodePluginInvalidConfig = 1002 ErrCodePluginStartFailed = 1003 ErrCodePluginStopFailed = 1004 ErrCodePluginHealthCheckFailed = 1005 // Engine-specific error codes (2000-2999) ErrCodeEngineNotFound = 2000 ErrCodeEngineNotInstalled = 2001 ErrCodeEngineStartFailed = 2002 ErrCodeEngineStopFailed = 2003 ErrCodeEngineInstallFailed = 2004 ErrCodeEngineUpgradeFailed = 2005 ErrCodeEngineHealthCheckFailed = 2006 // Model-specific error codes (3000-3999) ErrCodeModelNotFound = 3000 ErrCodeModelPullFailed = 3001 ErrCodeModelDeleteFailed = 3002 ErrCodeModelLoadFailed = 3003 ErrCodeModelUnloadFailed = 3004 ErrCodeModelInvalidFormat = 3005 // Service invocation error codes (4000-4999) ErrCodeServiceNotFound = 4000 ErrCodeServiceTimeout = 4002 ErrCodeServiceInvalidRequest = 4003 ErrCodeServiceInvalidResponse = 4004 ErrCodeServiceStreamingNotSupported = 4005 ErrCodeServiceBidirectionalNotSupported = 4006 )
Error codes
const ( StatusRunning = "running" StatusStopped = "stopped" StatusInstalling = "installing" StatusError = "error" StatusUnknown = "unknown" )
Operation status constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
type Credentials struct {
Type string `json:"type"` // apikey, token, oauth, etc.
Values map[string]string `json:"values"` // key-value pairs
}
Credentials represents authentication credentials.
type DeleteModelRequest ¶
type DeleteModelRequest struct {
Model string `json:"model"`
}
DeleteModelRequest is the request for deleting a model.
type DeleteRequest ¶
type DeleteRequest = DeleteModelRequest
DeleteRequest is an alias of DeleteModelRequest for backward compatibility.
type EngineConfig ¶
type EngineConfig struct {
Host string `json:"host"`
Scheme string `json:"scheme"` // http/https
EnginePath string `json:"engine_path"`
ExecFile string `json:"exec_file"`
ExecPath string `json:"exec_path"`
DownloadURL string `json:"download_url"`
DownloadPath string `json:"download_path"`
DeviceType string `json:"device_type,omitempty"` // GPU type
}
EngineConfig represents basic engine configuration.
type EngineRecommendConfig ¶
type EngineRecommendConfig struct {
Host string `json:"host"`
Origin string `json:"origin"`
Scheme string `json:"scheme"`
RecommendModel string `json:"recommend_model"`
DownloadUrl string `json:"download_url"`
DownloadPath string `json:"download_path"`
EnginePath string `json:"engine_path"`
ExecPath string `json:"exec_path"`
ExecFile string `json:"exec_file"`
DeviceType string `json:"device_type"`
}
EngineRecommendConfig represents extended engine configuration.
type EngineStatus ¶
type EngineStatus struct {
Name string `json:"name"`
Version string `json:"version"`
Status string `json:"status"` // running, stopped, installing, error
Message string `json:"message,omitempty"`
}
EngineStatus represents the status of an engine.
type EngineVersionResponse ¶
type EngineVersionResponse struct {
Version string `json:"version"`
}
EngineVersionResponse represents the engine version response.
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"` // UP, DOWN, UNKNOWN
Message string `json:"message,omitempty"`
Details map[string]string `json:"details,omitempty"`
}
HealthStatus represents the health status.
type InvokeRequest ¶
type InvokeRequest struct {
ServiceName string `json:"service_name"`
RequestBody []byte `json:"request_body"`
Headers map[string]string `json:"headers,omitempty"`
}
InvokeRequest represents a plugin service invocation request.
type InvokeResponse ¶
type InvokeResponse struct {
ResponseBody []byte `json:"response_body"`
Headers map[string]string `json:"headers,omitempty"`
StatusCode int `json:"status_code,omitempty"`
}
InvokeResponse represents a plugin service invocation response.
type ListModelsResponse ¶
type ListModelsResponse struct {
Models []ModelInfo `json:"models"`
}
ListModelsResponse is the response for listing models.
type ListResponse ¶
type ListResponse = ListModelsResponse
ListResponse is an alias of ListModelsResponse for backward compatibility.
type LoadModelRequest ¶
type LoadModelRequest struct {
Model string `json:"model"`
}
LoadModelRequest is the request for loading a model.
type LoadRequest ¶
type LoadRequest = LoadModelRequest
LoadRequest is an alias of LoadModelRequest for backward compatibility.
type ModelDetails ¶
type ModelDetails struct {
Format string `json:"format"`
Family string `json:"family"`
Families []string `json:"families"`
ParameterSize string `json:"parameter_size"`
QuantizationLevel string `json:"quantization_level"`
}
ModelDetails contains detailed model information.
type ModelInfo ¶
type ModelInfo struct {
Name string `json:"name"`
Model string `json:"model"`
ModifiedAt time.Time `json:"modified_at"`
Size int64 `json:"size"`
Digest string `json:"digest,omitempty"`
Details *ModelDetails `json:"details,omitempty"`
}
ModelInfo represents model information.
type OllamaResources ¶
type OllamaResources struct {
Executable string `json:"executable,omitempty" yaml:"executable,omitempty"`
ModelsDir string `json:"models_dir,omitempty" yaml:"models_dir,omitempty"`
DownloadDir string `json:"download_dir,omitempty" yaml:"download_dir,omitempty"`
}
OllamaResources defines Ollama resource configuration.
type PlatformConfig ¶
type PlatformConfig struct {
Executable string `json:"executable" yaml:"executable"`
Dependencies []string `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
}
PlatformConfig defines platform-specific configuration.
type PluginError ¶
type PluginError struct {
Code int `json:"code"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
}
PluginError represents a plugin error.
func NewPluginError ¶
func NewPluginError(code int, message string, details string) *PluginError
NewPluginError creates a new plugin error.
func (*PluginError) Error ¶
func (e *PluginError) Error() string
type PluginManifest ¶
type PluginManifest struct {
Version string `json:"version" yaml:"version"`
Provider ProviderInfo `json:"provider" yaml:"provider"`
Services []ServiceDef `json:"services" yaml:"services"`
Platforms map[string]PlatformConfig `json:"platforms,omitempty" yaml:"platforms,omitempty"`
Resources *ResourcesConfig `json:"resources,omitempty" yaml:"resources,omitempty"`
// PluginDir is the plugin directory path (injected at runtime, not serialized).
PluginDir string `json:"-" yaml:"-"`
}
PluginManifest defines the complete metadata for a plugin. This is the core SDK type that defines the structure of plugin.yaml.
func LoadManifest ¶
func LoadManifest(pluginDir string) (*PluginManifest, error)
LoadManifest loads plugin metadata from the specified directory.
func (*PluginManifest) GetPlatformConfig ¶
func (m *PluginManifest) GetPlatformConfig(goos, goarch string) (*PlatformConfig, error)
GetPlatformConfig returns the configuration for the specified platform.
func (*PluginManifest) GetServiceByName ¶
func (m *PluginManifest) GetServiceByName(serviceName string) (*ServiceDef, error)
GetServiceByName returns the service definition by name.
func (*PluginManifest) ListServiceNames ¶
func (m *PluginManifest) ListServiceNames() []string
ListServiceNames returns all service names.
func (*PluginManifest) SaveManifest ¶
func (m *PluginManifest) SaveManifest(pluginDir string, format string) error
SaveManifest saves the plugin metadata to a file.
type PluginStatus ¶
type PluginStatus struct {
Name string `json:"name"`
Version string `json:"version"`
Status string `json:"status"` // running, stopped, error
Message string `json:"message,omitempty"`
}
PluginStatus represents the status of a plugin.
type ProgressResponse ¶
type ProgressResponse struct {
Status string `json:"status"`
Digest string `json:"digest,omitempty"`
Total int64 `json:"total,omitempty"`
Completed int64 `json:"completed,omitempty"`
}
ProgressResponse represents progress for operations like model downloads.
type ProviderInfo ¶
type ProviderInfo struct {
Name string `json:"name" yaml:"name"`
DisplayName string `json:"display_name" yaml:"display_name"`
Version string `json:"version" yaml:"version"`
Type string `json:"type" yaml:"type"` // local/remote
Author string `json:"author,omitempty" yaml:"author,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Homepage string `json:"homepage,omitempty" yaml:"homepage,omitempty"`
EngineHost string `json:"engine_host,omitempty" yaml:"engine_host,omitempty"` // Engine base URL (required for local type)
}
ProviderInfo defines the basic information about a plugin provider.
type PullModelRequest ¶
type PullModelRequest struct {
Model string `json:"model"`
Insecure bool `json:"insecure,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Stream *bool `json:"stream,omitempty"`
Name string `json:"name,omitempty"` // alias (for backward compatibility)
ModelType string `json:"model_type,omitempty"` // model type (OpenVINO-specific)
}
PullModelRequest is the request for pulling a model.
type PullProgressFunc ¶
type PullProgressFunc func(ProgressResponse) error
PullProgressFunc is a progress callback function for LocalPluginProvider.PullModel to provide streaming progress notifications.
type RecommendModelData ¶
type RecommendModelData struct {
Id string `json:"id"`
Service string `json:"service_name"`
ApiFlavor string `json:"api_flavor"`
Flavor string `json:"flavor"`
Method string `json:"method" default:"POST"`
Desc string `json:"desc"`
Url string `json:"url"`
AuthType string `json:"auth_type"`
AuthApplyUrl string `json:"auth_apply_url"`
AuthFields []string `json:"auth_fields"`
Name string `json:"name"`
ServiceProvider string `json:"service_provider_name"`
Size string `json:"size"`
IsRecommended bool `json:"is_recommended" default:"false"`
Status string `json:"status"`
Avatar string `json:"avatar"`
CanSelect bool `json:"can_select" default:"false"`
Class []string `json:"class"`
OllamaId string `json:"ollama_id"`
ParamsSize float32 `json:"params_size"`
InputLength int `json:"input_length"`
OutputLength int `json:"output_length"`
Source string `json:"source"`
IsDefault string `json:"is_default" default:"false"`
Think bool `json:"think"`
ThinkSwitch bool `json:"think_switch"`
Tools bool `json:"tools"` // 是否支持工具调用
Context float32 `json:"context"`
CreatedAt LocalTime `json:"created_at"`
}
type ResourcesConfig ¶
type ResourcesConfig struct {
// DataDir is the data root directory, supports environment variable expansion.
DataDir string `json:"data_dir,omitempty" yaml:"data_dir,omitempty"`
// Ollama contains Ollama-specific resource configuration (optional, depends on plugin type).
Ollama *OllamaResources `json:"ollama,omitempty" yaml:"ollama,omitempty"`
}
ResourcesConfig defines plugin-managed resource configuration.
type ServiceCapabilities ¶
type ServiceCapabilities struct {
// SupportStreaming indicates if HTTP protocol supports streaming response.
SupportStreaming bool `json:"support_streaming,omitempty" yaml:"support_streaming,omitempty"`
// SupportBidirectional indicates if bidirectional streaming is supported.
SupportBidirectional bool `json:"support_bidirectional,omitempty" yaml:"support_bidirectional,omitempty"`
}
ServiceCapabilities declares the capabilities of a service.
type ServiceDef ¶
type ServiceDef struct {
ServiceName string `json:"service_name" yaml:"service_name"`
TaskType string `json:"task_type" yaml:"task_type"`
Protocol string `json:"protocol" yaml:"protocol"`
ExposeProtocol string `json:"expose_protocol" yaml:"expose_protocol"`
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
AuthType string `json:"auth_type,omitempty" yaml:"auth_type,omitempty"`
DefaultModel string `json:"default_model,omitempty" yaml:"default_model,omitempty"`
SupportModels []string `json:"support_models,omitempty" yaml:"support_models,omitempty"`
// ConfigRef references an existing template configuration, format: "flavor:service"
ConfigRef string `json:"config_ref,omitempty" yaml:"config_ref,omitempty"`
// Timeout is the service invocation timeout in seconds.
// - Not set (0): Use default timeout (60s for unary, 300s for streaming)
// - Positive value (N > 0): Custom timeout of N seconds
// - Negative value (N < 0): No timeout limit (recommended for time-consuming services like text-to-image, model downloads)
// AOG uses context.WithTimeout for positive values and context.WithCancel for negative values.
Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Middlewares []string `json:"middlewares,omitempty" yaml:"middlewares,omitempty"`
Capabilities ServiceCapabilities `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
}
ServiceDef defines a service supported by the plugin.
func (*ServiceDef) GetInvokeMode ¶
func (s *ServiceDef) GetInvokeMode() string
GetInvokeMode returns the recommended invocation mode.
func (*ServiceDef) SupportsBidirectional ¶
func (s *ServiceDef) SupportsBidirectional() bool
SupportsBidirectional checks if the service supports bidirectional streaming.
func (*ServiceDef) SupportsStreaming ¶
func (s *ServiceDef) SupportsStreaming() bool
SupportsStreaming checks if the service supports streaming response.
type StreamChunk ¶
type StreamChunk struct {
Data []byte // chunk data
Error error // error information
IsFinal bool // whether this is the final chunk
Metadata map[string]string // metadata (e.g., content-type)
}
StreamChunk represents a chunk in streaming response (e.g., SSE, NDJSON).
type UnloadModelRequest ¶
type UnloadModelRequest struct {
Models []string `json:"models"`
}
UnloadModelRequest is the request for unloading models.