Management Commands
Initialize 3rd party providers.
- class smarter.apps.provider.management.commands.initialize_providers.Command(*args, **kwargs)[source]
Bases:
SmarterCommandDjango 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.
- initialize_brave_search()[source]
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_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_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_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.
- 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.
- 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