Refactor the current function tool implementation to create a plugin-based architecture that enables easy addition of new assistant capabilities without modifying core code.
The current implementation in generateToolOutputs
is hardcoded with limited extensibility. Adding new functions requires modifying the core implementation, making the system difficult to extend and maintain.
type FunctionPlugin interface {
// Metadata returns information about the function
Metadata() FunctionMetadata
// Execute runs the function with provided parameters
Execute(ctx context.Context, params map[string]interface{}) (interface{}, error)
// ValidateParameters checks if parameters are valid
ValidateParameters(params map[string]interface{}) error
}
type FunctionMetadata struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]ParameterDef `json:"parameters"`
Required []string `json:"required"`
Version string `json:"version"`
Author string `json:"author"`
Tags []string `json:"tags"`
}
type ParameterDef struct {
Type string `json:"type"`
Description string `json:"description"`
Enum []string `json:"enum,omitempty"`
Default interface{} `json:"default,omitempty"`
}
type FunctionRegistry interface {
// RegisterFunction adds a function to the registry
RegisterFunction(plugin FunctionPlugin) error
// GetFunction retrieves a function by name
GetFunction(name string) (FunctionPlugin, error)
// ListFunctions returns all registered functions
ListFunctions() []FunctionMetadata
// EnableFunction enables a function
EnableFunction(name string) error
// DisableFunction disables a function
DisableFunction(name string) error
}