plugins

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbedderPlugin

type EmbedderPlugin interface {
	Plugin

	// Embedder returns the embedding provider implementation
	//
	// Returns:
	// - embedding.Provider: Embedding provider implementation
	Embedder() embedding.Provider
}

EmbedderPlugin defines the interface for embedding provider plugins

Embedder plugins add support for new embedding models.

Example implementation:

type MyEmbedderPlugin struct {
    MyPlugin
    embedder embedding.Provider
}

func (p *MyEmbedderPlugin) Embedder() embedding.Provider {
    return p.embedder
}

type LLMPlugin

type LLMPlugin interface {
	Plugin

	// LLM returns the LLM client implementation
	//
	// Returns:
	// - llm.Client: LLM client implementation
	LLM() llm.Client
}

LLMPlugin defines the interface for LLM client plugins

LLM plugins add support for new LLM providers.

Example implementation:

type MyLLMPlugin struct {
    MyPlugin
    llmClient llm.Client
}

func (p *MyLLMPlugin) LLM() llm.Client {
    return p.llmClient
}

type ParserPlugin

type ParserPlugin interface {
	Plugin

	// Parser returns the parser implementation
	//
	// Returns:
	// - parser.Parser: Parser implementation
	Parser() parser.Parser
}

ParserPlugin defines the interface for parser plugins

Parser plugins add support for new file formats to the RAG engine.

Example implementation:

type MyParserPlugin struct {
    MyPlugin
    parser parser.Parser
}

func (p *MyParserPlugin) Parser() parser.Parser {
    return p.parser
}

type Plugin

type Plugin interface {
	// Name returns the name of the plugin
	//
	// Returns:
	// - string: Unique name of the plugin
	Name() string

	// Type returns the type of the plugin
	//
	// Returns:
	// - PluginType: Type of the plugin
	Type() PluginType

	// Init initializes the plugin with the given configuration
	//
	// Parameters:
	// - config: Configuration map for the plugin
	//
	// Returns:
	// - error: Error if initialization fails
	Init(config map[string]interface{}) error
}

Plugin defines the interface for all plugins

This is the base interface that all plugins must implement. It provides basic metadata and initialization functionality.

Example implementation:

type MyPlugin struct {
    name string
    pluginType PluginType
}

func (p *MyPlugin) Name() string {
    return p.name
}

func (p *MyPlugin) Type() PluginType {
    return p.pluginType
}

func (p *MyPlugin) Init(config map[string]interface{}) error {
    // Initialize plugin with config
    return nil
}

type PluginType

type PluginType string

PluginType defines the type of plugin

This type categorizes the different types of plugins that can be registered with the GoRAG framework.

const (
	// PluginTypeParser represents a document parser plugin
	// These plugins add support for new file formats
	PluginTypeParser PluginType = "parser"
	// PluginTypeVectorStore represents a vector store plugin
	// These plugins add support for new vector database backends
	PluginTypeVectorStore PluginType = "vectorstore"
	// PluginTypeEmbedder represents an embedding provider plugin
	// These plugins add support for new embedding models
	PluginTypeEmbedder PluginType = "embedder"
	// PluginTypeLLM represents an LLM client plugin
	// These plugins add support for new LLM providers
	PluginTypeLLM PluginType = "llm"
)

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages plugins

The Registry is responsible for registering, storing, and retrieving plugins.

Example usage:

registry := plugins.NewRegistry()

// Register a plugin
err := registry.Register(myPlugin)
if err != nil {
    log.Fatal(err)
}

// Get a plugin by name
plugin := registry.Get("my-plugin")

// Get all plugins of a type
parserPlugins := registry.GetByType(plugins.PluginTypeParser)

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new plugin registry

Returns: - *Registry: New plugin registry instance

func (*Registry) Get

func (r *Registry) Get(name string) Plugin

Get returns a plugin by name

Parameters: - name: Name of the plugin

Returns: - Plugin: Plugin instance or nil if not found

func (*Registry) GetByType

func (r *Registry) GetByType(pluginType PluginType) []Plugin

GetByType returns all plugins of a specific type

Parameters: - pluginType: Type of plugins to return

Returns: - []Plugin: Slice of plugins of the specified type

func (*Registry) List

func (r *Registry) List() []Plugin

List returns all registered plugins

func (*Registry) Load

func (r *Registry) Load(path string) error

Load loads a plugin from a shared library

func (*Registry) LoadPluginsFromDirectory added in v1.0.1

func (r *Registry) LoadPluginsFromDirectory(directory string) (int, int, error)

LoadPluginsFromDirectory loads all plugins from a directory

Parameters: - directory: Directory to load plugins from

Returns: - int: Number of successfully loaded plugins - int: Number of failed plugins - error: Error if directory access fails

func (*Registry) Register

func (r *Registry) Register(plugin Plugin) error

Register registers a plugin

Parameters: - plugin: Plugin to register

Returns: - error: Error if registration fails (e.g., duplicate name)

type VectorStorePlugin

type VectorStorePlugin interface {
	Plugin

	// VectorStore creates and returns a vector store instance
	//
	// Parameters:
	// - ctx: Context for cancellation and timeout
	//
	// Returns:
	// - vectorstore.Store: Vector store instance
	// - error: Error if creation fails
	VectorStore(ctx context.Context) (vectorstore.Store, error)
}

VectorStorePlugin defines the interface for vector store plugins

Vector store plugins add support for new vector database backends.

Example implementation:

type MyVectorStorePlugin struct {
    MyPlugin
    config map[string]interface{}
}

func (p *MyVectorStorePlugin) VectorStore(ctx context.Context) (vectorstore.Store, error) {
    // Create and return vector store instance
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL