# Generated by Django 6.0 on 2026-04-07 15:40

import django.db.models.deletion
import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("api", "0340_merge_20260408_1455"),
    ]

    operations = [
        migrations.AlterField(
            model_name="persistentagentcompletion",
            name="completion_type",
            field=models.CharField(
                choices=[
                    ("orchestrator", "Orchestrator"),
                    ("compaction", "Comms Compaction"),
                    ("step_compaction", "Step Compaction"),
                    ("tag", "Tag Generation"),
                    ("short_description", "Short Description"),
                    ("mini_description", "Mini Description"),
                    ("avatar_visual_description", "Avatar Visual Description"),
                    ("avatar_image_generation", "Avatar Image Generation"),
                    ("image_generation", "Image Generation"),
                    ("video_generation", "Video Generation"),
                    ("tool_search", "Tool Search"),
                    ("template_clone", "Template Clone"),
                    ("other", "Other"),
                ],
                default="orchestrator",
                help_text="Origin of the completion (orchestrator loop, compaction, tag generation, etc.).",
                max_length=64,
            ),
        ),
        migrations.CreateModel(
            name="VideoGenerationLLMTier",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "use_case",
                    models.CharField(
                        choices=[("create_video", "Create Video")],
                        default="create_video",
                        help_text="Which video-generation workflow this tier ordering applies to.",
                        max_length=32,
                    ),
                ),
                (
                    "order",
                    models.PositiveIntegerField(
                        help_text="1-based order within the selected video generation workflow."
                    ),
                ),
                ("description", models.CharField(blank=True, max_length=256)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "ordering": ["use_case", "order"],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("use_case", "order"),
                        name="unique_video_generation_tier_order_per_use_case",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="VideoGenerationModelEndpoint",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "key",
                    models.SlugField(
                        help_text="Endpoint key, e.g., 'openai_sora2'",
                        max_length=96,
                        unique=True,
                    ),
                ),
                ("enabled", models.BooleanField(default=True)),
                (
                    "low_latency",
                    models.BooleanField(
                        default=False,
                        help_text="Marks this endpoint as low latency/high performance.",
                    ),
                ),
                (
                    "litellm_model",
                    models.CharField(
                        help_text="Model identifier passed to LiteLLM.", max_length=256
                    ),
                ),
                (
                    "api_base",
                    models.CharField(
                        blank=True,
                        help_text="Optional OpenAI-compatible base URL for proxy endpoints.",
                        max_length=256,
                    ),
                ),
                (
                    "supports_image_to_video",
                    models.BooleanField(
                        default=False,
                        help_text="Indicates this endpoint can accept a source image for image-to-video generation.",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "provider",
                    models.ForeignKey(
                        blank=True,
                        help_text="Optional link to the provider supplying credentials for this endpoint.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="video_generation_endpoints",
                        to="api.llmprovider",
                    ),
                ),
            ],
            options={
                "ordering": ["provider__display_name", "litellm_model"],
            },
        ),
        migrations.CreateModel(
            name="VideoGenerationTierEndpoint",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "weight",
                    models.FloatField(
                        help_text="Relative weight within the tier; must be > 0."
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "endpoint",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="in_tiers",
                        to="api.videogenerationmodelendpoint",
                    ),
                ),
                (
                    "tier",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="tier_endpoints",
                        to="api.videogenerationllmtier",
                    ),
                ),
            ],
            options={
                "ordering": ["tier__order", "endpoint__key"],
            },
        ),
        migrations.AddIndex(
            model_name="videogenerationmodelendpoint",
            index=models.Index(fields=["key"], name="api_videoge_key_fd422a_idx"),
        ),
        migrations.AddIndex(
            model_name="videogenerationmodelendpoint",
            index=models.Index(
                fields=["enabled"], name="api_videoge_enabled_cd5e0a_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="videogenerationmodelendpoint",
            index=models.Index(
                fields=["provider"], name="api_videoge_provide_f0ccaf_idx"
            ),
        ),
        migrations.AlterUniqueTogether(
            name="videogenerationtierendpoint",
            unique_together={("tier", "endpoint")},
        ),
    ]
