@@ -233,26 +233,22 @@ private static void ProcessCommandModelAttributes(Activity activity, Dictionary<
233233 }
234234
235235 // input tokens not provided in Command response body, so we estimate the value based on input length
236- if ( jsonBody . TryGetValue ( "prompt " , out var input ) )
236+ if ( jsonBody . TryGetValue ( "message " , out var input ) )
237237 {
238238 activity . SetTag ( AWSSemanticConventions . AttributeGenAiInputTokens , Math . Ceiling ( ( double ) input . GetString ( ) . Length / 6 ) ) ;
239239 }
240240 }
241241 else
242242 {
243- if ( jsonBody . TryGetValue ( "generations " , out var generationsArray ) )
243+ if ( jsonBody . TryGetValue ( "finish_reason " , out var finishReasons ) )
244244 {
245- var generation = generationsArray [ 0 ] ;
246- if ( generation . TryGetProperty ( "finish_reason" , out var finishReasons ) )
247- {
248- activity . SetTag ( AWSSemanticConventions . AttributeGenAiFinishReasons , new string [ ] { finishReasons . GetString ( ) } ) ;
249- }
245+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiFinishReasons , new string [ ] { finishReasons . GetString ( ) } ) ;
246+ }
250247
251- // completion tokens not provided in Command response body, so we estimate the value based on output length
252- if ( generation . TryGetProperty ( "text" , out var output ) )
253- {
254- activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Math . Ceiling ( ( double ) output . GetString ( ) . Length / 6 ) ) ;
255- }
248+ // completion tokens not provided in Command response body, so we estimate the value based on output length
249+ if ( jsonBody . TryGetValue ( "text" , out var output ) )
250+ {
251+ activity . SetTag ( AWSSemanticConventions . AttributeGenAiOutputTokens , Math . Ceiling ( ( double ) output . GetString ( ) . Length / 6 ) ) ;
256252 }
257253 }
258254 }
0 commit comments