Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(llma): only show llm-judge evals in trial credits modal (#66195)

posthog[bot]30cdf805eaa5
diff --git a/products/ai_observability/backend/api/provider_keys.py b/products/ai_observability/backend/api/provider_keys.py
index 8e375dac83e8..472804da67dc 100644
--- a/products/ai_observability/backend/api/provider_keys.py
+++ b/products/ai_observability/backend/api/provider_keys.py
@@ -29,6 +29,7 @@ from ..llm.providers.azure_openai import (
is_allowed_azure_endpoint,
)
from ..models.evaluation_config import EvaluationConfig
+from ..models.evaluation_configs import EvaluationType
from ..models.evaluations import Evaluation
from ..models.model_configuration import LLMModelConfiguration
from ..models.provider_keys import LLMProvider, LLMProviderKey
@@ -439,9 +440,11 @@ class LLMProviderKeyViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, v
if provider == "openai":
trial_filter |= Q(model_configuration__isnull=True)
- trial_evals = Evaluation.objects.filter(trial_filter, team_id=self.team_id, deleted=False).values(
- "id", "name", "enabled"
- )[:50]
+ # Only LLM-as-a-judge evaluations use a provider key — Hog and Sentiment never do, so the
+ # legacy "no model_configuration" clause above would otherwise sweep them in.
+ trial_evals = Evaluation.objects.filter(
+ trial_filter, team_id=self.team_id, deleted=False, evaluation_type=EvaluationType.LLM_JUDGE
+ ).values("id", "name", "enabled")[:50]
return Response({"evaluations": list(trial_evals)})
diff --git a/products/ai_observability/backend/api/test/test_provider_keys.py b/products/ai_observability/backend/api/test/test_provider_keys.py
index 3626fc44e849..1ab3b4161db7 100644
--- a/products/ai_observability/backend/api/test/test_provider_keys.py
+++ b/products/ai_observability/backend/api/test/test_provider_keys.py
@@ -1214,6 +1214,32 @@ class TestTrialEvaluationsEndpoint(APIBaseTest):
self.assertEqual(len(response.data["evaluations"]), 1)
self.assertEqual(response.data["evaluations"][0]["name"], "Legacy")
+ def test_excludes_non_llm_judge_evals(self):
+ # Hog and Sentiment evals have no model_configuration, so the legacy OpenAI clause would
+ # otherwise sweep them in — but they never use a provider key.
+ Evaluation.objects.create(
+ team=self.team,
+ name="Hog eval",
+ evaluation_type="hog",
+ output_type="boolean",
+ model_configuration=None,
+ enabled=True,
+ )
+ Evaluation.objects.create(
+ team=self.team,
+ name="Sentiment eval",
+ evaluation_type="sentiment",
+ output_type="sentiment",
+ model_configuration=None,
+ enabled=True,
+ )
+
+ response = self.client.get(
+ f"/api/environments/{self.team.id}/llm_analytics/provider_keys/trial_evaluations/?provider=openai"
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ self.assertEqual(len(response.data["evaluations"]), 0)
+
def test_rejects_invalid_provider(self):
response = self.client.get(
f"/api/environments/{self.team.id}/llm_analytics/provider_keys/trial_evaluations/?provider=invalid"