Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ddtrace/llmobs/_llmobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,10 @@ def submit_evaluation(
error = "invalid_metric_label"
raise ValueError("label must be the specified name of the evaluation metric.")

if "." in label:
error = "invalid_label_value"
raise ValueError("label value must not contain a '.'.")

metric_type = metric_type.lower()
if metric_type not in ("categorical", "score", "boolean"):
error = "invalid_metric_type"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fixes:
- |
LLM Observability: This fix resolves an issue where evaluation-metric labels containing dots could be interpreted as nested objects by adding validation that rejects such labels and provides a clear error message instructing users to use alternative naming conventions.

7 changes: 7 additions & 0 deletions tests/llmobs/test_llmobs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,13 @@ def test_submit_evaluation_empty_label_raises_error(llmobs, mock_llmobs_logs):
)


def test_submit_evaluation_label_value_with_a_period_raises_error(llmobs, mock_llmobs_logs):
with pytest.raises(ValueError, match="label value must not contain a '.'."):
llmobs.submit_evaluation(
span={"span_id": "123", "trace_id": "456"}, label="toxicity.0", metric_type="categorical", value="high"
)


def test_submit_evaluation_incorrect_metric_type_raises_error(llmobs, mock_llmobs_logs):
with pytest.raises(ValueError, match="metric_type must be one of 'categorical', 'score', or 'boolean'."):
llmobs.submit_evaluation(
Expand Down
Loading