fix: rename class to differentiate lighthouse providers

This commit is contained in:
Chandrapal Badshah
2025-10-09 12:01:31 +05:30
parent 29ab107edf
commit dd7fed06ac
5 changed files with 15 additions and 14 deletions
+4 -4
View File
@@ -933,10 +933,10 @@ class TenantApiKeyFilter(FilterSet):
class LighthouseProviderConfigFilter(FilterSet):
provider_type = ChoiceFilter(
choices=LighthouseProviderConfiguration.ProviderChoices.choices
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices
)
provider_type__in = ChoiceInFilter(
choices=LighthouseProviderConfiguration.ProviderChoices.choices,
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices,
field_name="provider_type",
lookup_expr="in",
)
@@ -952,11 +952,11 @@ class LighthouseProviderConfigFilter(FilterSet):
class LighthouseProviderModelsFilter(FilterSet):
provider_type = ChoiceFilter(
choices=LighthouseProviderConfiguration.ProviderChoices.choices,
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices,
field_name="provider_configuration__provider_type",
)
provider_type__in = ChoiceInFilter(
choices=LighthouseProviderConfiguration.ProviderChoices.choices,
choices=LighthouseProviderConfiguration.LLMProviderChoices.choices,
field_name="provider_configuration__provider_type",
lookup_expr="in",
)
+2 -2
View File
@@ -1967,7 +1967,7 @@ class LighthouseProviderConfiguration(RowLevelSecurityProtectedModel):
One configuration per provider type per tenant.
"""
class ProviderChoices(models.TextChoices):
class LLMProviderChoices(models.TextChoices):
OPENAI = "openai", _("OpenAI")
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
@@ -1976,7 +1976,7 @@ class LighthouseProviderConfiguration(RowLevelSecurityProtectedModel):
provider_type = models.CharField(
max_length=50,
choices=ProviderChoices.choices,
choices=LLMProviderChoices.choices,
help_text="LLM provider name",
)
+5 -4
View File
@@ -3080,7 +3080,7 @@ class LighthouseProviderConfigCreateSerializer(RLSSerializer, BaseWriteSerialize
provider_type = attrs.get("provider_type")
credentials = attrs.get("credentials") or {}
if provider_type == LighthouseProviderConfiguration.ProviderChoices.OPENAI:
if provider_type == LighthouseProviderConfiguration.LLMProviderChoices.OPENAI:
try:
OpenAICredentialsSerializer(data=credentials).is_valid(
raise_exception=True
@@ -3136,7 +3136,8 @@ class LighthouseProviderConfigUpdateSerializer(BaseWriteSerializer):
if (
credentials is not None
and provider_type == LighthouseProviderConfiguration.ProviderChoices.OPENAI
and provider_type
== LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
):
try:
OpenAICredentialsSerializer(data=credentials).is_valid(
@@ -3211,7 +3212,7 @@ class LighthouseTenantConfigCreateSerializer(RLSSerializer, BaseWriteSerializer)
default_models = attrs.get("default_models", {})
if default_provider:
supported = set(LighthouseProviderConfiguration.ProviderChoices.values)
supported = set(LighthouseProviderConfiguration.LLMProviderChoices.values)
if default_provider not in supported:
raise ValidationError(
{"default_provider": f"Unsupported provider '{default_provider}'."}
@@ -3289,7 +3290,7 @@ class LighthouseTenantConfigUpdateSerializer(BaseWriteSerializer):
)
if default_provider:
supported = set(LighthouseProviderConfiguration.ProviderChoices.values)
supported = set(LighthouseProviderConfiguration.LLMProviderChoices.values)
if default_provider not in supported:
raise ValidationError(
{"default_provider": f"Unsupported provider '{default_provider}'."}
+2 -2
View File
@@ -4282,7 +4282,7 @@ class LighthouseProviderConfigViewSet(BaseRLSViewSet):
instance = self.get_object()
if (
instance.provider_type
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
):
return Response(
data={
@@ -4325,7 +4325,7 @@ class LighthouseProviderConfigViewSet(BaseRLSViewSet):
instance = self.get_object()
if (
instance.provider_type
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
):
return Response(
data={
@@ -58,7 +58,7 @@ def check_lighthouse_provider_connection(provider_config_id: str) -> Dict:
# TODO: Add support for other providers
if (
provider_cfg.provider_type
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
):
return {"connected": False, "error": "Unsupported provider type"}
@@ -107,7 +107,7 @@ def refresh_lighthouse_provider_models(provider_config_id: str) -> Dict:
if (
provider_cfg.provider_type
!= LighthouseProviderConfiguration.ProviderChoices.OPENAI
!= LighthouseProviderConfiguration.LLMProviderChoices.OPENAI
):
return {
"created": 0,