-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(llmobs): add retrieval and embedding spans (#9134)
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 input strings, dictionaries, or a list of dictionaries, which will be cast as `Documents` when submitted to LLMObs. Embedding spans can be annotated with output strings or any JSON serializable value. Retrieval spans can be annotated with input strings or any JSON serializable value. Retrieval spans can also be annotated with output strings, dictionaries, or a list of dictionaries, which will be cast as `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. The `Documents` TypedDict object can contain the following fields: - `name`: str - `id`: str - `text`: str - `score`: int/float ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) (cherry picked from commit d10e081)
- Loading branch information
1 parent
af1c3e2
commit 8f8291f
Showing
8 changed files
with
512 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.