plugin_manager.py


Overview

plugin_manager.py defines the PluginManager class responsible for discovering, loading, and managing plugins specifically of type LLM Tool plugins within the system. It leverages an external plugin loading mechanism (pluginlib.PluginLoader) to dynamically load plugins from the embedded plugin directory and provides interfaces to query and retrieve these plugins by name or in bulk.

This file plays a crucial role in the plugin architecture by encapsulating plugin lifecycle management and offering convenient access to loaded LLM tool plugins, which are likely used elsewhere in the application to extend or customize functionality related to Large Language Model (LLM) tools.


Classes and Methods

Class: PluginManager

Manages the lifecycle and access of LLM Tool plugins loaded from embedded plugin sources.

Properties

Methods


__init__(self) -> None

Initializes a new instance of PluginManager.


load_plugins(self) -> None

Discovers and loads plugins from the embedded plugins directory.


get_llm_tools(self) -> list[LLMToolPlugin]

Returns a list of all currently loaded LLM tool plugins.


get_llm_tool_by_name(self, name: str) -> LLMToolPlugin | None

Fetches a single LLM tool plugin by its unique name.


get_llm_tools_by_names(self, tool_names: list[str]) -> list[LLMToolPlugin]

Fetches multiple LLM tool plugins by a list of their names.


Important Implementation Details


Interaction with Other System Components


Visual Diagram

classDiagram
    class PluginManager {
        -_llm_tool_plugins: dict[str, LLMToolPlugin]
        +__init__()
        +load_plugins() void
        +get_llm_tools() list~LLMToolPlugin~
        +get_llm_tool_by_name(name: str) LLMToolPlugin | None
        +get_llm_tools_by_names(tool_names: list~str~) list~LLMToolPlugin~
    }
    PluginManager o-- LLMToolPlugin : manages

Summary

The plugin_manager.py file encapsulates the plugin loading and management logic for LLM tool plugins. It abstracts the complexities of plugin discovery, loading, and retrieval, providing a clean and straightforward API for clients to access these dynamically loaded components. This modular design supports extensibility and maintainability in applications that rely on pluggable LLM tool functionalities.