From 148764019711b5cfa56af7aee96d97b5374150f5 Mon Sep 17 00:00:00 2001 From: hakan458 Date: Tue, 7 Jan 2025 17:19:28 -0800 Subject: [PATCH 1/5] feat: DIA-1715: VertexAI Gemini model support --- ...google_application_credentials_and_more.py | 62 +++++++++++++++++++ label_studio/ml_model_providers/models.py | 12 ++++ ...3_alter_thirdpartymodelversion_provider.py | 28 +++++++++ 3 files changed, 102 insertions(+) create mode 100644 label_studio/ml_model_providers/migrations/0006_modelproviderconnection_google_application_credentials_and_more.py create mode 100644 label_studio/ml_models/migrations/0013_alter_thirdpartymodelversion_provider.py diff --git a/label_studio/ml_model_providers/migrations/0006_modelproviderconnection_google_application_credentials_and_more.py b/label_studio/ml_model_providers/migrations/0006_modelproviderconnection_google_application_credentials_and_more.py new file mode 100644 index 000000000000..9af3b889dc7c --- /dev/null +++ b/label_studio/ml_model_providers/migrations/0006_modelproviderconnection_google_application_credentials_and_more.py @@ -0,0 +1,62 @@ +# Generated by Django 5.1.4 on 2025-01-03 20:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "ml_model_providers", + "0005_modelproviderconnection_budget_alert_threshold_and_more", + ), + ] + + operations = [ + migrations.AddField( + model_name="modelproviderconnection", + name="google_application_credentials", + field=models.TextField( + blank=True, + help_text="The content of GOOGLE_APPLICATION_CREDENTIALS json file", + null=True, + verbose_name="google application credentials", + ), + ), + migrations.AddField( + model_name="modelproviderconnection", + name="google_location", + field=models.CharField( + blank=True, + help_text="Google project location", + max_length=255, + null=True, + verbose_name="google location", + ), + ), + migrations.AddField( + model_name="modelproviderconnection", + name="google_project_id", + field=models.CharField( + blank=True, + help_text="Google project ID", + max_length=255, + null=True, + verbose_name="google project id", + ), + ), + migrations.AlterField( + model_name="modelproviderconnection", + name="provider", + field=models.CharField( + choices=[ + ("OpenAI", "OpenAI"), + ("AzureOpenAI", "AzureOpenAI"), + ("VertexAI", "VertexAI"), + ("Custom", "Custom"), + ], + default="OpenAI", + max_length=255, + ), + ), + ] diff --git a/label_studio/ml_model_providers/models.py b/label_studio/ml_model_providers/models.py index eda8223b5eb2..54d895910c4b 100644 --- a/label_studio/ml_model_providers/models.py +++ b/label_studio/ml_model_providers/models.py @@ -11,6 +11,7 @@ class ModelProviders(models.TextChoices): OPENAI = 'OpenAI', _('OpenAI') AZURE_OPENAI = 'AzureOpenAI', _('AzureOpenAI') + VERTEX_AI = 'VertexAI', _('VertexAI') CUSTOM = 'Custom', _('Custom') @@ -32,6 +33,17 @@ class ModelProviderConnection(models.Model): endpoint = models.CharField(max_length=512, null=True, blank=True, help_text='Azure OpenAI endpoint') + google_application_credentials = models.TextField( + _('google application credentials'), + null=True, + blank=True, + help_text='The content of GOOGLE_APPLICATION_CREDENTIALS json file', + ) + + google_project_id = models.CharField(_('google project id'), max_length=255, null=True, blank=True, help_text='Google project ID') + + google_location = models.CharField(_('google location'), max_length=255, null=True, blank=True, help_text='Google project location') + cached_available_models = models.CharField( max_length=4096, null=True, blank=True, help_text='List of available models from the provider' ) diff --git a/label_studio/ml_models/migrations/0013_alter_thirdpartymodelversion_provider.py b/label_studio/ml_models/migrations/0013_alter_thirdpartymodelversion_provider.py new file mode 100644 index 000000000000..5823fc63e085 --- /dev/null +++ b/label_studio/ml_models/migrations/0013_alter_thirdpartymodelversion_provider.py @@ -0,0 +1,28 @@ +# Generated by Django 5.1.4 on 2025-01-03 20:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("ml_models", "0012_alter_thirdpartymodelversion_provider"), + ] + + operations = [ + migrations.AlterField( + model_name="thirdpartymodelversion", + name="provider", + field=models.CharField( + choices=[ + ("OpenAI", "OpenAI"), + ("AzureOpenAI", "AzureOpenAI"), + ("VertexAI", "VertexAI"), + ("Custom", "Custom"), + ], + default="OpenAI", + help_text="The model provider to use e.g. OpenAI", + max_length=255, + ), + ), + ] From b0cbca005901305b5a042f3fb0bc7456f6cde7d2 Mon Sep 17 00:00:00 2001 From: Matt Bernstein Date: Fri, 10 Jan 2025 13:33:17 -0500 Subject: [PATCH 2/5] feat: DIA-1716: Google AI Studio support in Prompts From 1baff06ee9e9340d947f5084c2a8fcc1615a42cf Mon Sep 17 00:00:00 2001 From: Matt Bernstein Date: Fri, 10 Jan 2025 13:39:24 -0500 Subject: [PATCH 3/5] add gemini to enum --- ..._alter_modelproviderconnection_provider.py | 31 +++++++++++++++++++ label_studio/ml_model_providers/models.py | 1 + ...4_alter_thirdpartymodelversion_provider.py | 29 +++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 label_studio/ml_model_providers/migrations/0007_alter_modelproviderconnection_provider.py create mode 100644 label_studio/ml_models/migrations/0014_alter_thirdpartymodelversion_provider.py diff --git a/label_studio/ml_model_providers/migrations/0007_alter_modelproviderconnection_provider.py b/label_studio/ml_model_providers/migrations/0007_alter_modelproviderconnection_provider.py new file mode 100644 index 000000000000..911f764f3b9f --- /dev/null +++ b/label_studio/ml_model_providers/migrations/0007_alter_modelproviderconnection_provider.py @@ -0,0 +1,31 @@ +# Generated by Django 5.1.4 on 2025-01-10 18:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "ml_model_providers", + "0006_modelproviderconnection_google_application_credentials_and_more", + ), + ] + + operations = [ + migrations.AlterField( + model_name="modelproviderconnection", + name="provider", + field=models.CharField( + choices=[ + ("OpenAI", "OpenAI"), + ("AzureOpenAI", "AzureOpenAI"), + ("VertexAI", "VertexAI"), + ("Gemini", "Gemini"), + ("Custom", "Custom"), + ], + default="OpenAI", + max_length=255, + ), + ), + ] diff --git a/label_studio/ml_model_providers/models.py b/label_studio/ml_model_providers/models.py index 54d895910c4b..3ee837da0c03 100644 --- a/label_studio/ml_model_providers/models.py +++ b/label_studio/ml_model_providers/models.py @@ -12,6 +12,7 @@ class ModelProviders(models.TextChoices): OPENAI = 'OpenAI', _('OpenAI') AZURE_OPENAI = 'AzureOpenAI', _('AzureOpenAI') VERTEX_AI = 'VertexAI', _('VertexAI') + GEMINI = 'Gemini', _('Gemini') CUSTOM = 'Custom', _('Custom') diff --git a/label_studio/ml_models/migrations/0014_alter_thirdpartymodelversion_provider.py b/label_studio/ml_models/migrations/0014_alter_thirdpartymodelversion_provider.py new file mode 100644 index 000000000000..0e5d86397233 --- /dev/null +++ b/label_studio/ml_models/migrations/0014_alter_thirdpartymodelversion_provider.py @@ -0,0 +1,29 @@ +# Generated by Django 5.1.4 on 2025-01-10 18:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("ml_models", "0013_alter_thirdpartymodelversion_provider"), + ] + + operations = [ + migrations.AlterField( + model_name="thirdpartymodelversion", + name="provider", + field=models.CharField( + choices=[ + ("OpenAI", "OpenAI"), + ("AzureOpenAI", "AzureOpenAI"), + ("VertexAI", "VertexAI"), + ("Gemini", "Gemini"), + ("Custom", "Custom"), + ], + default="OpenAI", + help_text="The model provider to use e.g. OpenAI", + max_length=255, + ), + ), + ] From fbec9b6acb059831d10a4c5143bc5713dff2c491 Mon Sep 17 00:00:00 2001 From: Matt Bernstein Date: Fri, 10 Jan 2025 15:14:22 -0500 Subject: [PATCH 4/5] feat: DIA-1802: Anthropic support in Prompts From a349ae667704f5f8cfc421c9477a025859649d69 Mon Sep 17 00:00:00 2001 From: Matt Bernstein Date: Fri, 10 Jan 2025 15:16:04 -0500 Subject: [PATCH 5/5] update enum --- ..._alter_modelproviderconnection_provider.py | 29 ++++++++++++++++++ label_studio/ml_model_providers/models.py | 1 + ...5_alter_thirdpartymodelversion_provider.py | 30 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 label_studio/ml_model_providers/migrations/0008_alter_modelproviderconnection_provider.py create mode 100644 label_studio/ml_models/migrations/0015_alter_thirdpartymodelversion_provider.py diff --git a/label_studio/ml_model_providers/migrations/0008_alter_modelproviderconnection_provider.py b/label_studio/ml_model_providers/migrations/0008_alter_modelproviderconnection_provider.py new file mode 100644 index 000000000000..7cbb55b158c6 --- /dev/null +++ b/label_studio/ml_model_providers/migrations/0008_alter_modelproviderconnection_provider.py @@ -0,0 +1,29 @@ +# Generated by Django 5.1.4 on 2025-01-10 20:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("ml_model_providers", "0007_alter_modelproviderconnection_provider"), + ] + + operations = [ + migrations.AlterField( + model_name="modelproviderconnection", + name="provider", + field=models.CharField( + choices=[ + ("OpenAI", "OpenAI"), + ("AzureOpenAI", "AzureOpenAI"), + ("VertexAI", "VertexAI"), + ("Gemini", "Gemini"), + ("Anthropic", "Anthropic"), + ("Custom", "Custom"), + ], + default="OpenAI", + max_length=255, + ), + ), + ] diff --git a/label_studio/ml_model_providers/models.py b/label_studio/ml_model_providers/models.py index 3ee837da0c03..72b6cdd8ce2b 100644 --- a/label_studio/ml_model_providers/models.py +++ b/label_studio/ml_model_providers/models.py @@ -13,6 +13,7 @@ class ModelProviders(models.TextChoices): AZURE_OPENAI = 'AzureOpenAI', _('AzureOpenAI') VERTEX_AI = 'VertexAI', _('VertexAI') GEMINI = 'Gemini', _('Gemini') + ANTHROPIC = 'Anthropic', _('Anthropic') CUSTOM = 'Custom', _('Custom') diff --git a/label_studio/ml_models/migrations/0015_alter_thirdpartymodelversion_provider.py b/label_studio/ml_models/migrations/0015_alter_thirdpartymodelversion_provider.py new file mode 100644 index 000000000000..cc1f678ec170 --- /dev/null +++ b/label_studio/ml_models/migrations/0015_alter_thirdpartymodelversion_provider.py @@ -0,0 +1,30 @@ +# Generated by Django 5.1.4 on 2025-01-10 20:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("ml_models", "0014_alter_thirdpartymodelversion_provider"), + ] + + operations = [ + migrations.AlterField( + model_name="thirdpartymodelversion", + name="provider", + field=models.CharField( + choices=[ + ("OpenAI", "OpenAI"), + ("AzureOpenAI", "AzureOpenAI"), + ("VertexAI", "VertexAI"), + ("Gemini", "Gemini"), + ("Anthropic", "Anthropic"), + ("Custom", "Custom"), + ], + default="OpenAI", + help_text="The model provider to use e.g. OpenAI", + max_length=255, + ), + ), + ]