@@ -5,6 +5,13 @@ import { customElement, property, state } from 'lit/decorators.js';
55import { ParsedMessage } from '../message-parser' ;
66import aiSvg from '../../assets/icons/ai.svg?raw' ;
77
8+ export type IntermediateStep = {
9+ type : 'tool' | 'llm' ;
10+ name : string ;
11+ input ?: string ;
12+ output ?: string ;
13+ }
14+
815@customElement ( 'azc-debug' )
916export class DebugComponent extends LitElement {
1017 @property ( { type : Object } ) message : ParsedMessage | undefined ;
@@ -33,15 +40,12 @@ export class DebugComponent extends LitElement {
3340 }
3441 }
3542
36- protected getStepType ( step : any ) : 'tool' | 'llm' {
37- return step . action ?. tool ? 'tool' : 'llm' ;
43+ protected getStepType ( step : IntermediateStep ) : 'tool' | 'llm' {
44+ return step . type ;
3845 }
3946
40- protected getStepSummary ( step : any ) : string {
41- if ( step . action ?. tool ) {
42- return `Tool: ${ step . action . tool } ` ;
43- }
44- return 'LLM call' ;
47+ protected getStepSummary ( step : IntermediateStep ) : string {
48+ return step . type === 'tool' ? `Tool: ${ step . name } ` : `LLM: ${ step . name } ` ;
4549 }
4650
4751 protected truncateText ( text : string , maxLength : number = 100 ) : string {
@@ -75,7 +79,7 @@ export class DebugComponent extends LitElement {
7579 ` ;
7680 }
7781
78- protected renderStep ( step : any , index : number ) {
82+ protected renderStep ( step : IntermediateStep , index : number ) {
7983 const stepType = this . getStepType ( step ) ;
8084 const isExpanded = this . expandedSteps . has ( index ) ;
8185 const summary = this . getStepSummary ( step ) ;
@@ -99,14 +103,11 @@ export class DebugComponent extends LitElement {
99103
100104 ${ isExpanded ? html `
101105 <div class= "step-details" >
102- ${ step . action ?. log ? this . renderDetailSection ( 'Log' , step . action . log , index , 'log' ) : nothing }
103-
104- ${ step . action ?. toolInput !== undefined
105- ? this . renderDetailSection ( 'Input' , JSON . stringify ( step . action . toolInput , null , 2 ) , index , 'input' )
106+ ${ step . input !== undefined
107+ ? this . renderDetailSection ( 'Input' , step . input , index , 'input' , step . input . length > 500 )
106108 : nothing }
107-
108- ${ step . observation
109- ? this . renderDetailSection ( 'Output' , step . observation , index , 'output' , step . observation . length > 500 )
109+ ${ step . output !== undefined
110+ ? this . renderDetailSection ( 'Output' , step . output , index , 'output' , step . output . length > 500 )
110111 : nothing }
111112 </ div>
112113 ` : nothing }
@@ -116,7 +117,7 @@ export class DebugComponent extends LitElement {
116117 }
117118
118119 protected override render ( ) {
119- const intermediateSteps = this . message ?. context ?. [ 'intermediateSteps' ] ?? [ ] ;
120+ const intermediateSteps : IntermediateStep [ ] = ( this . message ?. context ?. [ 'intermediateSteps' ] as IntermediateStep [ ] | undefined ) ?? [ ] ;
120121 return intermediateSteps . length === 0 ? nothing : html `
121122 <div class= "debug-container" >
122123 <butto n
@@ -135,7 +136,7 @@ export class DebugComponent extends LitElement {
135136 ${ repeat (
136137 intermediateSteps ,
137138 ( _ , index ) => index ,
138- ( step , index ) => this . renderStep ( step , index )
139+ ( step , index ) => this . renderStep ( step as IntermediateStep , index )
139140 ) }
140141 </ div>
141142 ` : nothing }
0 commit comments