@@ -952,12 +952,11 @@ def _get_span_name(template, name, kwargs=None):
952952
953953 if template == SPANTEMPLATE .AI_CHAT :
954954 model = None
955- if kwargs and "model" in kwargs and isinstance (kwargs ["model" ], str ):
956- model = kwargs ["model" ]
957- elif (
958- kwargs and "model_name" in kwargs and isinstance (kwargs ["model_name" ], str )
959- ):
960- model = kwargs ["model_name" ]
955+ if kwargs :
956+ for key in ("model" , "model_name" ):
957+ if kwargs .get (key ) and isinstance (kwargs [key ], str ):
958+ model = kwargs [key ]
959+ break
961960
962961 span_name = f"chat { model } " if model else "chat"
963962
@@ -998,14 +997,10 @@ def _get_input_attributes(template, send_pii, args, kwargs):
998997
999998 if template in [SPANTEMPLATE .AI_AGENT , SPANTEMPLATE .AI_TOOL , SPANTEMPLATE .AI_CHAT ]:
1000999 for key , value in list (kwargs .items ()):
1001- if key == "model" and isinstance (value , str ):
1002- attributes [SPANDATA .GEN_AI_REQUEST_MODEL ] = value
1003- if key == "model_name" and isinstance (value , str ):
1000+ if key in ("model" , "model_name" ) and isinstance (value , str ):
10041001 attributes [SPANDATA .GEN_AI_REQUEST_MODEL ] = value
10051002
1006- if key == "agent" and isinstance (value , str ):
1007- attributes [SPANDATA .GEN_AI_AGENT_NAME ] = value
1008- if key == "agent_name" and isinstance (value , str ):
1003+ if key in ("agent" , "agent_name" ) and isinstance (value , str ):
10091004 attributes [SPANDATA .GEN_AI_AGENT_NAME ] = value
10101005
10111006 if key == "prompt" and isinstance (value , str ):
0 commit comments