Utils

Plugin utils module for core plugin functionality.

class smarter.apps.llmtool.plugin.utils.Plugins(user, account)[source]

Bases: object

A class for managing and interacting with multiple plugins.

This class provides methods to retrieve, serialize, and work with plugins associated with a user and account. It loads plugins using metadata and controllers, and exposes their data in dictionary and JSON formats.

Parameters:
  • user (User) – The user for whom plugins are loaded.

  • account (Account) – The account context for plugin retrieval.

Note

A plugin that cannot be loaded, for example one whose plugin data is missing, is logged and skipped.

See also

PluginController for plugin instantiation. PluginMeta for plugin metadata.

Example usage:

plugins = Plugins(user=my_user, account=my_account)
plugin_dicts = plugins.data
plugin_json = plugins.to_json()
__init__(user, account)[source]
account: Account | None = None
property data: list[dict[str, Any]]

Return a list of plugins in dictionary format.

static load_plugin(plugin_meta, user_profile)[source]

Load a plugin, or log and skip it if it cannot be loaded.

One malformed plugin, for example one whose plugin data is missing, should not prevent the others from being listed.

Parameters:
  • plugin_meta (PluginMeta) – The plugin’s PluginMeta.

  • user_profile (UserProfile) – The plugin’s owner.

Returns:

The plugin, or None if it cannot be loaded.

Return type:

PluginBase | None

plugins: list[PluginBase] = []
to_json()[source]

Return a list of plugins in JSON format.

Return type:

list[dict[str, Any]]

user_profile: UserProfile | None = None
smarter.apps.llmtool.plugin.utils.should_log(level)[source]

Check if logging should be done based on the waffle switch.