Documentation
¶
Overview ¶
Package plugin provides LUA-based plugin support for extending switchAILocal functionality. It allows users to write custom scripts that can intercept and modify API requests/responses.
Index ¶
- Constants
- type Classifier
- type Config
- type IntelligenceService
- type LuaEngine
- func (e *LuaEngine) Close()
- func (e *LuaEngine) IsEnabled() bool
- func (e *LuaEngine) LoadPlugins() error
- func (e *LuaEngine) RunHook(ctx context.Context, hookName string, data map[string]any) (map[string]any, error)
- func (e *LuaEngine) SetClassifier(c Classifier)
- func (e *LuaEngine) SetIntelligenceService(svc IntelligenceService)
- type SkillDefinition
Constants ¶
const ( HookOnRequest = "on_request" HookOnResponse = "on_response" )
Hook types for plugin execution points
const (
// SkipLuaContextKey is a context key used to prevent recursive LUA execution.
SkipLuaContextKey contextKey = "skip_lua"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Classifier ¶
Classifier defines the interface for LLM-based intent classification. It is used by the Lua engine to delegate classification requests back to the Go host.
type Config ¶
type Config struct {
// Enabled determines if the plugin engine is active
Enabled bool `yaml:"enabled" json:"enabled"`
// PluginDir is the directory containing LUA scripts
PluginDir string `yaml:"plugin-dir" json:"plugin-dir"`
// Intelligence holds settings for the Cortex routing engine
Intelligence config.IntelligenceConfig
// EnabledPlugins specifies a list of plugin IDs to load
EnabledPlugins []string
}
type IntelligenceService ¶
type IntelligenceService interface {
IsEnabled() bool
GetDiscoveryService() intelligence.DiscoveryServiceInterface
GetMatrixBuilder() intelligence.MatrixBuilderInterface
IsModelAvailable(modelID string) bool
GetSkillRegistry() *skills.Registry
GetEmbeddingEngine() *embedding.Engine
GetSemanticTier() intelligence.SemanticTierInterface
GetSemanticCache() intelligence.SemanticCacheInterface
GetConfidenceScorer() *confidence.Scorer
GetVerifier() *verification.Verifier
GetCascadeManager() intelligence.CascadeManagerInterface
GetFeedbackCollector() intelligence.FeedbackCollectorInterface
}
IntelligenceService defines the interface for Phase 2 intelligent routing features. It provides access to advanced capabilities like discovery, semantic matching, and skill registry.
type LuaEngine ¶
type LuaEngine struct {
// contains filtered or unexported fields
}
func NewLuaEngine ¶
NewLuaEngine creates a new LUA plugin engine with the given configuration.
func (*LuaEngine) Close ¶
func (e *LuaEngine) Close()
Close shuts down the LUA engine and cleans up resources.
func (*LuaEngine) LoadPlugins ¶
LoadPlugins loads all plugin directories from the plugin dir.
func (*LuaEngine) RunHook ¶
func (e *LuaEngine) RunHook(ctx context.Context, hookName string, data map[string]any) (map[string]any, error)
RunHook executes a specific hook function across all loaded plugins. Returns the modified data or the original if no modifications were made.
func (*LuaEngine) SetClassifier ¶
func (e *LuaEngine) SetClassifier(c Classifier)
SetClassifier sets the classifier implementation for the engine.
func (*LuaEngine) SetIntelligenceService ¶
func (e *LuaEngine) SetIntelligenceService(svc IntelligenceService)
SetIntelligenceService sets the intelligence service implementation for the engine. This allows Lua plugins to access Phase 2 intelligent routing features.