LLMClientPlugin Model

class smarter.apps.llm_client.models.LLMClientPlugin(*args, **kwargs)[source]

Bases: TimestampedModel

Represents the association between a LLMClient instance and its enabled plugins within the Smarter platform.

This model establishes a many-to-one relationship, where each plugin entry is linked to a specific LLMClient and references metadata describing the plugin. By maintaining this mapping, the platform can manage which plugins are available to each llm_client, enabling extensibility and customization of llm_client capabilities.

The LLMClientPlugin model supports use cases such as plugin activation, deactivation, and enumeration for individual llm_clients. It is essential for scenarios where llm_clients require additional functionality provided by external or internal plugins, such as integrations, enhanced processing, or custom behaviors.

Model Relationships

  • Each LLMClientPlugin is linked to one LLMClient instance.

  • Each LLMClientPlugin references one PluginMeta instance, which contains metadata about the plugin.

Usage Example

# Add a plugin to an llm_client
plugin_meta = PluginMeta.objects.get(name="weather")
llm_client_plugin = LLMClientPlugin.objects.create(llm_client=my_llm_client, plugin_meta=plugin_meta)

# List all plugins for an llm_client
plugins = LLMClientPlugin.objects.filter(llm_client=my_llm_client)

Notes

  • Plugin management and loading are handled via the PluginController and related infrastructure.

  • This model is intended for internal use to support dynamic extension of llm_client features.

  • Uniqueness is enforced for each (llm_client, plugin_meta) pair to prevent duplicate plugin assignments.

Parameters:
  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

Relationship fields:

Parameters:
  • llm_client (Unknown) –

    Llm client (related name: llmclientplugin)

    The LLMClient instance associated with this plugin.

  • plugin_meta (Unknown) –

    Plugin meta (related name: llmclientplugin)

    The metadata for the plugin associated with the LLMClient.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

created_at

DateTimeField

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

classmethod get_cached_objects(invalidate=False, llm_client=None)[source]

Retrieve a queryset of LLMClientPlugin instances associated with a LLMClient using caching.

Parameters:
  • invalidate (Optional[bool]) – Whether to invalidate the cache for this retrieval.

  • llm_client (Optional[LLMClient]) – The LLMClient instance for which to retrieve plugins.

Returns:

A queryset of LLMClientPlugin instances associated with the LLMClient.

Return type:

QuerySet

id

BigAutoField

Primary key: ID

Type:

Type

llm_client

ForeignKey to LLMClient

Llm client (related name: llmclientplugin)

The LLMClient instance associated with this plugin.

Type:

Type

llm_client_id

Internal field, use llm_client instead.

classmethod load(llm_client, data)[source]

Load (aka import) a plugin from a data file in yaml or json format.

Parameters:
  • llm_client (LLMClient) – The LLMClient instance to associate with the plugin.

  • data – The plugin manifest data in yaml or json format.

Returns:

The created LLMClientPlugin instance.

Return type:

LLMClientPlugin

See Also:

objects = <django.db.models.Manager object>
property plugin: PluginBase | None

Returns the Plugin instance associated with this LLMClientPlugin.

Returns:

Plugin instance or None

Return type:

Optional[PluginBase]

plugin_meta

ForeignKey to PluginMeta

Plugin meta (related name: llmclientplugin)

The metadata for the plugin associated with the LLMClient.

Type:

Type

plugin_meta_id

Internal field, use plugin_meta instead.

classmethod plugins(llm_client)[source]

Returns a list of Plugin instances associated with the given LLMClient.

Parameters:

llm_client (LLMClient) – The LLMClient instance to retrieve plugins for.

Returns:

List of Plugin instances.

Return type:

List[PluginBase]

Raises:

SmarterValueError – If admin user for llm_client account is not found or if a plugin fails to load.

See Also:

  • smarter.apps.plugin.controller.PluginController

classmethod plugins_json(llm_client)[source]
Return type:

List[dict]

updated_at

DateTimeField

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