Skip to content

Commit e9418da

Browse files
committed
pr comments
1 parent 6b09627 commit e9418da

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

src/judgeval/tracer/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from judgeval.utils.serialize import safe_serialize
5151
from judgeval.version import get_version
5252
from judgeval.warnings import JudgmentWarning
53+
from judgeval.exceptions import JudgmentRuntimeError
5354

5455
from judgeval.tracer.exporters import JudgmentSpanExporter
5556
from judgeval.tracer.keys import AttributeKeys, ResourceKeys
@@ -490,7 +491,7 @@ def _create_agent_context(args) -> Token:
490491

491492
if identifier:
492493
if not class_name or not instance or not isinstance(instance, object):
493-
raise Exception(
494+
raise JudgmentRuntimeError(
494495
"'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."
495496
)
496497
if (
@@ -501,7 +502,7 @@ def _create_agent_context(args) -> Token:
501502
instance_name = str(getattr(instance, identifier))
502503
agent_context["instance_name"] = instance_name
503504
else:
504-
raise Exception(
505+
raise JudgmentRuntimeError(
505506
f"Attribute {identifier} does not exist for {class_name}. Check your agent() decorator."
506507
)
507508

src/judgeval/tracer/keys.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class AttributeKeys:
3838
GEN_AI_RESPONSE_FINISH_REASONS = gen_ai_attributes.GEN_AI_RESPONSE_FINISH_REASONS
3939

4040
# GenAI-specific attributes (custom namespace)
41-
GEN_AI_USAGE_TOTAL_TOKENS = "gen_ai.usage.total_tokens"
4241
GEN_AI_USAGE_TOTAL_COST = "gen_ai.usage.total_cost"
4342

4443

src/judgeval/tracer/llm/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ def wrapper(*args, **kwargs):
7676
AttributeKeys.GEN_AI_USAGE_COMPLETION_TOKENS,
7777
usage.completion_tokens,
7878
)
79-
if usage.total_tokens:
80-
span.set_attribute(
81-
AttributeKeys.GEN_AI_USAGE_TOTAL_TOKENS,
82-
usage.total_tokens,
83-
)
8479
if usage.total_cost_usd:
8580
span.set_attribute(
8681
AttributeKeys.GEN_AI_USAGE_TOTAL_COST,
@@ -123,11 +118,6 @@ async def wrapper(*args, **kwargs):
123118
AttributeKeys.GEN_AI_USAGE_COMPLETION_TOKENS,
124119
usage.completion_tokens,
125120
)
126-
if usage.total_tokens:
127-
span.set_attribute(
128-
AttributeKeys.GEN_AI_USAGE_TOTAL_TOKENS,
129-
usage.total_tokens,
130-
)
131121
if usage.total_cost_usd:
132122
span.set_attribute(
133123
AttributeKeys.GEN_AI_USAGE_TOTAL_COST,

0 commit comments

Comments
 (0)