Skip to content

Add LLM Obs evaluations to DDClient - #3

Open
Kyle-Verhoog wants to merge 1 commit into
mainfrom
llmobs-evals
Open

Add LLM Obs evaluations to DDClient#3
Kyle-Verhoog wants to merge 1 commit into
mainfrom
llmobs-evals

Conversation

@Kyle-Verhoog

Copy link
Copy Markdown
Owner

Brings the evaluation half of LLM Observability onto the client, so scoring what the app produced sits next to tracing it instead of requiring a drop down into ddtrace.

Covers evaluation metrics against spans, datasets, experiments (sync and async, plus a build-and-run convenience), and publishing an evaluator for Datadog to run against live spans. The metric type is inferred from the value and the evaluation attaches to the span currently being traced, so the common case is one line; spans from another process can still be joined explicitly or by tag.

Datasets and experiments hit the Datadog API directly and so need an app key on top of the api key — that plus the project they organize under are new config options, both with env var equivalents, and the error you get without an app key says so. Evaluator and dataset types are re-exported under a new module so evaluator code has a single import surface; it stays out of the package import path so clients with LLM Obs off don't pay for it.

Validated with the new example and a scratch script covering type inference, the three join keys, metadata passthrough, project defaulting and overrides, and every error path. Type checking is one error better than before; formatting is unchanged. Experiments were exercised against a recording double, not real credentials — the dataset/experiment round trip to Datadog is untested.

🤖 Generated with Claude Code

Evaluation metrics, datasets, experiments and evaluator publishing are
now client methods rather than something you reach into ddtrace for.

submit_evaluation infers metric_type from the value (bool before int,
since bool is an int subclass) and defaults to the active LLM Obs span,
so scoring a workflow is a one-liner. It also accepts a live span or the
dict from export_span(), and export_span() raises rather than returning
None when nothing is in scope, so that's caught to give a useful error.

Datasets/experiments need an app key on top of the api key, added as
llmobs_app_key (DD_APP_KEY), alongside llmobs_project_name
(DD_LLMOBS_PROJECT_NAME) for the project they organize under. Both are
passed through to LLMObs.enable.

datadog.llmobs re-exports the evaluator base classes, built-ins, judge
helpers and dataset types so evaluator code doesn't import ddtrace. It
is intentionally not imported by the package __init__, keeping the
ddtrace.llmobs import cost off clients with LLM Obs disabled.

Also fixes the return type comment on trace(): ddtrace.Span does not
exist at runtime in ddtrace 4, it's ddtrace.trace.Span.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant