@@ -449,6 +449,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
449449 {
450450 entity : AiAssistance . ChatMessageEntity . USER ,
451451 text : 'test' ,
452+ imageInput : undefined ,
452453 } ,
453454 {
454455 answer : 'test' ,
@@ -484,6 +485,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
484485 {
485486 entity : AiAssistance . ChatMessageEntity . USER ,
486487 text : 'test' ,
488+ imageInput : undefined ,
487489 } ,
488490 {
489491 answer : 'test' ,
@@ -520,6 +522,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
520522 {
521523 entity : AiAssistance . ChatMessageEntity . USER ,
522524 text : 'test' ,
525+ imageInput : undefined ,
523526 } ,
524527 {
525528 answer : 'test' ,
@@ -556,6 +559,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
556559 {
557560 entity : AiAssistance . ChatMessageEntity . USER ,
558561 text : 'test' ,
562+ imageInput : undefined ,
559563 } ,
560564 {
561565 answer : 'test' ,
@@ -573,15 +577,23 @@ describeWithMockConnection('AI Assistance Panel', () => {
573577 } ) ;
574578
575579 it ( 'should switch agents and restore history' , async ( ) => {
580+ Object . assign ( Root . Runtime . hostConfig , {
581+ devToolsFreestyler : {
582+ enabled : true ,
583+ multimodal : true ,
584+ } ,
585+ } ) ;
576586 const { view, panel} =
577587 createAiAssistancePanel ( { aidaClient : mockAidaClient ( [ [ { explanation : 'test' } ] , [ { explanation : 'test2' } ] ] ) } ) ;
578588 panel . handleAction ( 'freestyler.elements-floating-button' ) ;
579- view . lastCall . args [ 0 ] . onTextSubmit ( 'User question to Freestyler?' ) ;
589+ const imageInput = { inlineData : { data : 'imageinputbytes' , mimeType : 'image/jpeg' } } ;
590+ view . lastCall . args [ 0 ] . onTextSubmit ( 'User question to Freestyler?' , imageInput ) ;
580591 await drainMicroTasks ( ) ;
581592 assert . deepEqual ( view . lastCall . args [ 0 ] . messages , [
582593 {
583594 entity : AiAssistance . ChatMessageEntity . USER ,
584595 text : 'User question to Freestyler?' ,
596+ imageInput,
585597 } ,
586598 {
587599 answer : 'test' ,
@@ -599,6 +611,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
599611 {
600612 entity : AiAssistance . ChatMessageEntity . USER ,
601613 text : 'User question to DrJones?' ,
614+ imageInput : undefined ,
602615 } ,
603616 {
604617 answer : 'test2' ,
@@ -619,10 +632,12 @@ describeWithMockConnection('AI Assistance Panel', () => {
619632 contextMenu . invokeHandler ( freestylerEntry . id ( ) ) ;
620633
621634 await drainMicroTasks ( ) ;
635+ // Currently history should not store image input
622636 assert . deepEqual ( view . lastCall . args [ 0 ] . messages , [
623637 {
624638 entity : AiAssistance . ChatMessageEntity . USER ,
625639 text : 'User question to Freestyler?' ,
640+ imageInput : undefined ,
626641 } ,
627642 {
628643 answer : 'test' ,
@@ -645,6 +660,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
645660 {
646661 entity : AiAssistance . ChatMessageEntity . USER ,
647662 text : 'test' ,
663+ imageInput : undefined ,
648664 } ,
649665 {
650666 answer : 'test' ,
@@ -678,6 +694,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
678694 {
679695 entity : AiAssistance . ChatMessageEntity . USER ,
680696 text : 'test' ,
697+ imageInput : undefined ,
681698 } ,
682699 {
683700 answer : 'test' ,
@@ -704,6 +721,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
704721 {
705722 entity : AiAssistance . ChatMessageEntity . USER ,
706723 text : 'User question to Freestyler?' ,
724+ imageInput : undefined ,
707725 } ,
708726 {
709727 answer : 'test' ,
@@ -721,6 +739,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
721739 {
722740 entity : AiAssistance . ChatMessageEntity . USER ,
723741 text : 'User question to DrJones?' ,
742+ imageInput : undefined ,
724743 } ,
725744 {
726745 answer : 'test2' ,
@@ -816,6 +835,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
816835 {
817836 entity : AiAssistance . ChatMessageEntity . USER ,
818837 text : 'test' ,
838+ imageInput : undefined ,
819839 } ,
820840 {
821841 answer : 'test' ,
@@ -839,6 +859,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
839859 {
840860 entity : AiAssistance . ChatMessageEntity . USER ,
841861 text : 'test' ,
862+ imageInput : undefined ,
842863 } ,
843864 {
844865 answer : 'test' ,
@@ -850,6 +871,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
850871 {
851872 entity : AiAssistance . ChatMessageEntity . USER ,
852873 text : 'test2' ,
874+ imageInput : undefined ,
853875 } ,
854876 {
855877 answer : 'test2' ,
@@ -1083,6 +1105,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
10831105 {
10841106 entity : AiAssistance . ChatMessageEntity . USER ,
10851107 text : 'test' ,
1108+ imageInput : undefined ,
10861109 } ,
10871110 {
10881111 answer : undefined ,
@@ -1151,5 +1174,40 @@ describeWithMockConnection('AI Assistance Panel', () => {
11511174
11521175 assert . isEmpty ( view . lastCall . args [ 0 ] . imageInput ) ;
11531176 } ) ;
1177+
1178+ it ( 'sends image as input' , async ( ) => {
1179+ Object . assign ( Root . Runtime . hostConfig , {
1180+ devToolsFreestyler : {
1181+ enabled : true ,
1182+ multimodal : true ,
1183+ } ,
1184+ } ) ;
1185+ UI . Context . Context . instance ( ) . setFlavor (
1186+ ElementsPanel . ElementsPanel . ElementsPanel ,
1187+ sinon . createStubInstance ( ElementsPanel . ElementsPanel . ElementsPanel ) ) ;
1188+ const {
1189+ view,
1190+ } = createAiAssistancePanel ( { aidaClient : mockAidaClient ( [ [ { explanation : 'test' } ] ] ) } ) ;
1191+
1192+ assert . isTrue ( view . lastCall . args [ 0 ] . multimodalInputEnabled ) ;
1193+
1194+ view . lastCall . args [ 0 ] . onTextSubmit ( 'test' , { inlineData : { data : 'imageInput' , mimeType : 'image/jpeg' } } ) ;
1195+ await drainMicroTasks ( ) ;
1196+
1197+ assert . deepEqual ( view . lastCall . args [ 0 ] . messages , [
1198+ {
1199+ entity : AiAssistance . ChatMessageEntity . USER ,
1200+ text : 'test' ,
1201+ imageInput : { inlineData : { data : 'imageInput' , mimeType : 'image/jpeg' } }
1202+ } ,
1203+ {
1204+ answer : 'test' ,
1205+ entity : AiAssistance . ChatMessageEntity . MODEL ,
1206+ rpcId : undefined ,
1207+ suggestions : undefined ,
1208+ steps : [ ] ,
1209+ } ,
1210+ ] ) ;
1211+ } ) ;
11541212 } ) ;
11551213} ) ;
0 commit comments