File tree Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Original file line number Diff line number Diff line change 32
32
INPUT_TOKENS_METRIC_KEY = "input_tokens"
33
33
OUTPUT_TOKENS_METRIC_KEY = "output_tokens"
34
34
TOTAL_TOKENS_METRIC_KEY = "total_tokens"
35
- INTEGRATIONS_USING_INPUT_OUTPUT_TOKENS = {"anthropic" }
36
35
37
36
EVP_PROXY_AGENT_BASE_PATH = "evp_proxy/v2"
38
37
EVP_PROXY_AGENT_ENDPOINT = "{}/api/v2/llmobs" .format (EVP_PROXY_AGENT_BASE_PATH )
Original file line number Diff line number Diff line change 4
4
from ddtrace .llmobs ._constants import INPUT_TOKENS_METRIC_KEY
5
5
from ddtrace .llmobs ._constants import OUTPUT_TOKENS_METRIC_KEY
6
6
from ddtrace .llmobs ._constants import TOTAL_TOKENS_METRIC_KEY
7
- from ddtrace .llmobs ._constants import INTEGRATIONS_USING_INPUT_OUTPUT_TOKENS
8
7
from ddtrace .llmobs ._utils import _get_attr
9
8
10
9
@@ -131,13 +130,9 @@ def get_llmobs_metrics_tags(integration_name, span):
131
130
usage [TOTAL_TOKENS_METRIC_KEY ] = input_tokens + output_tokens
132
131
return usage
133
132
134
- prompt_tokens_name = "prompt_tokens"
135
- completion_tokens_name = "completion_tokens"
136
- if integration_name in INTEGRATIONS_USING_INPUT_OUTPUT_TOKENS :
137
- prompt_tokens_name = "input_tokens"
138
- completion_tokens_name = "output_tokens"
139
- input_tokens = span .get_metric ("%s.response.usage.%s" % (integration_name , prompt_tokens_name ))
140
- output_tokens = span .get_metric ("%s.response.usage.%s" % (integration_name , completion_tokens_name ))
133
+ # check for both prompt / completion or input / output tokens
134
+ input_tokens = span .get_metric ("%s.response.usage.prompt_tokens" % integration_name ) or span .get_metric ("%s.response.usage.input_tokens" % integration_name )
135
+ output_tokens = span .get_metric ("%s.response.usage.completion_tokens" % integration_name ) or span .get_metric ("%s.response.usage.output_tokens" % integration_name )
141
136
total_tokens = span .get_metric ("%s.response.usage.total_tokens" % integration_name )
142
137
143
138
if input_tokens is not None :
You can’t perform that action at this time.
0 commit comments