manage.py deploy_builtin_llmclients

This module is used to deploy a customer API.

class smarter.apps.llmclient.management.commands.deploy_builtin_llmclients.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: SmarterCommand

Deploy built-in llmclients and plugins for a Smarter account.

This management command automates the deployment of default llmclients and plugins for a given account. The account can be specified by its account number. The deployment process reads YAML manifest files from predefined directories, applies each manifest to create plugins and llmclients, and then deploys each llmclient as a Celery task.

The deployed llmclients are accessible at URLs of the form: [llmclient-name].[account-number].api.example.com/llm-client/

Deployment Steps:
  • Retrieve the account and its admin user using the provided account number.

  • Iterate through all plugin manifest files and create each plugin.

  • Iterate through all llmclient manifest files, create each llmclient, and deploy it asynchronously.

  • Output progress and status messages for each operation.

This command is intended for administrators to quickly provision standard llmclients and plugins for new or existing accounts, ensuring consistent setup and deployment across environments.

__init__(stdout=None, stderr=None, no_color=False, force_color=False)[source]
account: Account | None = None
add_arguments(parser)[source]

Add arguments to the command.

apply_manifest(manifest, filespec)[source]

Apply a manifest as the smarter admin, and report, rather than raise, a failure.

The manifest is applied in a transaction, so that a manifest that fails is rolled back entirely: a plugin whose apply fails leaves no PluginMeta behind, which an LLMClient would otherwise attach, and an LLMClient that exists keeps its previous version. Any exception is caught, because brokers raise their own exceptions, rather than CommandError, and one manifest that fails must not prevent the others from being applied. For example, the plugin smarter_project_websearch fails without its Secret tavily_api_key, and the smarter LLMClient, which uses it, then fails too.

Return type:

bool

Returns:

True if the manifest was applied, False otherwise.

create_and_deploy_llmclient(filespec)[source]

Create and deploy an llmclient by name.

Apply the Smarter yaml manifest: - Read and Parse the YAML file - load in the body of the POST request - get a response - check the response - get the llmclient by name

The manifest is applied with spec.config.prompt.deployed set to true, rather than applied as it is and then deployed. A built-in manifest is not deployed, so applying it would undeploy an llmclient that is deployed, whose undeploy task destroys its A record, only for the deploy that follows to create it again. Resolvers that query the domain in between cache the NXDOMAIN for minutes. Applied this way, LLMClient.save() queues a deploy task only for an llmclient that is not deployed yet, and nothing for one that is.

Return type:

bool

create_plugin(filespec)[source]

Create a plugin by name.

Apply the Smarter yaml manifest: - Read and Parse the YAML file - load in the body of the POST request - get a response - check the response

Return type:

bool

delete_llmclient(name)[source]

Delete an llmclient by name.

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

Deploy built-in llmclients for an account.

property url: str
user: User
user_profile: UserProfile | None = None