File tree Expand file tree Collapse file tree 3 files changed +3
-13
lines changed Expand file tree Collapse file tree 3 files changed +3
-13
lines changed Original file line number Diff line number Diff line change 50
50
from judgeval .utils .serialize import safe_serialize
51
51
from judgeval .version import get_version
52
52
from judgeval .warnings import JudgmentWarning
53
+ from judgeval .exceptions import JudgmentRuntimeError
53
54
54
55
from judgeval .tracer .exporters import JudgmentSpanExporter
55
56
from judgeval .tracer .keys import AttributeKeys , ResourceKeys
@@ -490,7 +491,7 @@ def _create_agent_context(args) -> Token:
490
491
491
492
if identifier :
492
493
if not class_name or not instance or not isinstance (instance , object ):
493
- raise Exception (
494
+ raise JudgmentRuntimeError (
494
495
"'identifier' is set but no class name or instance is available. 'identifier' can only be specified when using the agent() decorator on a class method."
495
496
)
496
497
if (
@@ -501,7 +502,7 @@ def _create_agent_context(args) -> Token:
501
502
instance_name = str (getattr (instance , identifier ))
502
503
agent_context ["instance_name" ] = instance_name
503
504
else :
504
- raise Exception (
505
+ raise JudgmentRuntimeError (
505
506
f"Attribute { identifier } does not exist for { class_name } . Check your agent() decorator."
506
507
)
507
508
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ class AttributeKeys:
38
38
GEN_AI_RESPONSE_FINISH_REASONS = gen_ai_attributes .GEN_AI_RESPONSE_FINISH_REASONS
39
39
40
40
# GenAI-specific attributes (custom namespace)
41
- GEN_AI_USAGE_TOTAL_TOKENS = "gen_ai.usage.total_tokens"
42
41
GEN_AI_USAGE_TOTAL_COST = "gen_ai.usage.total_cost"
43
42
44
43
Original file line number Diff line number Diff line change @@ -76,11 +76,6 @@ def wrapper(*args, **kwargs):
76
76
AttributeKeys .GEN_AI_USAGE_COMPLETION_TOKENS ,
77
77
usage .completion_tokens ,
78
78
)
79
- if usage .total_tokens :
80
- span .set_attribute (
81
- AttributeKeys .GEN_AI_USAGE_TOTAL_TOKENS ,
82
- usage .total_tokens ,
83
- )
84
79
if usage .total_cost_usd :
85
80
span .set_attribute (
86
81
AttributeKeys .GEN_AI_USAGE_TOTAL_COST ,
@@ -123,11 +118,6 @@ async def wrapper(*args, **kwargs):
123
118
AttributeKeys .GEN_AI_USAGE_COMPLETION_TOKENS ,
124
119
usage .completion_tokens ,
125
120
)
126
- if usage .total_tokens :
127
- span .set_attribute (
128
- AttributeKeys .GEN_AI_USAGE_TOTAL_TOKENS ,
129
- usage .total_tokens ,
130
- )
131
121
if usage .total_cost_usd :
132
122
span .set_attribute (
133
123
AttributeKeys .GEN_AI_USAGE_TOTAL_COST ,
You can’t perform that action at this time.
0 commit comments