@@ -471,7 +471,10 @@ def traced_method(wrapped, instance, args, kwargs):
471471 attributes = LLMSpanAttributes (** span_attributes )
472472
473473 tools = []
474- if kwargs .get ("temperature" ) is not None and kwargs .get ("temperature" ) != NOT_GIVEN :
474+ if (
475+ kwargs .get ("temperature" ) is not None
476+ and kwargs .get ("temperature" ) != NOT_GIVEN
477+ ):
475478 attributes .llm_temperature = kwargs .get ("temperature" )
476479 if kwargs .get ("top_p" ) is not None and kwargs .get ("top_p" ) != NOT_GIVEN :
477480 attributes .llm_top_p = kwargs .get ("top_p" )
@@ -499,7 +502,11 @@ def traced_method(wrapped, instance, args, kwargs):
499502 try :
500503 # Attempt to call the original method
501504 result = wrapped (* args , ** kwargs )
502- if kwargs .get ("stream" ) is False or kwargs .get ("stream" ) is None or kwargs .get ("stream" ) == NOT_GIVEN :
505+ if (
506+ kwargs .get ("stream" ) is False
507+ or kwargs .get ("stream" ) is None
508+ or kwargs .get ("stream" ) == NOT_GIVEN
509+ ):
503510 span .set_attribute ("llm.model" , result .model )
504511 if hasattr (result , "choices" ) and result .choices is not None :
505512 responses = [
@@ -528,7 +535,8 @@ def traced_method(wrapped, instance, args, kwargs):
528535 span .set_attribute ("llm.responses" , json .dumps (responses ))
529536 if (
530537 hasattr (result , "system_fingerprint" )
531- and result .system_fingerprint is not None and result .system_fingerprint != NOT_GIVEN
538+ and result .system_fingerprint is not None
539+ and result .system_fingerprint != NOT_GIVEN
532540 ):
533541 span .set_attribute (
534542 "llm.system.fingerprint" , result .system_fingerprint
@@ -555,7 +563,10 @@ def traced_method(wrapped, instance, args, kwargs):
555563 )
556564
557565 # iterate over kwargs.get("functions") and calculate the prompt tokens
558- if kwargs .get ("functions" ) is not None and kwargs .get ("functions" ) != NOT_GIVEN :
566+ if (
567+ kwargs .get ("functions" ) is not None
568+ and kwargs .get ("functions" ) != NOT_GIVEN
569+ ):
559570 for function in kwargs .get ("functions" ):
560571 prompt_tokens += calculate_prompt_tokens (
561572 json .dumps (function ), kwargs .get ("model" )
@@ -641,7 +652,10 @@ async def traced_method(wrapped, instance, args, kwargs):
641652 attributes = LLMSpanAttributes (** span_attributes )
642653
643654 tools = []
644- if kwargs .get ("temperature" ) is not None and kwargs .get ("temperature" ) != NOT_GIVEN :
655+ if (
656+ kwargs .get ("temperature" ) is not None
657+ and kwargs .get ("temperature" ) != NOT_GIVEN
658+ ):
645659 attributes .llm_temperature = kwargs .get ("temperature" )
646660 if kwargs .get ("top_p" ) is not None and kwargs .get ("top_p" ) != NOT_GIVEN :
647661 attributes .llm_top_p = kwargs .get ("top_p" )
@@ -667,7 +681,11 @@ async def traced_method(wrapped, instance, args, kwargs):
667681 try :
668682 # Attempt to call the original method
669683 result = await wrapped (* args , ** kwargs )
670- if kwargs .get ("stream" ) is False or kwargs .get ("stream" ) is None or kwargs .get ("stream" ) == NOT_GIVEN :
684+ if (
685+ kwargs .get ("stream" ) is False
686+ or kwargs .get ("stream" ) is None
687+ or kwargs .get ("stream" ) == NOT_GIVEN
688+ ):
671689 span .set_attribute ("llm.model" , result .model )
672690 if hasattr (result , "choices" ) and result .choices is not None :
673691 responses = [
@@ -696,7 +714,8 @@ async def traced_method(wrapped, instance, args, kwargs):
696714 span .set_attribute ("llm.responses" , json .dumps (responses ))
697715 if (
698716 hasattr (result , "system_fingerprint" )
699- and result .system_fingerprint is not None and result .system_fingerprint != NOT_GIVEN
717+ and result .system_fingerprint is not None
718+ and result .system_fingerprint != NOT_GIVEN
700719 ):
701720 span .set_attribute (
702721 "llm.system.fingerprint" , result .system_fingerprint
@@ -723,7 +742,10 @@ async def traced_method(wrapped, instance, args, kwargs):
723742 )
724743
725744 # iterate over kwargs.get("functions") and calculate the prompt tokens
726- if kwargs .get ("functions" ) is not None and kwargs .get ("functions" ) != NOT_GIVEN :
745+ if (
746+ kwargs .get ("functions" ) is not None
747+ and kwargs .get ("functions" ) != NOT_GIVEN
748+ ):
727749 for function in kwargs .get ("functions" ):
728750 prompt_tokens += calculate_prompt_tokens (
729751 json .dumps (function ), kwargs .get ("model" )
0 commit comments