# Generated by Codex on 2025-12-23

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


class Migration(migrations.Migration):

    dependencies = [
        ("api", "0239_toolconfig_search_engine_batch_query_limit"),
    ]

    operations = [
        migrations.CreateModel(
            name="FileHandlerModelEndpoint",
            fields=[
                ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ("key", models.SlugField(help_text="Endpoint key, e.g., 'openai_gpt4o_file_handler'", max_length=96, unique=True)),
                ("enabled", models.BooleanField(default=True)),
                ("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_vision", models.BooleanField(default=False, help_text="Indicates the model can process image or multimodal inputs.")),
                ("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="file_handler_endpoints",
                        to="api.llmprovider",
                    ),
                ),
            ],
            options={
                "ordering": ["provider__display_name", "litellm_model"],
            },
        ),
        migrations.CreateModel(
            name="FileHandlerLLMTier",
            fields=[
                ("id", models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ("order", models.PositiveIntegerField(help_text="1-based order across all file handler tiers.", unique=True)),
                ("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": ["order"],
            },
        ),
        migrations.CreateModel(
            name="FileHandlerTierEndpoint",
            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.filehandlermodelendpoint",
                    ),
                ),
                (
                    "tier",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="tier_endpoints",
                        to="api.filehandlerllmtier",
                    ),
                ),
            ],
            options={
                "ordering": ["tier__order", "endpoint__key"],
                "unique_together": {("tier", "endpoint")},
            },
        ),
        migrations.AddIndex(
            model_name="filehandlermodelendpoint",
            index=models.Index(fields=["key"], name="api_filehan_key_9ff4ca_idx"),
        ),
        migrations.AddIndex(
            model_name="filehandlermodelendpoint",
            index=models.Index(fields=["enabled"], name="api_filehan_enabled_ef6579_idx"),
        ),
        migrations.AddIndex(
            model_name="filehandlermodelendpoint",
            index=models.Index(fields=["provider"], name="api_filehan_provide_4600a9_idx"),
        ),
    ]
