Repository navigation
chore(ai-sdks): Document embedding spans #20252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alexander-alderman-webb
wants to merge
4
commits into
master
Choose a base branch
from
webb/embedding-spans
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6c2396f
chore(ai-sdks): Remove requirement level from attributes
alexander-alderman-webb 57523dd
chore(ai-sdks): Document embedding spans
alexander-alderman-webb f9ec3ae
Merge branch 'master' into webb/embedding-spans
alexander-alderman-webb 2c451e4
only set what product uses
alexander-alderman-webb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ This span represents a request to an AI model or service that generates a respon | |
|
|
||
| - Span `op` **SHOULD** be `"gen_ai.{gen_ai.operation.name}"`. (e.g. `"gen_ai.chat"`) | ||
| - Span `name` **SHOULD** be `"{gen_ai.operation.name} {gen_ai.request.model}"`. (e.g. `"chat o3-mini"`) | ||
| - Attribute `gen_ai.operation.name` **MUST** be `"chat"`, `"embeddings"`, `"generate_content"` or `"text_completion"`. | ||
| - Attribute `gen_ai.operation.name` **MUST** be `"chat"`, `"generate_content"` or `"text_completion"`. | ||
| - Attribute `gen_ai.provider.name` **MUST** be the Generative AI product as identified by the client or server instrumentation. (e.g. `"openai"`) | ||
| - Attribute `gen_ai.request.model` **MUST** be the requested model. (e.g. `"gpt-4o"`) | ||
| - Attribute `gen_ai.response.model` **MUST** be the concrete response model. (e.g. `"gpt-4o-2024-08-06"`) | ||
|
|
@@ -111,6 +111,26 @@ Additional attributes on the span: | |
| - **[2]:** Cached tokens are a subset of input tokens; `gen_ai.usage.input_tokens` includes `gen_ai.usage.cache_read.input_tokens`. | ||
| - **[3]:** Reasoning tokens are a subset of output tokens; `gen_ai.usage.output_tokens` includes `gen_ai.usage.reasoning.output_tokens`. | ||
|
|
||
| ## Embedding Span | ||
|
|
||
| This span represents a request to a provider to encode input into numeric vector embeddings. | ||
|
|
||
| - Span `op` **SHOULD** be `"gen_ai.embeddings"`. | ||
| - Span `name` **SHOULD** be `"embeddings {gen_ai.request.model}"`. (e.g. `"embeddings text-embedding-3-small"`) | ||
| - Attribute `gen_ai.operation.name` **MUST** be `"embeddings"`. | ||
| - Attribute `gen_ai.provider.name` **MUST** be the Generative AI product as identified by the client or server instrumentation. (e.g. `"openai"`) | ||
| - Attribute `gen_ai.request.model` **MUST** be the requested model. (e.g. `"text-embedding-3-small"`) | ||
| - Attribute `gen_ai.response.model` **MUST** be the concrete response model. (e.g. `"text-embedding-3-small-001"`) | ||
| - If the request originates from an agent, the `gen_ai.agent.name` attribute **SHOULD** be set to the name of the agent. (e.g. `"Weather Agent"`) | ||
| - If relevant, the `gen_ai.pipeline.name` attribute **SHOULD** be set to the name of the AI workflow, pipeline or chain within which the agent operates. (e.g. `"weather-pipeline"`) | ||
|
|
||
| Additional attributes on the span: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the MAY, SHOULD, or MUST? |
||
|
|
||
| | Attribute | Type | Description | Example | | ||
| | :-------------------------- | :----- | :-------------------------------------- | :--------------------------------------------- | | ||
| | `gen_ai.embeddings.input` | string | Input to embed. | `'{"type": "text", "value": "Hello, world!"}'` | | ||
| | `gen_ai.usage.input_tokens` | int | The number of tokens used in the input. | `60` | | ||
|
|
||
| ## Execute Tool Span | ||
|
|
||
| Describes a tool execution. | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these really need to be MUST-level requirements? E.g. what if the integration does not allow retrieving these values?
I would downgrade to SHOULD