Skip to content

Commit 22aec89

Browse files
committed
handle cache case in autogen
1 parent 4c04d1f commit 22aec89

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/langtrace_python_sdk/instrumentation/autogen/patch.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,16 @@ def traced_method(wrapped, instance, args, kwargs):
9292
set_span_attributes(span, attributes)
9393
set_event_completion(span, [{"role": "assistant", "content": result}])
9494
if llm_config:
95-
total_cost, response_model = list(instance.get_total_usage().keys())
96-
set_span_attribute(
97-
span, SpanAttributes.LLM_RESPONSE_MODEL, response_model
98-
)
99-
set_usage_attributes(
100-
span, instance.get_total_usage().get(response_model)
101-
)
95+
if instance.get_total_usage() is not None:
96+
total_cost, response_model = list(
97+
instance.get_total_usage().keys()
98+
)
99+
set_span_attribute(
100+
span, SpanAttributes.LLM_RESPONSE_MODEL, response_model
101+
)
102+
set_usage_attributes(
103+
span, instance.get_total_usage().get(response_model)
104+
)
102105

103106
return result
104107

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.3.19"
1+
__version__ = "3.3.20"

0 commit comments

Comments
 (0)