@@ -110,11 +110,15 @@ export class JupyterNotebookExporter {
110110 return ;
111111 }
112112
113- cells . push ( new NotebookCellData ( NotebookCellKind . Markup , parameters . reason , 'markdown' ) ) ;
114- const codeCell = new NotebookCellData ( NotebookCellKind . Code , parameters . code , 'python' ) ;
115- const outputs : NotebookCellOutput [ ] = [ ]
116- codeCell . outputs = outputs ;
117- cells . push ( codeCell ) ;
113+ if ( parameters . reason ) {
114+ cells . push ( new NotebookCellData ( NotebookCellKind . Markup , parameters . reason , 'markdown' ) ) ;
115+ }
116+ if ( parameters . code ) {
117+ const codeCell = new NotebookCellData ( NotebookCellKind . Code , parameters . code , 'python' ) ;
118+ const outputs : NotebookCellOutput [ ] = [ ]
119+ codeCell . outputs = outputs ;
120+ cells . push ( codeCell ) ;
121+ }
118122
119123 // result.content.forEach((output) =>{
120124 // if (isTextPart(output) && output.value){
@@ -145,13 +149,15 @@ export class JupyterNotebookExporter {
145149 const resultCells = new Map < number , NotebookCellData > ( ) ;
146150 await Promise . all ( response . response . filter ( r => r instanceof ChatResponseMarkdownPart ) . map ( async ( r , i ) => {
147151 const { markdown, attachments } = await createAttachments ( r . value . value ) ;
148- const cell = new NotebookCellData ( NotebookCellKind . Markup , markdown , 'markdown' ) ;
149- if ( attachments ) {
150- cell . metadata = {
151- attachments
152+ if ( markdown ) {
153+ const cell = new NotebookCellData ( NotebookCellKind . Markup , markdown , 'markdown' ) ;
154+ if ( attachments ) {
155+ cell . metadata = {
156+ attachments
157+ }
152158 }
159+ resultCells . set ( i , cell ) ;
153160 }
154- resultCells . set ( i , cell ) ;
155161 } ) ) ;
156162 Array . from ( resultCells . values ( ) ) . forEach ( cell => cells . push ( cell ) ) ;
157163 }
0 commit comments