@@ -35,31 +35,34 @@ const transformToStandardFormat = (attributes: any) => {
3535 if ( role && content ) {
3636 inputMessages . push ( {
3737 role,
38- parts : [ { type : "text" , content } ]
38+ parts : [ { type : "text" , content } ] ,
3939 } ) ;
4040 }
4141 i ++ ;
4242 }
4343 if ( inputMessages . length > 0 ) {
44- attributes [ SpanAttributes . LLM_INPUT_MESSAGES ] = JSON . stringify ( inputMessages ) ;
44+ attributes [ SpanAttributes . LLM_INPUT_MESSAGES ] =
45+ JSON . stringify ( inputMessages ) ;
4546 }
4647
4748 // Transform completions to LLM_OUTPUT_MESSAGES
4849 const outputMessages = [ ] ;
4950 let j = 0 ;
5051 while ( attributes [ `${ SpanAttributes . LLM_COMPLETIONS } .${ j } .role` ] ) {
5152 const role = attributes [ `${ SpanAttributes . LLM_COMPLETIONS } .${ j } .role` ] ;
52- const content = attributes [ `${ SpanAttributes . LLM_COMPLETIONS } .${ j } .content` ] ;
53+ const content =
54+ attributes [ `${ SpanAttributes . LLM_COMPLETIONS } .${ j } .content` ] ;
5355 if ( role && content ) {
5456 outputMessages . push ( {
5557 role,
56- parts : [ { type : "text" , content } ]
58+ parts : [ { type : "text" , content } ] ,
5759 } ) ;
5860 }
5961 j ++ ;
6062 }
6163 if ( outputMessages . length > 0 ) {
62- attributes [ SpanAttributes . LLM_OUTPUT_MESSAGES ] = JSON . stringify ( outputMessages ) ;
64+ attributes [ SpanAttributes . LLM_OUTPUT_MESSAGES ] =
65+ JSON . stringify ( outputMessages ) ;
6366 }
6467} ;
6568
@@ -946,7 +949,10 @@ describe("Test OpenAI instrumentation", async function () {
946949 assert . strictEqual ( inputMessages [ 0 ] . role , "user" ) ;
947950 assert . ok ( Array . isArray ( inputMessages [ 0 ] . parts ) ) ;
948951 assert . strictEqual ( inputMessages [ 0 ] . parts [ 0 ] . type , "text" ) ;
949- assert . strictEqual ( inputMessages [ 0 ] . parts [ 0 ] . content , "Tell me a joke about OpenTelemetry" ) ;
952+ assert . strictEqual (
953+ inputMessages [ 0 ] . parts [ 0 ] . content ,
954+ "Tell me a joke about OpenTelemetry" ,
955+ ) ;
950956
951957 // Verify LLM_OUTPUT_MESSAGES attribute exists and is valid JSON
952958 assert . ok ( completionSpan . attributes [ SpanAttributes . LLM_OUTPUT_MESSAGES ] ) ;
0 commit comments