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:
TimestampedModelAn installed Smarter Extension.
There is one row per extension, whatever its version.
installed_versionis the version that runs, andlatest_versionis 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 ifall_accounts, otherwise theaccountslisted.- 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
-
Accounts. The accounts that may use the extension, when it is not available to all accounts. (related name:
extensions)- Type:
Type
- all_accounts
-
All accounts. Whether every account may use the extension.
- Type:
Type
- 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
- enabled
-
Enabled. Whether the extension’s tools are offered to LLMs.
- Type:
Type
- error
-
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. Seeget_FOO_display()for more information.
- get_trust_badge_display(*, field=<django.db.models.CharField: trust_badge>)
Shows the label of the
trust_badge. Seeget_FOO_display()for more information.
- id
-
Primary key: ID
- Type:
Type
- installed_version
ForeignKeytoExtensionVersionInstalled version. The version that runs. (related name:
+)- Type:
Type
- installed_version_id
Internal field, use
installed_versioninstead.
- latest_checked_at
-
Latest checked at. When the registry was last checked for updates.
- Type:
Type
- llmclient_extensions
Reverse
ForeignKeyfromLLMClientExtensionsAll llmclient extensions of this Extension (related name of
extension)- Type:
Type
- objects = <django.db.models.Manager object>
- resources
Reverse
ForeignKeyfromExtensionResourceAll resources of this Extension (related name of
extension)- Type:
Type
- settings
Reverse
ForeignKeyfromExtensionSettingAll settings of this Extension (related name of
extension)- Type:
Type
- property update_available: bool
Whether the registry offers a newer version than the installed one.
- 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
- versions
Reverse
ForeignKeyfromExtensionVersionAll versions of this Extension (related name of
extension)- Type:
Type
- class smarter.apps.llmtool.models.extension.ExtensionResource(*args, **kwargs)[source]
Bases:
TimestampedModelA 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 withapply_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
-
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
- id
-
Primary key: ID
- Type:
Type
- managed
-
Managed. Whether it came from the package’s manifests/ directory, rather than a lifecycle hook.
- Type:
Type
- objects = <django.db.models.Manager object>
- 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
- user_profile
-
User profile. The resource’s owner. (related name:
+)- Type:
Type
- user_profile_id
Internal field, use
user_profileinstead.
- class smarter.apps.llmtool.models.extension.ExtensionSetting(*args, **kwargs)[source]
Bases:
TimestampedModelThe configured value of one of an extension’s settings.
A
secretsetting refers to aSecretrather 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
-
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
- id
-
Primary key: ID
- Type:
Type
- objects = <django.db.models.Manager object>
- secret
ForeignKeytoSecretSecret. The Secret that holds a secret setting’s value. (related name:
+)- 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
- class smarter.apps.llmtool.models.extension.ExtensionSource(*values)[source]
Bases:
TextChoicesWhere an extension was installed from.
- REGISTRY = 'registry'
- UPLOAD = 'upload'
- class smarter.apps.llmtool.models.extension.ExtensionTrustBadge(*values)[source]
Bases:
TextChoicesHow far an extension’s publisher is trusted, as shown in the admin console and the registry.
The registry assigns
official,verifiedandcommunity. An uploaded archive, which did not come from the registry, isunverified.- COMMUNITY = 'community'
- OFFICIAL = 'official'
- UNVERIFIED = 'unverified'
- VERIFIED = 'verified'
- class smarter.apps.llmtool.models.extension.ExtensionVersion(*args, **kwargs)[source]
Bases:
TimestampedModelOne 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
-
Archive. The extension’s zip archive.
- Type:
Type
- 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
- id
-
Primary key: ID
- Type:
Type
- installed_by
ForeignKeytoUserInstalled by (related name:
+)- Type:
Type
- installed_by_id
Internal field, use
installed_byinstead.
- objects = <django.db.models.Manager object>
- property parsed_manifest: ExtensionManifest
The version’s manifest, as an
ExtensionManifest.
- 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
- class smarter.apps.llmclient.models.LLMClientExtensions(*args, **kwargs)[source]
Bases:
TimestampedModelThe Extensions whose tools a LLMClient offers the LLM.
Each record links an LLMClient to an
Extension, as listed, by slug, in the LLMClient manifest’sspec.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
-
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.
- 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