Plugin_manager

Plugin_manager#

evofabric.plugin_manager.PluginTypeDict#

Plugin type dictionary, mapping base classes to their corresponding string identifiers. Used for dynamic loading and registration of plugins.

Type:

Dict[type, str]

Example:
PluginTypeDict = {

ChatClientBase: “ChatClientBase”, EmbedClientBase: “EmbedClientBase”, RerankClientBase: “RerankClientBase”, SyncNode: “SyncNode”, AsyncNode: “AsyncNode”, SyncStreamNode: “SyncStreamNode”, AsyncStreamNode: “AsyncStreamNode”, MemBase: “MemBase”, ToolManager: “ToolManager”, McpToolManager: “McpToolManager”, CodeSandbox: “CodeSandbox”, DBBase: “DBBase”

}

evofabric.plugin_manager.load_plugins(parent_cls, tool_type)[source]#

Dynamically load plugins of the specified type and return a plugin class dictionary.

Parameters:
  • parent_cls (type) – Plugin base class, loaded plugin classes will inherit from this class.

  • tool_type (str) – Plugin type string, corresponding to the group name of entry points.

Returns:

The loaded plugin dictionary, where keys are entry point names and values are dynamically generated plugin classes.

Return type:

Dict[str, type]

Note

  1. Use importlib.metadata.entry_points to get all entry points for the specified group.

  2. Call the registration function of each entry point to obtain the plugin’s full class path.

  3. Dynamically import a module and obtain the plugin class object.

  4. Use type to dynamically create a new class that inherits from parent_cls and plugin class.

  5. Add the new class to the returned dictionary.

evofabric.plugin_manager.init_plugins()[source]#

Initialize all plugins, automatically loading the corresponding plugins based on PluginTypeDict.

Note

  1. Iterate through each (plugin base class, tool type) pair in PluginTypeDict.

  2. Call load_plugins() for each base class and tool type to load plugins.

  3. This function is mainly used for the unified initialization of all plugins during system startup.