feat: add openai-compatible model gateway
This commit is contained in:
143
backend/apps/modelhub/migrations/0001_initial.py
Normal file
143
backend/apps/modelhub/migrations/0001_initial.py
Normal file
@@ -0,0 +1,143 @@
|
||||
# Generated by Django 5.2.15 on 2026-07-14 05:44
|
||||
|
||||
import uuid
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="ModelProvider",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||
),
|
||||
),
|
||||
("name", models.CharField(max_length=120, unique=True)),
|
||||
("base_url", models.URLField(max_length=500)),
|
||||
("api_key_encrypted", models.TextField(blank=True)),
|
||||
("enabled", models.BooleanField(default=True)),
|
||||
("default_timeout_seconds", models.PositiveIntegerField(default=60)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"created_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="created_model_providers",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ["name"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="ModelDeployment",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||
),
|
||||
),
|
||||
("display_name", models.CharField(max_length=120)),
|
||||
("model_name", models.CharField(max_length=160)),
|
||||
("capability", models.CharField(default="text_chat", max_length=40)),
|
||||
("default_temperature", models.FloatField(default=0.2)),
|
||||
("max_output_tokens", models.PositiveIntegerField(default=2048)),
|
||||
("enabled", models.BooleanField(default=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("updated_at", models.DateTimeField(auto_now=True)),
|
||||
(
|
||||
"provider",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name="deployments",
|
||||
to="modelhub.modelprovider",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ["provider__name", "display_name"],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="ModelInvocation",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||
),
|
||||
),
|
||||
("public_id", models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
("invocation_type", models.CharField(default="model_test", max_length=40)),
|
||||
("status", models.CharField(default="queued", max_length=24)),
|
||||
("model_snapshot", models.JSONField(blank=True, default=dict)),
|
||||
("input_snapshot", models.JSONField(blank=True, default=dict)),
|
||||
("output_text", models.TextField(blank=True)),
|
||||
("input_tokens", models.PositiveIntegerField(blank=True, null=True)),
|
||||
("output_tokens", models.PositiveIntegerField(blank=True, null=True)),
|
||||
("duration_ms", models.PositiveIntegerField(default=0)),
|
||||
("retry_count", models.PositiveIntegerField(default=0)),
|
||||
("error_code", models.CharField(blank=True, max_length=80)),
|
||||
("error_message", models.TextField(blank=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
("started_at", models.DateTimeField(blank=True, null=True)),
|
||||
("finished_at", models.DateTimeField(blank=True, null=True)),
|
||||
(
|
||||
"created_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="model_invocations",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"deployment",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="invocations",
|
||||
to="modelhub.modeldeployment",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ["-created_at"],
|
||||
"indexes": [
|
||||
models.Index(
|
||||
fields=["status", "created_at"], name="modelhub_mo_status_bc8fa5_idx"
|
||||
),
|
||||
models.Index(
|
||||
fields=["invocation_type", "created_at"],
|
||||
name="modelhub_mo_invocat_53d7b6_idx",
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="modeldeployment",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("provider", "model_name"), name="unique_provider_model_name"
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user