Models

Smarter Extension models.

An Extension is an installable Python package that adds LLM tools to the platform. Only superusers install, update, configure and uninstall extensions, from the Django admin console. The code of an extension is stored in the database, as the archive of each ExtensionVersion, so that every process of every pod loads the same code without a redeploy. See smarter.apps.llmtool.extension.

class smarter.apps.llmtool.models.extension.Extension(*args, **kwargs)[source]

Bases: TimestampedModel

An installed Smarter Extension.

There is one row per extension, whatever its version. installed_version is the version that runs, and latest_version is the newest compatible version that the registry offers, so that the admin console can say an update is available.

An extension runs only while it is enabled, and only for the LLMClients of the accounts it is available to: every account if all_accounts, otherwise the accounts listed.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • slug (Unknown) – Slug. The extension’s permanent identifier, e.g. weather.

  • display_name (Unknown) – Display name. The extension’s name, as shown to people.

  • description (Unknown) – Description. A one-line description.

  • publisher (Unknown) – Publisher. The publisher’s registry id, or the archive’s authors.

  • source (Unknown) – Source

  • trust_badge (Unknown) – Trust badge

  • enabled (Unknown) – Enabled. Whether the extension’s tools are offered to LLMs.

  • latest_version (Unknown) – Latest version. The newest compatible version in the registry.

  • latest_checked_at (Unknown) – Latest checked at. When the registry was last checked for updates.

  • all_accounts (Unknown) – All accounts. Whether every account may use the extension.

  • error (Unknown) – Error. The last error from loading the extension or running its lifecycle hooks.

Relationship fields:

Parameters:
  • installed_version (Unknown) – Installed version. The version that runs. (related name: +)

  • accounts (Unknown) – Accounts. The accounts that may use the extension, when it is not available to all accounts. (related name: extensions)

Reverse relationships:

Parameters:
  • llmclient_extensions (Unknown) – All llmclient extensions of this Extension (related name of extension)

  • versions (Unknown) – All versions of this Extension (related name of extension)

  • settings (Unknown) – All settings of this Extension (related name of extension)

  • resources (Unknown) – All resources of this Extension (related name of extension)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

accounts

ManyToManyField to Account

Accounts. The accounts that may use the extension, when it is not available to all accounts. (related name: extensions)

Type:

Type

all_accounts

BooleanField

All accounts. Whether every account may use the extension.

Type:

Type

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

description

TextField

Description. A one-line description.

Type:

Type

display_name

CharField

Display name. The extension’s name, as shown to people.

Type:

Type

enabled

BooleanField

Enabled. Whether the extension’s tools are offered to LLMs.

Type:

Type

error

TextField

Error. The last error from loading the extension or running its lifecycle hooks.

Type:

Type

get_source_display(*, field=<django.db.models.CharField: source>)

Shows the label of the source. See get_FOO_display() for more information.

get_trust_badge_display(*, field=<django.db.models.CharField: trust_badge>)

Shows the label of the trust_badge. See get_FOO_display() for more information.

id

BigAutoField

Primary key: ID

Type:

Type

installed_version

ForeignKey to ExtensionVersion

Installed version. The version that runs. (related name: +)

Type:

Type

installed_version_id

Internal field, use installed_version instead.

is_available_to(account)[source]

Return whether an account may use this extension.

Parameters:

account (Account | None) – The account, e.g. the owner of an LLMClient.

Return type:

bool

Returns:

True if the extension is available to all accounts, or to this one.

latest_checked_at

DateTimeField

Latest checked at. When the registry was last checked for updates.

Type:

Type

latest_version

CharField

Latest version. The newest compatible version in the registry.

Type:

Type

llmclient_extensions

Reverse ForeignKey from LLMClientExtensions

All llmclient extensions of this Extension (related name of extension)

Type:

Type

objects = <django.db.models.Manager object>
publisher

CharField

Publisher. The publisher’s registry id, or the archive’s authors.

Type:

Type

resources

Reverse ForeignKey from ExtensionResource

All resources of this Extension (related name of extension)

Type:

Type

settings

Reverse ForeignKey from ExtensionSetting

All settings of this Extension (related name of extension)

Type:

Type

slug

CharField

Slug. The extension’s permanent identifier, e.g. weather.

Type:

Type

source

CharField

Source

Choices:

  • registry

  • upload

Type:

Type

trust_badge

CharField

Trust badge

Choices:

  • official

  • verified

  • community

  • unverified

Type:

Type

property update_available: bool

Whether the registry offers a newer version than the installed one.

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

versions

Reverse ForeignKey from ExtensionVersion

All versions of this Extension (related name of extension)

Type:

Type

class smarter.apps.llmtool.models.extension.ExtensionResource(*args, **kwargs)[source]

Bases: TimestampedModel

A SAM resource that an extension created, so that uninstalling it deletes exactly what it created.

Resources are created from the manifests in the package’s manifests/ directory, and by lifecycle hooks with apply_manifest().

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • kind (Unknown) – Kind. The resource’s SAM kind, e.g. Secret.

  • name (Unknown) – Name. The resource’s name.

  • version (Unknown) – Version. The extension version that created or last applied it.

  • managed (Unknown) – Managed. Whether it came from the package’s manifests/ directory, rather than a lifecycle hook.

Relationship fields:

Parameters:
  • extension (Unknown) – Extension (related name: resources)

  • user_profile (Unknown) – User profile. The resource’s owner. (related name: +)

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

extension

ForeignKey to Extension

Extension (related name: resources)

Type:

Type

extension_id

Internal field, use extension instead.

id

BigAutoField

Primary key: ID

Type:

Type

kind

CharField

Kind. The resource’s SAM kind, e.g. Secret.

Type:

Type

managed

BooleanField

Managed. Whether it came from the package’s manifests/ directory, rather than a lifecycle hook.

Type:

Type

name

CharField

Name. The resource’s name.

Type:

Type

objects = <django.db.models.Manager object>
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

user_profile

ForeignKey to UserProfile

User profile. The resource’s owner. (related name: +)

Type:

Type

user_profile_id

Internal field, use user_profile instead.

version

CharField

Version. The extension version that created or last applied it.

Type:

Type

class smarter.apps.llmtool.models.extension.ExtensionSetting(*args, **kwargs)[source]

Bases: TimestampedModel

The configured value of one of an extension’s settings.

A secret setting refers to a Secret rather than storing a value, so that it is encrypted at rest.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • name (Unknown) – Name. The setting’s name, as declared in the manifest.

  • value (Unknown) – Value. The value, as text. Empty for a secret setting.

Relationship fields:

Parameters:
  • extension (Unknown) – Extension (related name: settings)

  • secret (Unknown) – Secret. The Secret that holds a secret setting’s value. (related name: +)

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

extension

ForeignKey to Extension

Extension (related name: settings)

Type:

Type

extension_id

Internal field, use extension instead.

id

BigAutoField

Primary key: ID

Type:

Type

name

CharField

Name. The setting’s name, as declared in the manifest.

Type:

Type

objects = <django.db.models.Manager object>
secret

ForeignKey to Secret

Secret. The Secret that holds a secret setting’s value. (related name: +)

Type:

Type

secret_id

Internal field, use secret instead.

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

value

TextField

Value. The value, as text. Empty for a secret setting.

Type:

Type

class smarter.apps.llmtool.models.extension.ExtensionSource(*values)[source]

Bases: TextChoices

Where an extension was installed from.

REGISTRY = 'registry'
UPLOAD = 'upload'
class smarter.apps.llmtool.models.extension.ExtensionTrustBadge(*values)[source]

Bases: TextChoices

How far an extension’s publisher is trusted, as shown in the admin console and the registry.

The registry assigns official, verified and community. An uploaded archive, which did not come from the registry, is unverified.

COMMUNITY = 'community'
OFFICIAL = 'official'
UNVERIFIED = 'unverified'
VERIFIED = 'verified'
class smarter.apps.llmtool.models.extension.ExtensionVersion(*args, **kwargs)[source]

Bases: TimestampedModel

One installed version of an extension: its archive, manifest and documentation.

Versions are kept after an update, so that an administrator can roll back to one.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • version (Unknown) – Version. The version, from the manifest, e.g. 1.2.0.

  • archive (Unknown) – Archive. The extension’s zip archive.

  • sha256 (Unknown) – Sha256. The hex sha256 of the archive.

  • manifest (Unknown) – Manifest. The archive’s pyproject.toml, as an ExtensionManifest.

  • docstring (Unknown) – Docstring. The package’s module docstring (reStructuredText).

  • docs_html (Unknown) – Docs html. The docstring, rendered as HTML.

  • source_url (Unknown) – Source url. Where the archive was downloaded.

Relationship fields:

Parameters:
  • extension (Unknown) – Extension (related name: versions)

  • installed_by (Unknown) – Installed by (related name: +)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

archive

BinaryField

Archive. The extension’s zip archive.

Type:

Type

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

docs_html

TextField

Docs html. The docstring, rendered as HTML.

Type:

Type

docstring

TextField

Docstring. The package’s module docstring (reStructuredText).

Type:

Type

extension

ForeignKey to Extension

Extension (related name: versions)

Type:

Type

extension_id

Internal field, use extension instead.

id

BigAutoField

Primary key: ID

Type:

Type

installed_by

ForeignKey to User

Installed by (related name: +)

Type:

Type

installed_by_id

Internal field, use installed_by instead.

manifest

JSONField

Manifest. The archive’s pyproject.toml, as an ExtensionManifest.

Type:

Type

objects = <django.db.models.Manager object>
property parsed_manifest: ExtensionManifest

The version’s manifest, as an ExtensionManifest.

sha256

CharField

Sha256. The hex sha256 of the archive.

Type:

Type

source_url

URLField

Source url. Where the archive was downloaded.

Type:

Type

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

version

CharField

Version. The version, from the manifest, e.g. 1.2.0.

Type:

Type

class smarter.apps.llmclient.models.LLMClientExtensions(*args, **kwargs)[source]

Bases: TimestampedModel

The Extensions whose tools a LLMClient offers the LLM.

Each record links an LLMClient to an Extension, as listed, by slug, in the LLMClient manifest’s spec.extensions. On each prompt, the tools of the linked extensions that are enabled, and available to the LLMClient’s account, are offered to the LLM.

Usage Example

LLMClientExtensions.objects.create(llmclient=my_llmclient, extension=weather)
extensions = LLMClientExtensions.extensions_for(my_llmclient)
Parameters:
  • id (Unknown) – Primary key: ID

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

Relationship fields:

Parameters:
  • llmclient (Unknown) – Llmclient (related name: llmclientextensions)

  • extension (Unknown) – Extension. The Extension. (related name: llmclient_extensions)

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 extensions_for(llmclient)[source]

Return the extensions of a LLMClient, in order of slug, with their installed versions.

The versions’ archives are not fetched: load_version() reads one only the first time a process loads it.

Parameters:

llmclient (LLMClient) – The LLMClient.

Returns:

The LLMClient’s extensions, enabled or not.

Return type:

list[Extension]

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