Обновление GLM моделей до GLM-4
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# Generated migration for updating GLM default model
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def update_glm_default_model(apps, schema_editor):
|
||||
"""Обновляем модель по умолчанию для существующих записей GLM"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Обновляем все записи с glm-4.7 на glm-4-flash
|
||||
GLMIntegration.objects.filter(model_name='glm-4.7').update(model_name='glm-4-flash')
|
||||
|
||||
|
||||
def reverse_update_glm_default_model(apps, schema_editor):
|
||||
"""Откат миграции - возвращаем glm-4.7"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Возвращаем glm-4.7
|
||||
GLMIntegration.objects.filter(model_name='glm-4-flash').update(model_name='glm-4.7')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('integrations', '0002_glmintegration_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(update_glm_default_model, reverse_update_glm_default_model),
|
||||
]
|
||||
29
myproject/integrations/migrations/0004_revert_glm_model.py
Normal file
29
myproject/integrations/migrations/0004_revert_glm_model.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Generated migration for reverting GLM model back to glm-4.7
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def revert_glm_model(apps, schema_editor):
|
||||
"""Откатываем модель обратно на glm-4.7"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Обновляем все записи с glm-4-flash обратно на glm-4.7
|
||||
GLMIntegration.objects.filter(model_name='glm-4-flash').update(model_name='glm-4.7')
|
||||
|
||||
|
||||
def reverse_revert_glm_model(apps, schema_editor):
|
||||
"""Применяем миграцию - возвращаем glm-4-flash"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Возвращаем glm-4-flash
|
||||
GLMIntegration.objects.filter(model_name='glm-4.7').update(model_name='glm-4-flash')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('integrations', '0003_update_glm_default_model'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(revert_glm_model, reverse_revert_glm_model),
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
# Generated migration for updating GLM model to glm-4
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def update_glm_model_to_glm4(apps, schema_editor):
|
||||
"""Обновляем модель с glm-4-flash на glm-4"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Обновляем все записи с glm-4-flash на glm-4
|
||||
GLMIntegration.objects.filter(model_name='glm-4-flash').update(model_name='glm-4')
|
||||
|
||||
|
||||
def reverse_update_glm_model_to_glm4(apps, schema_editor):
|
||||
"""Откат миграции - возвращаем glm-4-flash"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Возвращаем glm-4-flash
|
||||
GLMIntegration.objects.filter(model_name='glm-4').update(model_name='glm-4-flash')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('integrations', '0004_revert_glm_model'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(update_glm_model_to_glm4, reverse_update_glm_model_to_glm4),
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
# Generated migration for updating GLM model from glm-4-flash to glm-4
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def update_glm_model_to_glm4(apps, schema_editor):
|
||||
"""Обновляем модель с glm-4-flash на glm-4"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Обновляем все записи с glm-4-flash на glm-4
|
||||
GLMIntegration.objects.filter(model_name='glm-4-flash').update(model_name='glm-4')
|
||||
|
||||
|
||||
def reverse_update_glm_model_to_glm4(apps, schema_editor):
|
||||
"""Откат миграции - возвращаем glm-4-flash"""
|
||||
GLMIntegration = apps.get_model('integrations', 'GLMIntegration')
|
||||
|
||||
# Возвращаем glm-4-flash
|
||||
GLMIntegration.objects.filter(model_name='glm-4').update(model_name='glm-4-flash')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('integrations', '0005_update_glm_model_to_glm4'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(update_glm_model_to_glm4, reverse_update_glm_model_to_glm4),
|
||||
]
|
||||
Reference in New Issue
Block a user