Deploy Custom API

Celery tasks for deploying llm_client custom API domains.

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

Main Tasks

  • deploy_custom_api(llm_client_id):

    Creates a custom domain A record for an llm_client’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 llm_client logging.

Usage

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

deploy_custom_api.delay(llm_client_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.llm_client.tasks.deploy_custom_api.deploy_custom_api(llm_client_id)

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

This Celery task performs the following steps: 1. Sends a pre-deploy signal for the llm_client 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 llm_client’s custom domain. 6. Verifies the hosted zone of the custom domain. 7. Sends a post-deploy signal for the llm_client API.

Parameters:
  • llm_client_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.