Management Commands

Initialize 3rd party providers.

class smarter.apps.provider.management.commands.initialize_providers.Command(*args, **kwargs)[source]

Bases: SmarterCommand

Django manage.py initialize_providers.py command.

Used to create/update the principal Providers that are preloaded on all platforms. Creates/updates the API key Secret, the Provider, and the ProviderModels for each provider. The following providers are initialized:

  • Anthropic

  • Cohere

  • Fireworks

  • Google Service Account

  • Google AI

  • Google Maps

  • Meta AI

  • Mistral

  • OpenAI

  • TogetherIA

This is called indirectly by initialize_platform and runs during automated deployment.

echo_banner(name)[source]

Echo a banner to the console.

handle(*args, **options)[source]

Initialize all built-in providers.

initialize_anthropic()[source]

Initialize Anthropic provider and its models.

Initialize the Brave Search api key Secret.

ImageSearchPlugins, such as safe_image_search, and the Brave WebsearchPlugin samples, such as research_assistant, read their api key from this Secret. As with Tavily, a missing key is not stored. An ImageSearchPlugin without it returns no images, and logs how to create it.

initialize_cohere()[source]

Initialize Cohere provider and its models.

initialize_fireworks()[source]

Initialize Fireworks provider and its models.

initialize_generic_provider(api_key_env_var, name, provider_configuration, logo_filename, provider_api_url)[source]

Initialize a provider and its models.

  • create/update api key secret

  • create/update provider

  • create/update provider models

initialize_google_maps()[source]

Initialize Google Maps provider.

initialize_google_service_account()[source]

Initialize Google service account credentials.

A Google service account is a special identity that allows an application, rather than a person, to securely authenticate with Google APIs and services. It uses cryptographic credentials to prove its identity and obtain temporary access tokens without requiring a user to log in. The service account can only perform the actions that have been explicitly granted to it through Google Cloud IAM permissions.

Example service account JSON structure:

service_account_json = {
"type": "service_account",
"project_id": "smarter-sh",
"private_key_id": "65fc3e5bd38b1234567890676f6d6abcdefghijk",
"private_key": "PRIVATE-KEY-DATA",
"client_email": "smarter-gemini-initializer@smarter-sh.iam.gserviceaccount.com",
"client_id": "104887368144732193269",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/smarter-gemini-initializer%40smarter-sh.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}

service_account_b64 = base64.b64encode(json.dumps(service_account_json).encode("utf-8")).decode("ascii")
print(service_account_b64)
initialize_googleai()[source]

Initialize Google AI provider and its models.

initialize_metaai()[source]

Initialize Meta AI provider and its models.

initialize_mistral()[source]

Initialize Mistral provider and its models.

initialize_openai()[source]

Initialize OpenAI provider and its models.

initialize_tavily()[source]

Initialize the Tavily web search api key Secret.

The built-in WebsearchPlugin smarter_project_websearch, which the smarter LLMClient uses, reads its api key from this Secret. Unlike the provider api keys, a missing key is not stored: the Secret is skipped, so that applying the plugin reports the missing Secret.

initialize_togetheria()[source]

Initialize TogetherAI provider and its models.

log_missing_api_keys()[source]

Log one banner that lists the API keys that are not set, and how to set them.

missing_api_key(env_var, used_for, url)[source]

Record an API key that is not set, for the summary that handle() logs.

Parameters:
  • env_var (str) – The environment variable, without the optional SMARTER_ prefix.

  • used_for (str) – What the key is used for.

  • url (str) – Where to get the key.

missing_api_keys: list[tuple[str, str, str]]

their environment variable, what they are used for, and where to get one.

Type:

The API keys that are not set

user_profile: UserProfile