-
Notifications
You must be signed in to change notification settings - Fork 140
feat(semcov): Add Image Token Count and Cost Semantic Conventions #1787
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
sallyannarize
wants to merge
4
commits into
Arize-ai:main
Choose a base branch
from
sallyannarize:sallyann/image_semconv
base: main
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 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@arizeai/openinference-semantic-conventions": major | ||
--- | ||
|
||
Add image semantic conventions |
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
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 |
---|---|---|
|
@@ -70,65 +70,88 @@ class SpanAttributes: | |
""" | ||
The version of the prompt template being used. | ||
""" | ||
LLM_TOKEN_COUNT_COMPLETION = "llm.token_count.completion" | ||
""" | ||
Number of tokens in the completion (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_COMPLETION_DETAILS_AUDIO = "llm.token_count.completion_details.audio" | ||
LLM_TOKEN_COUNT_PROMPT = "llm.token_count.prompt" | ||
""" | ||
The number of audio tokens in the completion (in tokens). | ||
Number of tokens in the prompt. | ||
""" | ||
LLM_TOKEN_COUNT_COMPLETION_DETAILS_REASONING = "llm.token_count.completion_details.reasoning" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_WRITE = "llm.token_count.prompt_details.cache_write" | ||
""" | ||
Number of tokens used for reasoning steps in the completion (in tokens). | ||
Number of tokens in the prompt that were written to cache (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_PROMPT = "llm.token_count.prompt" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_READ = "llm.token_count.prompt_details.cache_read" | ||
""" | ||
Number of tokens in the prompt. | ||
Number of tokens in the prompt that were read from cache (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS = "llm.token_count.prompt_details" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_INPUT = "llm.token_count.prompt_details.cache_input" | ||
""" | ||
Key prefix for additional prompt token count details. Each detail should be a separate attribute | ||
with this prefix, e.g. llm.token_count.prompt_details.reasoning, | ||
llm.token_count.prompt_details.audio. All values should be in tokens. | ||
Number of input tokens in the prompt that were cached (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_AUDIO = "llm.token_count.prompt_details.audio" | ||
""" | ||
The number of audio tokens in the prompt (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_INPUT = "llm.token_count.prompt_details.cache_input" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_IMAGE = "llm.token_count.prompt_details.image" | ||
""" | ||
Number of input tokens in the prompt that were cached (in tokens). | ||
The number of image tokens in the prompt (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_READ = "llm.token_count.prompt_details.cache_read" | ||
|
||
LLM_TOKEN_COUNT_COMPLETION = "llm.token_count.completion" | ||
""" | ||
Number of tokens in the prompt that were read from cache (in tokens). | ||
Number of tokens in the completion (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_WRITE = "llm.token_count.prompt_details.cache_write" | ||
LLM_TOKEN_COUNT_COMPLETION_DETAILS_REASONING = "llm.token_count.completion_details.reasoning" | ||
""" | ||
Number of tokens in the prompt that were written to cache (in tokens). | ||
Number of tokens used for reasoning steps in the completion (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_COMPLETION_DETAILS_AUDIO = "llm.token_count.completion_details.audio" | ||
""" | ||
The number of audio tokens in the completion (in tokens). | ||
""" | ||
LLM_TOKEN_COUNT_COMPLETION_DETAILS_IMAGE = "llm.token_count.completion_details.image" | ||
""" | ||
The number of image tokens in the completion (in tokens). | ||
""" | ||
|
||
LLM_TOKEN_COUNT_TOTAL = "llm.token_count.total" | ||
""" | ||
Total number of tokens, including both prompt and completion (in tokens). | ||
""" | ||
|
||
LLM_TOKEN_COUNT_PROMPT_DETAILS = "llm.token_count.prompt_details" | ||
""" | ||
Key prefix for additional prompt token count details. Each detail should be a separate attribute | ||
with this prefix, e.g. llm.token_count.prompt_details.reasoning, | ||
llm.token_count.prompt_details.audio. All values should be in tokens. | ||
""" | ||
LLM_TOKEN_COUNT_COMPLETION_DETAILS = "llm.token_count.completion_details" | ||
""" | ||
Key prefix for additional completion token count details. Each detail should be a separate | ||
attribute with this prefix, e.g. llm.token_count.completion_details.reasoning, | ||
llm.token_count.completion_details.audio. All values should be in tokens | ||
(integer count of tokens). | ||
""" | ||
|
||
LLM_COST_PROMPT = "llm.cost.prompt" | ||
""" | ||
Total cost of all input tokens sent to the LLM in USD. This includes all tokens that were | ||
processed as part of the prompt, including system messages, user messages, and any other input. | ||
""" | ||
LLM_COST_COMPLETION = "llm.cost.completion" | ||
""" | ||
Total cost of all output tokens generated by the LLM in USD. This includes all tokens that were | ||
generated in response to the prompt, including the main response and any additional output. | ||
""" | ||
LLM_COST_COMPLETION_DETAILS = "llm.cost.completion_details" | ||
LLM_COST_TOTAL = "llm.cost.total" | ||
""" | ||
Key prefix for additional completion cost details. Each detail should be a separate attribute | ||
with this prefix, e.g. llm.cost.completion_details.reasoning, | ||
llm.cost.completion_details.audio. All values should be in USD. | ||
Total cost of the LLM call in USD (prompt + completion). | ||
""" | ||
LLM_COST_COMPLETION_DETAILS_AUDIO = "llm.cost.completion_details.audio" | ||
LLM_COST_INPUT = "llm.cost.input" | ||
""" | ||
Cost of audio tokens in the completion in USD. | ||
Total cost of input tokens in USD. This represents the cost of tokens that were used as | ||
input to the model, which may be different from the prompt cost if there are additional | ||
processing steps. | ||
""" | ||
LLM_COST_COMPLETION_DETAILS_OUTPUT = "llm.cost.completion_details.output" | ||
LLM_COST_OUTPUT = "llm.cost.output" | ||
""" | ||
Total cost of output tokens in USD. This represents the cost of tokens that were generated | ||
as output by the model, which may be different from the completion cost if there are | ||
|
@@ -138,42 +161,62 @@ class SpanAttributes: | |
""" | ||
Cost of reasoning steps in the completion in USD. | ||
""" | ||
LLM_COST_PROMPT = "llm.cost.prompt" | ||
""" | ||
Total cost of all input tokens sent to the LLM in USD. This includes all tokens that were | ||
processed as part of the prompt, including system messages, user messages, and any other input. | ||
""" | ||
LLM_COST_PROMPT_DETAILS = "llm.cost.prompt_details" | ||
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. same comments here about |
||
LLM_COST_COMPLETION_DETAILS_AUDIO = "llm.cost.completion_details.audio" | ||
""" | ||
Key prefix for additional prompt cost details. Each detail should be a separate attribute | ||
with this prefix, e.g. llm.cost.prompt_details.reasoning, | ||
llm.cost.prompt_details.audio. All values should be in USD. | ||
Cost of audio tokens in the completion in USD. | ||
""" | ||
LLM_COST_PROMPT_DETAILS_AUDIO = "llm.cost.prompt_details.audio" | ||
LLM_COST_COMPLETION_DETAILS_IMAGE = "llm.cost.completion_details.image" | ||
""" | ||
Cost of audio tokens in the prompt in USD. | ||
Cost of image tokens in the completion in USD. | ||
""" | ||
LLM_COST_PROMPT_DETAILS_CACHE_INPUT = "llm.cost.prompt_details.cache_input" | ||
LLM_COST_PROMPT_DETAILS_CACHE_WRITE = "llm.cost.prompt_details.cache_write" | ||
""" | ||
Cost of input tokens in the prompt that were cached in USD. | ||
Cost of prompt tokens written to cache in USD. | ||
""" | ||
LLM_COST_PROMPT_DETAILS_CACHE_READ = "llm.cost.prompt_details.cache_read" | ||
""" | ||
Cost of prompt tokens read from cache in USD. | ||
""" | ||
LLM_COST_PROMPT_DETAILS_CACHE_WRITE = "llm.cost.prompt_details.cache_write" | ||
""" | ||
Cost of prompt tokens written to cache in USD. | ||
LLM_COST_PROMPT_DETAILS_CACHE_INPUT = "llm.cost.prompt_details.cache_input" | ||
""" | ||
LLM_COST_PROMPT_DETAILS_INPUT = "llm.cost.prompt_details.input" | ||
Cost of input tokens in the prompt that were cached in USD. | ||
""" | ||
Total cost of input tokens in USD. This represents the cost of tokens that were used as | ||
input to the model, which may be different from the prompt cost if there are additional | ||
processing steps. | ||
LLM_COST_PROMPT_DETAILS_AUDIO = "llm.cost.prompt_details.audio" | ||
""" | ||
LLM_COST_TOTAL = "llm.cost.total" | ||
Cost of audio tokens in the prompt in USD. | ||
""" | ||
Total cost of the LLM call in USD (prompt + completion). | ||
LLM_COST_PROMPT_DETAILS_IMAGE = "llm.cost.prompt_details.image" | ||
""" | ||
Cost of image tokens in the prompt in USD. | ||
""" | ||
|
||
LLM_COST = "llm.cost" | ||
""" | ||
Key prefix for cost information. When these keys are transformed into a JSON-like structure, | ||
it would look like: | ||
{ | ||
"prompt": 0.0021, # Cost in USD | ||
"completion": 0.0045, # Cost in USD | ||
"total": 0.0066, # Cost in USD | ||
"input": 0.0003, # Cost in USD | ||
"output": 0.0009, # Cost in USD | ||
"completion_details": { | ||
"reasoning": 0.0024, # Cost in USD (e.g., 80 tokens * $0.03/1K tokens) | ||
"audio": 0.0012, # Cost in USD (e.g., 40 tokens * $0.03/1K tokens) | ||
"image": 0.0018 # Cost in USD (e.g., 60 tokens * $0.03/1K tokens) | ||
}, | ||
"prompt_details": { | ||
"cache_write": 0.0006, # Cost in USD (e.g., 20 tokens * $0.03/1K tokens) | ||
"cache_read": 0.0003, # Cost in USD (e.g., 10 tokens * $0.03/1K tokens) | ||
"cache_input": 0.0006, # Cost in USD (e.g., 20 tokens * $0.03/1K tokens) | ||
"audio": 0.0003, # Cost in USD (e.g., 10 tokens * $0.03/1K tokens) | ||
"image": 0.0009 # Cost in USD (e.g., 30 tokens * $0.03/1K tokens) | ||
} | ||
} | ||
Note: This is a key prefix - individual attributes are stored as separate span attributes | ||
with this prefix, e.g. llm.cost.prompt, llm.cost.completion_details.reasoning, etc. | ||
The JSON structure shown above represents how these separate attributes can be conceptually | ||
organized. All monetary values are in USD with floating point precision. | ||
""" | ||
|
||
LLM_TOOLS = "llm.tools" | ||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Is removing or renaming
LLM_COST_COMPLETION_DETAILS
intentional?if so, tests in
test_attributes.py
should be updated to reflect this change otherwise CI wouldn't passThere 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.
Must have accidentally deleted these, I have added them back