PluginSelector Model
PluginSelector model for defining plugin selection strategies within the Smarter platform.
- class smarter.apps.llmtool.models.plugin_selector.PluginSelector(*args, **kwargs)[source]
Bases:
TimestampedModelStores plugin selection strategies for a Smarter plugin.
The
PluginSelectormodel defines how and when a plugin is included in the prompt sent to the LLM (Large Language Model). Each instance is linked to aPluginMetaobject, representing the plugin whose selection logic is being configured.The primary function of this model is to specify a selection directive—such as
search_terms,always, orllm—that determines the conditions under which the plugin should be activated. For example, when the directive issearch_terms, thesearch_termsfield contains a list of keywords or phrases (in JSON format). If any of these terms are detected in the user’s prompt, Smarter will prioritize loading and invoking the associated plugin. This enables context-aware, dynamic plugin routing based on user intent.PluginSelectorworks in concert with other models in this module:It references
PluginMetato associate selection logic with a specific plugin.It is audited by
PluginSelectorHistory, which records each activation event, the triggering search term, and relevant user prompt context for analytics and debugging.It complements
PluginPrompt, which customizes the LLM prompt for each plugin, allowing for both selection and prompt configuration to be managed independently.
By supporting multiple selection strategies, this model enables flexible, intelligent plugin discovery and orchestration within the Smarter platform. It is essential for implementing advanced plugin routing, ensuring that the most relevant plugins are surfaced to the LLM based on user input and system configuration.
See also:
PluginMetaPluginSelectorHistorysmarter.apps.llmtool.manifest.enum.SAMPluginCommonSpecSelectorKeyDirectiveValues
- Parameters:
id (Unknown) – Primary key: ID
created_at (Unknown) – Created at
updated_at (Unknown) – Updated at
directive (Unknown) – Directive. The selection strategy to use for this plugin.
search_terms (Unknown) – Search terms. search terms in JSON format that, if detected in the user prompt, will incentivize Smarter to load this plugin.
Relationship fields:
- Parameters:
plugin (Unknown) – Plugin (related name:
plugin_selector_plugin)
Reverse relationships:
- Parameters:
plugin_selector_history_plugin_selector (Unknown) – All plugin selector history plugin selector of this plugin selector (related name of
plugin_selector)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- exception NotUpdated
Bases:
ObjectNotUpdated,DatabaseError
- SELECT_DIRECTIVES = [('search_terms', 'search_terms'), ('always', 'always'), ('llm', 'llm')]
- created_at
-
Created at
Timestamp indicating when the model instance was created.
This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.
- Type:
Type
- directive
-
Directive. The selection strategy to use for this plugin.
Choices:
search_termsalwaysllm
- Type:
Type
- classmethod get_cached_selector_by_plugin(plugin, invalidate=False)[source]
Return a single instance of PluginSelector by plugin.
This method caches the results to improve performance.
- Parameters:
plugin (
PluginMeta) – The plugin whose selector should be retrieved.- Returns:
A PluginSelector instance if found, otherwise None.
- Return type:
- get_directive_display(*, field=<django.db.models.CharField: directive>)
Shows the label of the
directive. Seeget_FOO_display()for more information.
- id
-
Primary key: ID
- Type:
Type
- objects = <django.db.models.Manager object>
- plugin
-
Plugin (related name:
plugin_selector_plugin)- Type:
Type
- plugin_selector_history_plugin_selector
Reverse
ForeignKeyfromPluginSelectorHistoryAll plugin selector history plugin selector of this plugin selector (related name of
plugin_selector)- Type:
Type
- search_terms
-
Search terms. search terms in JSON format that, if detected in the user prompt, will incentivize Smarter to load this plugin.
- Type:
Type
- updated_at
-
Updated at
Timestamp indicating when the model instance was last updated.
This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.
- Type:
Type