Django ORM

All models for the Provider app.

class smarter.apps.provider.models.Provider(*args, **kwargs)[source]

Bases: MetaDataWithOwnershipModel

Provider model.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • name (Unknown) – Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

  • description (Unknown) – Description. A brief description of this resource. Be verbose, but not too verbose.

  • version (Unknown) – Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

  • annotations (Unknown) – Annotations. Key-value pairs for annotating this resource.

  • status (Unknown) – Status

  • is_default (Unknown) – Is default

  • is_active (Unknown) – Is active

  • is_verified (Unknown) – Is verified

  • is_featured (Unknown) – Is featured

  • is_deprecated (Unknown) – Is deprecated

  • is_flagged (Unknown) – Is flagged

  • is_suspended (Unknown) – Is suspended

  • base_url (Unknown) – Base url. The base URL for the provider’s API.

  • default_model (Unknown) – Default model. The default model to use for the provider.

  • connectivity_test_path (Unknown) – Connectivity test path. The URL to test connectivity with the provider’s API.

  • logo (Unknown) – Logo. The logo of the provider.

  • website_url (Unknown) – Website url. The website_url URL of the provider.

  • ownership_requested (Unknown) – Ownership requested. The email address of an alternative contact who has requested to take ownership of the provider.

  • contact_email (Unknown) – Contact email. The contact email of the provider.

  • contact_email_verified (Unknown) – Contact email verified. The date and time when the contact email was verified.

  • support_email (Unknown) – Support email. The support email of the provider.

  • support_email_verified (Unknown) – Support email verified. The date and time when the support email was verified.

  • docs_url (Unknown) – Docs url. The documentation URL of the provider.

  • terms_of_service_url (Unknown) – Terms of service url. The terms of service URL of the provider.

  • privacy_policy_url (Unknown) – Privacy policy url. The privacy policy URL of the provider.

  • tos_accepted_at (Unknown) – Tos accepted at. The date and time when the terms of service were accepted.

Relationship fields:

Parameters:
  • user_profile (Unknown) – User profile (related name: provider)

  • api_key (Unknown) – Api key. The API key for the provider. (related name: provider_api_key)

  • tos_accepted_by (Unknown) – Tos accepted by. The user who accepted the terms of service. (related name: tos_accepted_by)

  • tags (Unknown) – Tags. Tags for categorizing and organizing this resource. (related name: provider)

  • tagged_items (Unknown) – Tagged items (related name: +)

Reverse relationships:

Parameters:
  • providermodel (Unknown) – All Provider Models of this Provider (related name of provider)

  • providerverification (Unknown) – All Provider Verifications of this Provider (related name of provider)

  • vector_databases (Unknown) – All vector databases of this Provider (related name of provider)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

activate()[source]

Activate the provider.

annotations

JSONField

Annotations. Key-value pairs for annotating this resource.

Type:

Type

api_key

ForeignKey to Secret

Api key. The API key for the provider. (related name: provider_api_key)

Type:

Type

api_key_id

Internal field, use api_key instead.

property authorization_header: dict

Return the authorization header for the provider.

base_url

URLField

Base url. The base URL for the provider’s API.

Type:

Type

property can_activate: bool

Check if the provider can be activated.

connectivity_test_path

CharField

Connectivity test path. The URL to test connectivity with the provider’s API.

Type:

Type

contact_email

EmailField

Contact email. The contact email of the provider.

Type:

Type

contact_email_verified

DateTimeField

Contact email verified. The date and time when the contact email was verified.

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

deactivate()[source]

Deactivate the provider.

default_model

CharField

Default model. The default model to use for the provider.

Type:

Type

deprecate()[source]

Deprecate the provider.

description

TextField

Description. A brief description of this resource. Be verbose, but not too verbose.

Type:

Type

docs_url

URLField

Docs url. The documentation URL of the provider.

Type:

Type

flag()[source]

Flag the provider.

classmethod get_cached_provider_by_account_id_and_name(invalidate=False, account_id=None, name=None)[source]

Get a cached provider by account ID and name.

Return type:

Optional[Provider]

classmethod get_cached_provider_by_user_and_name(invalidate=False, user=None, name='')[source]

Return a single instance of Provider by name for the given user.

This method caches the results to improve performance.

Parameters:
  • user (Optional[User]) – The user whose provider should be retrieved.

  • name (Optional[str]) – The name of the provider to retrieve.

Returns:

A Provider instance if found, otherwise None.

Return type:

Optional[Provider]

classmethod get_cached_providers_for_user(invalidate=False, user=None)[source]

Get cached providers for a user.

Return type:

Sequence[Provider]

get_status_display(*, field=<django.db.models.CharField: status>)

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

id

BigAutoField

Primary key: ID

Type:

Type

is_active

BooleanField

Is active

Type:

Type

is_default

BooleanField

Is default

Type:

Type

is_deprecated

BooleanField

Is deprecated

Type:

Type

BooleanField

Is featured

Type:

Type

is_flagged

BooleanField

Is flagged

Type:

Type

property is_official_provider: bool

Check if the provider is an official provider.

is_suspended

BooleanField

Is suspended

Type:

Type

is_verified

BooleanField

Is verified

Type:

Type

ImageField

Logo. The logo of the provider.

Type:

Type

property manifest_url: str | None

Returns the URL to the plugin’s manifest.

This property constructs the URL to the plugin’s manifest based on its kind and RFC 1034-compliant name. The URL follows the pattern: /plugins/{kind}/{name}/manifest/, where {kind} is the RFC 1034-compliant kind of the plugin, and {name} is the RFC 1034-compliant name of the plugin.

Example:

self.rfc1034_compliant_kind  # 'static'
self.rfc1034_compliant_name  # 'example-plugin
self.manifest_url  # '/plugins/static/example-plugin/manifest/'
name

CharField

Name. Name in camelCase, e.g., ‘apiKey’, no special characters.

Type:

Type

objects: MetaDataWithOwnershipModelManager = <smarter.apps.account.models.metadata_with_ownership.MetaDataWithOwnershipModelManager object>
ownership_requested

EmailField

Ownership requested. The email address of an alternative contact who has requested to take ownership of the provider.

Type:

Type

privacy_policy_url

URLField

Privacy policy url. The privacy policy URL of the provider.

Type:

Type

production_api_key(mask=True)[source]

Return the production API key for the provider.

Return type:

str

providermodel_set

Reverse ForeignKey from ProviderModel

All Provider Models of this Provider (related name of provider)

Type:

Type

providerverification_set

Reverse ForeignKey from ProviderVerification

All Provider Verifications of this Provider (related name of provider)

Type:

Type

reset()[source]

Reset the provider to its initial state.

property rfc1034_compliant_name: str | None

Returns a URL-friendly name for the llm_client.

This property returns an RFC 1034-compliant name for the llm_client, suitable for use in URLs and DNS labels.

Example:

self.name = 'Example LLMClient 1'
self.rfc1034_compliant_name  # 'example-llm_client-1'
Returns:

The RFC 1034-compliant name, or None if self.name is not set.

Return type:

Optional[str]

status

CharField

Status

Choices:

  • unverified

  • verifying

  • failed

  • verified

  • suspended

  • deprecated

Type:

Type

support_email

EmailField

Support email. The support email of the provider.

Type:

Type

support_email_verified

DateTimeField

Support email verified. The date and time when the support email was verified.

Type:

Type

suspend()[source]

Suspend the provider.

tagged_items

Reverse GenericRelation from Provider

All + of this tagged item (related name of tagged_items)

Type:

Type

tags = <taggit.managers._TaggableManager object>
terms_of_service_url

URLField

Terms of service url. The terms of service URL of the provider.

Type:

Type

test_connectivity()[source]

Test connectivity to the provider’s API.

This method should be overridden by subclasses to implement specific connectivity tests.

Return type:

bool

property tos_accepted: bool

Check if the terms of service have been accepted.

tos_accepted_at

DateTimeField

Tos accepted at. The date and time when the terms of service were accepted.

Type:

Type

tos_accepted_by

ForeignKey to User

Tos accepted by. The user who accepted the terms of service. (related name: tos_accepted_by)

Type:

Type

tos_accepted_by_id

Internal field, use tos_accepted_by instead.

undeprecate()[source]

Undeprecate the provider.

unflag()[source]

Unflag the provider.

unsuspend()[source]

Unsuspend the provider.

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 (related name: provider)

Type:

Type

user_profile_id

Internal field, use user_profile instead.

validate()[source]

Validate the provider before saving.

Return type:

None

vector_databases

Reverse ForeignKey from EmbeddingsInterface

All vector databases of this Provider (related name of provider)

Type:

Type

verify()[source]

Request a batch of acceptance tests.

Set the status but don’t change the is_verified flag. This is used to indicate that the provider is being verified but has not yet been activated.

version

CharField

Version. Semantic version in the format MAJOR.MINOR.PATCH, e.g., ‘1.0.0’.

Type:

Type

website_url

URLField

Website url. The website_url URL of the provider.

Type:

Type

class smarter.apps.provider.models.ProviderModel(*args, **kwargs)[source]

Bases: TimestampedModel

Provider completion models for a provider.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • name (Unknown) – Name

  • description (Unknown) – Description

  • is_default (Unknown) – Is default

  • is_active (Unknown) – Is active

  • is_deprecated (Unknown) – Is deprecated

  • is_flagged (Unknown) – Is flagged

  • is_suspended (Unknown) – Is suspended

  • max_completion_tokens (Unknown) – Max completion tokens

  • temperature (Unknown) – Temperature

  • top_p (Unknown) – Top p

  • supports_text_input (Unknown) – Supports text input

  • supports_text_generation (Unknown) – Supports text generation

  • supports_translation (Unknown) – Supports translation

  • supports_summarization (Unknown) – Supports summarization

  • supports_streaming (Unknown) – Supports streaming

  • supports_tools (Unknown) – Supports tools

  • supports_image_input (Unknown) – Supports image input

  • supports_audio_input (Unknown) – Supports audio input

  • supports_embedding (Unknown) – Supports embedding

  • supports_fine_tuning (Unknown) – Supports fine tuning

  • supports_search (Unknown) – Supports search

  • supports_code_interpreter (Unknown) – Supports code interpreter

  • supports_image_generation (Unknown) – Supports image generation

  • supports_audio_generation (Unknown) – Supports audio generation

Relationship fields:

Parameters:

provider (Unknown) – Provider (related name: providermodel)

Reverse relationships:

Parameters:
  • providermodelverification (Unknown) – All Provider Model Verifications of this Provider Model (related name of provider_model)

  • vector_databases (Unknown) – All vector databases of this Provider Model (related name of provider_model)

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

description

TextField

Description

Type:

Type

id

BigAutoField

Primary key: ID

Type:

Type

is_active

BooleanField

Is active

Type:

Type

is_default

BooleanField

Is default

Type:

Type

is_deprecated

BooleanField

Is deprecated

Type:

Type

is_flagged

BooleanField

Is flagged

Type:

Type

is_suspended

BooleanField

Is suspended

Type:

Type

max_completion_tokens

PositiveIntegerField

Max completion tokens

Type:

Type

name

CharField

Name

Type:

Type

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

ForeignKey to Provider

Provider (related name: providermodel)

Type:

Type

provider_id

Internal field, use provider instead.

providermodelverification_set

Reverse ForeignKey from ProviderModelVerification

All Provider Model Verifications of this Provider Model (related name of provider_model)

Type:

Type

supports_audio_generation

BooleanField

Supports audio generation

Type:

Type

supports_audio_input

BooleanField

Supports audio input

Type:

Type

supports_code_interpreter

BooleanField

Supports code interpreter

Type:

Type

supports_embedding

BooleanField

Supports embedding

Type:

Type

supports_fine_tuning

BooleanField

Supports fine tuning

Type:

Type

supports_image_generation

BooleanField

Supports image generation

Type:

Type

supports_image_input

BooleanField

Supports image input

Type:

Type

BooleanField

Supports search

Type:

Type

supports_streaming

BooleanField

Supports streaming

Type:

Type

supports_summarization

BooleanField

Supports summarization

Type:

Type

supports_text_generation

BooleanField

Supports text generation

Type:

Type

supports_text_input

BooleanField

Supports text input

Type:

Type

supports_tools

BooleanField

Supports tools

Type:

Type

supports_translation

BooleanField

Supports translation

Type:

Type

temperature

FloatField

Temperature

Type:

Type

top_p

FloatField

Top p

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

vector_databases

Reverse ForeignKey from EmbeddingsInterface

All vector databases of this Provider Model (related name of provider_model)

Type:

Type

class smarter.apps.provider.models.ProviderModelTypedDict[source]

Bases: TypedDict

TypedDict for provider model information.

api_key: str
base_url: str
max_completion_tokens: int
model: str
provider_id: int
provider_name: str
supports_audio_generation: bool
supports_audio_input: bool
supports_code_interpreter: bool
supports_embedding: bool
supports_fine_tuning: bool
supports_image_generation: bool
supports_image_input: bool
supports_streaming: bool
supports_summarization: bool
supports_text_generation: bool
supports_text_input: bool
supports_tools: bool
supports_translation: bool
temperature: float
top_p: float
class smarter.apps.provider.models.ProviderModelVerification(*args, **kwargs)[source]

Bases: TimestampedModel

Provider completion model verifications for a provider.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • verification_type (Unknown) – Verification type

  • is_successful (Unknown) – Is successful

  • error_message (Unknown) – Error message

Relationship fields:

Parameters:

provider_model (Unknown) – Provider model (related name: providermodelverification)

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

error_message

TextField

Error message

Type:

Type

get_verification_type_display(*, field=<django.db.models.CharField: verification_type>)

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

id

BigAutoField

Primary key: ID

Type:

Type

is_successful

BooleanField

Is successful

Type:

Type

property is_valid: bool

Check if the verification is valid.

property next_verification: datetime

Get the next verification time.

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

ForeignKey to ProviderModel

Provider model (related name: providermodelverification)

Type:

Type

provider_model_id

Internal field, use provider_model 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

verification_type

CharField

Verification type

Choices:

  • streaming

  • tools

  • text_input

  • image_input

  • audio_input

  • fine_tuning

  • search

  • code_interpreter

  • text_to_image

  • text_to_audio

  • and 3 more

Type:

Type

class smarter.apps.provider.models.ProviderModelVerificationTypes(*values)[source]

Bases: TextChoices

AUDIO_INPUT = 'audio_input'
CODE_INTERPRETER = 'code_interpreter'
FINE_TUNING = 'fine_tuning'
IMAGE_INPUT = 'image_input'
SEARCH = 'search'
STREAMING = 'streaming'
SUMMARIZATION = 'summarization'
TEXT_INPUT = 'text_input'
TEXT_TO_AUDIO = 'text_to_audio'
TEXT_TO_IMAGE = 'text_to_image'
TEXT_TO_TEXT = 'text_to_text'
TOOLS = 'tools'
TRANSLATION = 'translation'
class smarter.apps.provider.models.ProviderStatus(*values)[source]

Bases: TextChoices

DEPRECATED = 'deprecated'
FAILED = 'failed'
SUSPENDED = 'suspended'
UNVERIFIED = 'unverified'
VERIFIED = 'verified'
VERIFYING = 'verifying'
class smarter.apps.provider.models.ProviderVerification(*args, **kwargs)[source]

Bases: TimestampedModel

Provider completion model verifications for a provider.

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

  • created_at (Unknown) – Created at

  • updated_at (Unknown) – Updated at

  • verification_type (Unknown) – Verification type

  • is_successful (Unknown) – Is successful

  • error_message (Unknown) – Error message

Relationship fields:

Parameters:

provider (Unknown) – Provider (related name: providerverification)

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

error_message

TextField

Error message

Type:

Type

get_verification_type_display(*, field=<django.db.models.CharField: verification_type>)

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

id

BigAutoField

Primary key: ID

Type:

Type

is_successful

BooleanField

Is successful

Type:

Type

property is_valid: bool

Check if the verification is valid.

property next_verification: datetime

Get the next verification time.

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

ForeignKey to Provider

Provider (related name: providerverification)

Type:

Type

provider_id

Internal field, use provider 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

verification_type

CharField

Verification type

Choices:

  • api_connectivity

  • logo

  • contact_email

  • support_email

  • website_url

  • tos_url

  • privacy_policy_url

  • tos_acceptance

  • production_api_key

Type:

Type

class smarter.apps.provider.models.ProviderVerificationTypes(*values)[source]

Bases: TextChoices

API_CONNECTIVITY = 'api_connectivity'
CONTACT_EMAIL = 'contact_email'
PRIVACY_POLICY_URL = 'privacy_policy_url'
PRODUCTION_API_KEY = 'production_api_key'
SUPPORT_EMAIL = 'support_email'
TOS_ACCEPTANCE = 'tos_acceptance'
TOS_URL = 'tos_url'
WEBSITE_URL = 'website_url'
smarter.apps.provider.models.get_model_for_provider(provider_name, model_name=None)[source]

Get the model for a provider by name and account number.

This is the primary way to retrieve a model for a provider. Raises a Smarter error if anything goes wrong.

Return type:

ProviderModelTypedDict

smarter.apps.provider.models.get_models_for_provider(provider_name)[source]

Get all models for a provider by name and account number.

This is the primary way to retrieve all models for a provider. Raises a Smarter error if anything goes wrong.

Return type:

list[ProviderModelTypedDict]

smarter.apps.provider.models.get_provider(provider_name)[source]

Get the provider by name and account number.

This is the primary way to retrieve a provider. Raises a Smarter error if anything goes wrong.

Return type:

Provider

smarter.apps.provider.models.get_providers()[source]

Get all active providers.

This is the primary way to retrieve all providers. Raises a Smarter error if anything goes wrong.

Return type:

list[Provider]

smarter.apps.provider.models.should_log(level)[source]

Check if logging should be done based on the waffle switch.