Utils
Plugin utils module for core plugin functionality.
- class smarter.apps.llmtool.plugin.utils.PluginExample(filepath, filename)[source]
Bases:
objectA class for loading and working with built-in YAML-based plugin examples.
This class reads plugin example files in YAML format, parses their contents, and exposes metadata and serialization methods for inspection and testing.
- Parameters:
See also
PluginExamplesfor managing collections of plugin examples.Example usage:
example = PluginExample(filepath="/path/to/examples", filename="my_plugin.yaml") print(example.name) print(example.to_yaml()) print(example.to_json())
- class smarter.apps.llmtool.plugin.utils.PluginExamples(*args, **kwargs)[source]
Bases:
objectA class for managing a collection of
PluginExampleinstances.This class loads all YAML-based plugin examples from a specified directory, providing access to the collection and utility methods for counting and retrieving examples.
- Parameters:
Note
Only files ending with
.yamlin the plugins path are loaded as examples.Tip
Use
count()to get the number of loaded plugin examples, and theplugins()property to access the list.See also
PluginExamplefor individual example details.Example usage:
examples = PluginExamples() print(examples.count()) for example in examples.plugins: print(example.filename, example.name)
- HERE = '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmtool/plugin'
- PLUGINS_PATH = '/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/llmtool/data/sample-plugins'
- property plugins: list[PluginExample]
Return a list of plugins in dictionary format.
- class smarter.apps.llmtool.plugin.utils.Plugins(user, account)[source]
Bases:
objectA 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:
Note
A plugin that cannot be loaded, for example one whose plugin data is missing, is logged and skipped.
See also
PluginControllerfor plugin instantiation.PluginMetafor plugin metadata.Example usage:
plugins = Plugins(user=my_user, account=my_account) plugin_dicts = plugins.data plugin_json = plugins.to_json()
- 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:
- plugins: list[PluginBase] = []
- user_profile: UserProfile | None = None