File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,14 @@ const executeSage = async function(interaction){
3030
3131 return client . askSage ( code )
3232 . then ( res => {
33- embed . description = "Input:\n```py\n" + code + "\n```\nOutput:\n```\n" + ( res ?. result ?. [ "text/plain" ] ?. trim ( ) || res ?. stdout ?. trim ( ) || "No Output" ) + "\n```" ;
33+ embed . description = "Input:\n```py\n" + code + "\n```\nOutput:\n```\n" + (
34+ res ?. result ?. [ "text/plain" ] ?. trim ( ) || res ?. stdout ?. trim ( ) || ( res . result ?. image ? "Image Below" : "No Output" )
35+ ) + "\n```" ;
36+
37+ if ( res ?. result ?. image ) { // @ts -ignore
38+ embed . image = { url : res . result . image } ;
39+ }
40+
3441 return interaction . editReply ( { embeds : [ embed ] } ) ;
3542 } )
3643 . catch ( ( ) => {
Original file line number Diff line number Diff line change @@ -187,6 +187,11 @@ export default class SageCell {
187187 result = msg . content ?. data ?? null ;
188188 }
189189
190+ if ( msgType === "display_data" ) {
191+ const filename = msg . content ?. data ?. [ "text/image-filename" ] ;
192+ result = filename ? { image : `${ this . baseUrl } /kernel/${ kernelId } /files/${ filename } ` } : msg . content ?. data ?? null ;
193+ }
194+
190195 if ( msgType === "status" &&
191196 msg . content ?. execution_state === "idle" ) {
192197 finish ( { stdout, stderr, result } ) ;
You can’t perform that action at this time.
0 commit comments