Deploy Custom API

Celery tasks for deploying llmclient custom API domains.

This module defines Celery tasks for deploying custom API domains for llmclients, including the creation and verification of Route53 A records for customer APIs.

Main Tasks

  • deploy_custom_api(llmclient_id):

    Creates a custom domain A record for an llmclient’s customer API and verifies the hosted zone.

Signals

  • pre_deploy_custom_api: Sent before deployment of the custom API begins.

  • post_deploy_custom_api: Sent after deployment of the custom API is completed.

Configuration

Celery task behavior (retries, backoff, queue) is controlled by smarter_settings.

Logging

Task execution and domain deployment are logged using the smarter logging library, with waffle switches for task and llmclient logging.

Usage

Import this module and call the Celery task as needed to asynchronously deploy an llmclient custom API domain:

deploy_custom_api.delay(llmclient_id)

raises LLMClient.DoesNotExist:

If the LLMClient with the given ID does not exist.

raises Exception:

Any exception during task execution will trigger a retry according to Celery settings.

smarter.apps.llmclient.tasks.deploy_custom_api.deploy_custom_api(llmclient_id)

Create a custom domain A record for an llmclient’s customer API.

This Celery task performs the following steps: 1. Sends a pre-deploy signal for the llmclient API. 2. Logs the deployment request. 3. Retrieves the LLMClient instance by ID. 4. Checks for a valid custom domain; logs and exits if missing or not validated. 5. Creates a Route53 A record for the llmclient’s custom domain. 6. Verifies the hosted zone of the custom domain. 7. Sends a post-deploy signal for the llmclient API.

Parameters:
  • llmclient_id (int) – The primary key of the LLMClient instance for which the custom domain A record is being created.

  • Signals

  • -------

  • pre_deploy_custom_api (django.dispatch.Signal) – Sent before the deployment of the custom API begins.

  • post_deploy_custom_api (django.dispatch.Signal) – Sent after the deployment of the custom API is completed.

Raises:
  • LLMClient.DoesNotExist – If the LLMClient with the given ID does not exist.

  • Exception – Any exception raised during the deployment process will trigger a retry according to Celery settings.