feat(llmobs): add retrieval and embedding spans [backport 2.9] #9358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport d10e081 from #9134 to 2.9.
This PR adds support for submitting embedding and retrieval type spans for LLM Observability, both via
LLMObs.{retrieval/embedding}
and@ddtrace.llmobs.decorators.{retrieval/embedding}
.Additionally, this PR adds a public helper class
ddtrace.llmobs.utils.Documents
for users to create SDK-compatible input/output annotation objects for Embedding/Retrieval spans.Embedding spans require a model name to be set, and also optionally accepts model provider values (will default to
custom
). Embedding spans can be annotated with:Documents
when submitted to LLMObs.Retrieval spans can be annotated with:
Documents
when submitted to LLMObs.This PR also introduces a class of type
ddtrace.llmobs.utils.Documents
, which can be used to convert arguments to be tagged as input/output documents. TheDocuments
TypedDict object can contain the following fields:name
: strid
: strtext
: strscore
: int/floatChecklist
changelog/no-changelog
is set@DataDog/apm-tees
.Reviewer Checklist