Skip to content

Commit 7c096c8

Browse files
committed
implement dynamically selecting video gen models via db
1 parent 1f917c8 commit 7c096c8

18 files changed

+1246
-767
lines changed

ai_models/__init__.py

Whitespace-only changes.

ai_models/admin.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from django.contrib import admin
2+
from django.db import models
3+
4+
from ai_models.models import VideoModelSpec
5+
from gooeysite.custom_widgets import JSONEditorWidget
6+
from usage_costs.admin import ModelPricingAdmin
7+
8+
9+
@admin.register(VideoModelSpec)
10+
class VideoModelSpecAdmin(admin.ModelAdmin):
11+
list_display = [
12+
"name",
13+
"label",
14+
"model_id",
15+
"created_at",
16+
"updated_at",
17+
]
18+
19+
list_filter = [
20+
"pricing__category",
21+
"pricing__provider",
22+
"created_at",
23+
"updated_at",
24+
]
25+
26+
search_fields = [
27+
"name",
28+
"label",
29+
"model_id",
30+
] + [f"pricing__{field}" for field in ModelPricingAdmin.search_fields]
31+
autocomplete_fields = ["pricing"]
32+
33+
readonly_fields = [
34+
"created_at",
35+
"updated_at",
36+
]
37+
38+
fieldsets = [
39+
(
40+
"Model Information",
41+
{
42+
"fields": [
43+
"name",
44+
"label",
45+
"model_id",
46+
"schema",
47+
"pricing",
48+
]
49+
},
50+
),
51+
(
52+
"Timestamps",
53+
{
54+
"fields": [
55+
"created_at",
56+
"updated_at",
57+
]
58+
},
59+
),
60+
]
61+
62+
formfield_overrides = {
63+
models.JSONField: {"widget": JSONEditorWidget},
64+
}

ai_models/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AiModelsConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "ai_models"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Generated by Django 5.1.3 on 2025-09-23 15:24
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
initial = True
10+
11+
dependencies = [
12+
("usage_costs", "0037_alter_modelpricing_model_name"),
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name="VideoModelSpec",
18+
fields=[
19+
(
20+
"id",
21+
models.BigAutoField(
22+
auto_created=True,
23+
primary_key=True,
24+
serialize=False,
25+
verbose_name="ID",
26+
),
27+
),
28+
(
29+
"name",
30+
models.TextField(
31+
help_text="The name of the model to be used in user-facing API calls. WARNING: Don't edit this field after it's been used in a workflow.",
32+
unique=True,
33+
),
34+
),
35+
(
36+
"label",
37+
models.TextField(
38+
help_text="The label of the model to be used in the UI."
39+
),
40+
),
41+
(
42+
"model_id",
43+
models.TextField(
44+
help_text="The internal API provider / huggingface model id."
45+
),
46+
),
47+
(
48+
"schema",
49+
models.JSONField(
50+
default=dict, help_text="The schema of the model parameters."
51+
),
52+
),
53+
("created_at", models.DateTimeField(auto_now_add=True)),
54+
("updated_at", models.DateTimeField(auto_now=True)),
55+
(
56+
"pricing",
57+
models.ForeignKey(
58+
blank=True,
59+
default=None,
60+
help_text="The pricing of the model. Only for display purposes. The actual pricing lookup uses the model_id, so make sure the video model's model_id matches the pricing's model_id.",
61+
null=True,
62+
on_delete=django.db.models.deletion.SET_NULL,
63+
related_name="video_model_specs",
64+
to="usage_costs.modelpricing",
65+
),
66+
),
67+
],
68+
),
69+
]

ai_models/migrations/__init__.py

Whitespace-only changes.

ai_models/models.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from django.db import models
2+
3+
4+
class VideoModelSpec(models.Model):
5+
name = models.TextField(
6+
unique=True,
7+
help_text="The name of the model to be used in user-facing API calls. WARNING: Don't edit this field after it's been used in a workflow.",
8+
)
9+
label = models.TextField(
10+
help_text="The label of the model to be used in the UI.",
11+
)
12+
model_id = models.TextField(
13+
help_text="The internal API provider / huggingface model id.",
14+
)
15+
schema = models.JSONField(
16+
help_text="The schema of the model parameters.",
17+
default=dict,
18+
)
19+
20+
pricing = models.ForeignKey(
21+
"usage_costs.ModelPricing",
22+
on_delete=models.SET_NULL,
23+
related_name="video_model_specs",
24+
null=True,
25+
blank=True,
26+
default=None,
27+
help_text="The pricing of the model. Only for display purposes. "
28+
"The actual pricing lookup uses the model_id, so make sure the video model's model_id matches the pricing's model_id.",
29+
)
30+
31+
created_at = models.DateTimeField(auto_now_add=True)
32+
updated_at = models.DateTimeField(auto_now=True)
33+
34+
def __str__(self):
35+
return f"{self.label} ({self.model_id})"
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Generated by Django 5.1.3 on 2025-09-21 07:20
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("bots", "0107_alter_publishedrun_workflow_alter_savedrun_workflow_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="publishedrun",
15+
name="workflow",
16+
field=models.IntegerField(
17+
choices=[
18+
(1, "Doc Search"),
19+
(2, "Doc Summary"),
20+
(3, "Google GPT"),
21+
(4, "Copilot"),
22+
(5, "Lipysnc + TTS"),
23+
(6, "Text to Speech"),
24+
(7, "Speech Recognition"),
25+
(8, "Lipsync"),
26+
(9, "Deforum Animation"),
27+
(10, "Compare Text2Img"),
28+
(11, "Text2Audio"),
29+
(12, "Img2Img"),
30+
(13, "Face Inpainting"),
31+
(14, "Google Image Gen"),
32+
(15, "Compare AI Upscalers"),
33+
(16, "SEO Summary"),
34+
(17, "Email Face Inpainting"),
35+
(18, "Social Lookup Email"),
36+
(19, "Object Inpainting"),
37+
(20, "Image Segmentation"),
38+
(21, "Compare LLM"),
39+
(22, "Chyron Plant"),
40+
(23, "Letter Writer"),
41+
(24, "Smart GPT"),
42+
(25, "AI QR Code"),
43+
(26, "Doc Extract"),
44+
(27, "Related QnA Maker"),
45+
(28, "Related QnA Maker Doc"),
46+
(29, "Embeddings"),
47+
(30, "Bulk Runner"),
48+
(31, "Bulk Evaluator"),
49+
(32, "Functions"),
50+
(33, "Translation"),
51+
(34, "Model Trainer"),
52+
(35, "Video Generation"),
53+
]
54+
),
55+
),
56+
migrations.AlterField(
57+
model_name="savedrun",
58+
name="workflow",
59+
field=models.IntegerField(
60+
choices=[
61+
(1, "Doc Search"),
62+
(2, "Doc Summary"),
63+
(3, "Google GPT"),
64+
(4, "Copilot"),
65+
(5, "Lipysnc + TTS"),
66+
(6, "Text to Speech"),
67+
(7, "Speech Recognition"),
68+
(8, "Lipsync"),
69+
(9, "Deforum Animation"),
70+
(10, "Compare Text2Img"),
71+
(11, "Text2Audio"),
72+
(12, "Img2Img"),
73+
(13, "Face Inpainting"),
74+
(14, "Google Image Gen"),
75+
(15, "Compare AI Upscalers"),
76+
(16, "SEO Summary"),
77+
(17, "Email Face Inpainting"),
78+
(18, "Social Lookup Email"),
79+
(19, "Object Inpainting"),
80+
(20, "Image Segmentation"),
81+
(21, "Compare LLM"),
82+
(22, "Chyron Plant"),
83+
(23, "Letter Writer"),
84+
(24, "Smart GPT"),
85+
(25, "AI QR Code"),
86+
(26, "Doc Extract"),
87+
(27, "Related QnA Maker"),
88+
(28, "Related QnA Maker Doc"),
89+
(29, "Embeddings"),
90+
(30, "Bulk Runner"),
91+
(31, "Bulk Evaluator"),
92+
(32, "Functions"),
93+
(33, "Translation"),
94+
(34, "Model Trainer"),
95+
(35, "Video Generation"),
96+
],
97+
default=4,
98+
),
99+
),
100+
migrations.AlterField(
101+
model_name="workflowmetadata",
102+
name="workflow",
103+
field=models.IntegerField(
104+
choices=[
105+
(1, "Doc Search"),
106+
(2, "Doc Summary"),
107+
(3, "Google GPT"),
108+
(4, "Copilot"),
109+
(5, "Lipysnc + TTS"),
110+
(6, "Text to Speech"),
111+
(7, "Speech Recognition"),
112+
(8, "Lipsync"),
113+
(9, "Deforum Animation"),
114+
(10, "Compare Text2Img"),
115+
(11, "Text2Audio"),
116+
(12, "Img2Img"),
117+
(13, "Face Inpainting"),
118+
(14, "Google Image Gen"),
119+
(15, "Compare AI Upscalers"),
120+
(16, "SEO Summary"),
121+
(17, "Email Face Inpainting"),
122+
(18, "Social Lookup Email"),
123+
(19, "Object Inpainting"),
124+
(20, "Image Segmentation"),
125+
(21, "Compare LLM"),
126+
(22, "Chyron Plant"),
127+
(23, "Letter Writer"),
128+
(24, "Smart GPT"),
129+
(25, "AI QR Code"),
130+
(26, "Doc Extract"),
131+
(27, "Related QnA Maker"),
132+
(28, "Related QnA Maker Doc"),
133+
(29, "Embeddings"),
134+
(30, "Bulk Runner"),
135+
(31, "Bulk Evaluator"),
136+
(32, "Functions"),
137+
(33, "Translation"),
138+
(34, "Model Trainer"),
139+
(35, "Video Generation"),
140+
],
141+
unique=True,
142+
),
143+
),
144+
]

bots/models/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Workflow(models.IntegerChoices):
221221
FUNCTIONS = (32, "Functions")
222222
TRANSLATION = (33, "Translation")
223223
MODEL_TRAINER = (34, "Model Trainer")
224-
TEXT_VIDEO = (35, "Text Video")
224+
VIDEO_GEN = (35, "Video Generation")
225225

226226
@property
227227
def short_slug(self):

bots/templates/django/forms/widgets/textarea.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
gutters: ["CodeMirror-lint-markers"],
2525
theme: "monokai",
2626
lint: true,
27+
extraKeys: {
28+
"Ctrl-F": "findPersistent",
29+
"Cmd-F": "findPersistent"
30+
}
2731
});
2832
</script>
2933
{% else %}

daras_ai_v2/all_pages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from recipes.SocialLookupEmail import SocialLookupEmailPage
3434
from recipes.Text2Audio import Text2AudioPage
3535
from recipes.TextToSpeech import TextToSpeechPage
36-
from recipes.TextToVideo import TextToVideoPage
36+
from recipes.VideoGenPage import VideoGenPage
3737
from recipes.VideoBots import VideoBotsPage
3838
from recipes.asr_page import AsrPage
3939
from recipes.embeddings_page import EmbeddingsPage
@@ -64,7 +64,7 @@
6464
FunctionsPage,
6565
],
6666
"Videos, Lipsync, & Speech": [
67-
TextToVideoPage,
67+
VideoGenPage,
6868
LipsyncPage,
6969
LipsyncTTSPage,
7070
TextToSpeechPage,

0 commit comments

Comments
 (0)