-
Couldn't load subscription status.
- Fork 148
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 all commits
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 |
|---|---|---|
|
|
@@ -82,6 +82,10 @@ class SpanAttributes: | |
| """ | ||
| Number of tokens used for reasoning steps 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_PROMPT = "llm.token_count.prompt" | ||
| """ | ||
| Number of tokens in the prompt. | ||
|
|
@@ -108,6 +112,10 @@ class SpanAttributes: | |
| """ | ||
| Number of tokens in the prompt that were written to cache (in tokens). | ||
| """ | ||
| LLM_TOKEN_COUNT_PROMPT_DETAILS_IMAGE = "llm.token_count.prompt_details.image" | ||
| """ | ||
| The number of image tokens in the prompt (in tokens). | ||
| """ | ||
| LLM_TOKEN_COUNT_TOTAL = "llm.token_count.total" | ||
| """ | ||
| Total number of tokens, including both prompt and completion (in tokens). | ||
|
|
@@ -138,10 +146,37 @@ 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_COMPLETION_DETAILS_IMAGE = "llm.cost.completion_details.image" | ||
| """ | ||
| Cost of image tokens in the completion 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_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 |
||
| """ | ||
|
|
@@ -171,6 +206,10 @@ class SpanAttributes: | |
| input to the model, which may be different from the prompt cost if there are additional | ||
| processing steps. | ||
| """ | ||
| LLM_COST_PROMPT_DETAILS_IMAGE = "llm.cost.prompt_details.image" | ||
| """ | ||
| Cost of image tokens in the prompt in USD. | ||
| """ | ||
| LLM_COST_TOTAL = "llm.cost.total" | ||
| """ | ||
| Total cost of the LLM call in USD (prompt + completion). | ||
|
|
||
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
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.
The file is missing a trailing newline character at the end. Adding a newline at the end of files is standard practice for POSIX compliance and helps prevent issues with certain tools and version control systems. Consider adding a newline character to maintain consistency with standard file formatting conventions.
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.