Deploy Default API

Celery tasks for deploying llm_client default API domains.

This module defines Celery tasks for deploying default API domains for llm_clients, including the creation and verification of Route53 A records, Kubernetes ingress manifests, and certificate issuance.

Main Tasks

  • deploy_default_api(llm_client_id, with_domain_verification=True):

    Creates a default domain A record for an llm_client, manages ingress and certificate resources, and optionally verifies the domain.

Signals

  • pre_deploy_default_api: Sent before deployment of the default API begins.

  • post_deploy_default_api: Sent after deployment of the default API is completed.

  • llm_client_deployed: Sent when the llm_client is successfully deployed.

  • llm_client_deploy_failed: Sent when deployment fails.

  • llm_client_dns_verification_initiated: Sent when DNS verification is initiated.

  • llm_client_dns_verified: Sent when DNS verification succeeds.

  • llm_client_dns_failed: Sent when DNS verification fails.

  • llm_client_dns_verification_status_changed: Sent when DNS verification status changes.

Configuration

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

Logging

Task execution, resource creation, and deployment status 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 default API domain:

deploy_default_api.delay(llm_client_id, with_domain_verification=True)

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_default_api.deploy_default_api(llm_client_id, with_domain_verification=True)

Create a customer API default domain A record for an llm_client and manage deployment resources.

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. Creates a Route53 A record for the llm_client’s default domain. 5. Optionally creates and applies a Kubernetes ingress manifest for the domain. 6. Verifies ingress resources and certificate issuance. 7. Handles domain verification if requested. 8. Sends post-deploy and deployment status signals. 9. Notifies the account owner by email upon successful deployment.

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

  • with_domain_verification (bool, optional) – Whether to perform domain verification after deployment. Default is True.

  • Signals

  • -------

  • pre_deploy_default_api (django.dispatch.Signal) – Sent before deployment of the default API begins.

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

  • llm_client_deployed (django.dispatch.Signal) – Sent when the llm_client is successfully deployed.

  • llm_client_deploy_failed (django.dispatch.Signal) – Sent when deployment fails.

  • llm_client_dns_verification_initiated (django.dispatch.Signal) – Sent when DNS verification is initiated.

  • llm_client_dns_verified (django.dispatch.Signal) – Sent when DNS verification succeeds.

  • llm_client_dns_failed (django.dispatch.Signal) – Sent when DNS verification fails.

  • llm_client_dns_verification_status_changed (django.dispatch.Signal) – Sent when DNS verification status changes.

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.