11using System . Text ;
22using Cellm . AddIn . UserInterface . Forms ;
3+ using Cellm . Models . Prompts ;
34using Cellm . Models . Providers ;
45using Cellm . Models . Providers . Anthropic ;
56using Cellm . Models . Providers . Aws ;
@@ -25,6 +26,7 @@ public partial class RibbonMain
2526 private enum ModelGroupControlIds
2627 {
2728 VerticalContainer ,
29+ HorizontalContainer ,
2830
2931 ModelProviderGroup ,
3032 ProviderModelBox ,
@@ -34,6 +36,12 @@ private enum ModelGroupControlIds
3436
3537 ModelComboBox ,
3638 TemperatureComboBox ,
39+
40+ OutputCell ,
41+ OutputRow ,
42+ OutputTable ,
43+ OutputColumn ,
44+
3745 CacheToggleButton ,
3846
3947 ProviderSettingsButton
@@ -155,11 +163,41 @@ public string ModelGroup()
155163 getItemLabel="{ nameof ( GetTemperatureItemLabel ) } "
156164 />
157165 </box>
166+ <box id="{ nameof ( ModelGroupControlIds . HorizontalContainer ) } " boxStyle="horizontal">
167+ <buttonGroup id="SelectionButtonGroup">
168+ <toggleButton id="{ nameof ( ModelGroupControlIds . OutputCell ) } "
169+ imageMso="TableSelectCell"
170+ getPressed="{ nameof ( GetOutputCellPressed ) } "
171+ onAction="{ nameof ( OnOutputCellClicked ) } "
172+ screentip="Output response in a single cell (default)" />
173+ <toggleButton id="{ nameof ( ModelGroupControlIds . OutputRow ) } "
174+ imageMso="TableRowSelect"
175+ getPressed="{ nameof ( GetOutputRowPressed ) } "
176+ onAction="{ nameof ( OnOutputRowClicked ) } "
177+ screentip="Respond with row"
178+ supertip="Spill multiple response values (if any) across cells to the right." />
179+ <toggleButton id="{ nameof ( ModelGroupControlIds . OutputTable ) } "
180+ imageMso="TableSelect"
181+ getPressed="{ nameof ( GetOutputTablePressed ) } "
182+ onAction="{ nameof ( OnOutputTableClicked ) } "
183+ screentip="Respond with table"
184+ supertip="Let model decide how to output multiple values (as single cell, row, column, or table, just tell it what you want)" />
185+ <toggleButton id="{ nameof ( ModelGroupControlIds . OutputColumn ) } "
186+ imageMso="TableColumnSelect"
187+ getPressed="{ nameof ( GetOutputColumnPressed ) } "
188+ onAction="{ nameof ( OnOutputColumnClicked ) } "
189+ screentip="Respond with column"
190+ supertip="Spill multiple response values (if any) across cells below" />
191+ </buttonGroup>
192+ </box>
158193 </box>
159194 <separator id="cacheSeparator" />
160- <toggleButton id="{ nameof ( ModelGroupControlIds . CacheToggleButton ) } " label="Cache" size="large" imageMso="SourceControlRefreshStatus"
195+ <toggleButton id="{ nameof ( ModelGroupControlIds . CacheToggleButton ) } "
196+ label="Memory On" size="large"
197+ imageMso="SourceControlRefreshStatus"
161198 screentip="Enable/disable local caching of model responses. Enabled: Return cached responses for identical prompts. Disabled: Always request new responses. Disabling cache will clear entries."
162- onAction="{ nameof ( OnCacheToggled ) } " getPressed="{ nameof ( GetCachePressed ) } " />
199+ onAction="{ nameof ( OnCacheToggled ) } "
200+ getPressed="{ nameof ( GetCachePressed ) } " />
163201 </group>
164202 """ ;
165203 }
@@ -809,4 +847,81 @@ public string GetTemperatureItemLabel(IRibbonControl control, int index)
809847 _logger . LogWarning ( "Invalid index {index} requested for GetTemperatureItemLabel" , index ) ;
810848 return string . Empty ;
811849 }
850+
851+ public void OnOutputCellClicked ( IRibbonControl control , bool isPressed )
852+ {
853+ // Default, cannot toggle off via this button
854+ SetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( StructuredOutputShape ) } ", StructuredOutputShape . None . ToString ( ) ) ;
855+ InvalidateOutputToggleButtons ( ) ;
856+ }
857+
858+ public void OnOutputRowClicked ( IRibbonControl control , bool isPressed )
859+ {
860+ if ( isPressed )
861+ {
862+ SetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( StructuredOutputShape ) } ", StructuredOutputShape . Row . ToString ( ) ) ;
863+ InvalidateOutputToggleButtons ( ) ;
864+ }
865+ else
866+ {
867+ SetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( StructuredOutputShape ) } ", StructuredOutputShape . None . ToString ( ) ) ;
868+ InvalidateOutputToggleButtons ( ) ;
869+ }
870+ }
871+
872+ public void OnOutputTableClicked ( IRibbonControl control , bool isPressed )
873+ {
874+ if ( isPressed )
875+ {
876+ SetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( StructuredOutputShape ) } ", StructuredOutputShape . Table . ToString ( ) ) ;
877+ InvalidateOutputToggleButtons ( ) ;
878+ }
879+ else
880+ {
881+ SetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( StructuredOutputShape ) } ", StructuredOutputShape . None . ToString ( ) ) ;
882+ InvalidateOutputToggleButtons ( ) ;
883+ }
884+ }
885+
886+ public void OnOutputColumnClicked ( IRibbonControl control , bool isPressed )
887+ {
888+ if ( isPressed )
889+ {
890+ SetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( StructuredOutputShape ) } ", StructuredOutputShape . Column . ToString ( ) ) ;
891+ InvalidateOutputToggleButtons ( ) ;
892+ }
893+ else
894+ {
895+ SetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( StructuredOutputShape ) } ", StructuredOutputShape . None . ToString ( ) ) ;
896+ InvalidateOutputToggleButtons ( ) ;
897+ }
898+ }
899+
900+ public bool GetOutputCellPressed ( IRibbonControl control )
901+ {
902+ return GetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( CellmAddInConfiguration . StructuredOutputShape ) } ") == StructuredOutputShape . None . ToString ( ) ;
903+ }
904+
905+ public bool GetOutputRowPressed ( IRibbonControl control )
906+ {
907+ return GetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( CellmAddInConfiguration . StructuredOutputShape ) } ") == StructuredOutputShape . Row . ToString ( ) ;
908+ }
909+
910+ public bool GetOutputTablePressed ( IRibbonControl control )
911+ {
912+ return GetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( CellmAddInConfiguration . StructuredOutputShape ) } ") == StructuredOutputShape . Table . ToString ( ) ;
913+ }
914+
915+ public bool GetOutputColumnPressed ( IRibbonControl control )
916+ {
917+ return GetValue ( $ "{ nameof ( CellmAddInConfiguration ) } :{ nameof ( CellmAddInConfiguration . StructuredOutputShape ) } ") == StructuredOutputShape . Column . ToString ( ) ;
918+ }
919+
920+ private void InvalidateOutputToggleButtons ( )
921+ {
922+ _ribbonUi ? . InvalidateControl ( nameof ( ModelGroupControlIds . OutputCell ) ) ;
923+ _ribbonUi ? . InvalidateControl ( nameof ( ModelGroupControlIds . OutputRow ) ) ;
924+ _ribbonUi ? . InvalidateControl ( nameof ( ModelGroupControlIds . OutputTable ) ) ;
925+ _ribbonUi ? . InvalidateControl ( nameof ( ModelGroupControlIds . OutputColumn ) ) ;
926+ }
812927}
0 commit comments