@@ -29,6 +29,8 @@ export interface CreateSlashCommandsOpts {
2929 setModelLoadingProgress : Dispatch < SetStateAction < number | null > > ;
3030 modelLoadingAbortControllerRef : RefObject < AbortController | null > ;
3131 lastPredictionStatsRef : RefObject < LLMPredictionStats | null > ;
32+ systemAsUser : boolean ;
33+ setSystemAsUser : Dispatch < SetStateAction < boolean > > ;
3234}
3335
3436export function createSlashCommands ( {
@@ -50,6 +52,8 @@ export function createSlashCommands({
5052 setModelLoadingProgress,
5153 modelLoadingAbortControllerRef,
5254 lastPredictionStatsRef,
55+ systemAsUser,
56+ setSystemAsUser,
5357} : CreateSlashCommandsOpts ) : SlashCommand [ ] {
5458 return [
5559 {
@@ -150,9 +154,12 @@ export function createSlashCommands({
150154 cursorInSegmentOffset : 0 ,
151155 } ) ;
152156 console . clear ( ) ;
153- const systemPrompt = chatRef . current . getSystemPrompt ( ) ;
157+ const systemPrompt = systemAsUser
158+ ? chatRef . current . at ( 0 ) . getText ( )
159+ : chatRef . current . getSystemPrompt ( ) ;
160+ const role = systemAsUser ? "user" : "system" ;
154161 chatRef . current = Chat . empty ( ) ;
155- chatRef . current . append ( "system" , systemPrompt ) ;
162+ chatRef . current . append ( role , systemPrompt ) ;
156163 lastPredictionStatsRef . current = null ;
157164 } ,
158165 } ,
@@ -170,6 +177,23 @@ export function createSlashCommands({
170177 logInChat ( "System prompt updated to: " + prompt ) ;
171178 } ,
172179 } ,
180+ {
181+ name : "system-as-user" ,
182+ description : "Toggle sending system messages as user messages" ,
183+ handler : async ( ) => {
184+ setSystemAsUser ( ! systemAsUser ) ;
185+
186+ const systemPrompt = systemAsUser
187+ ? chatRef . current . at ( 0 ) . getText ( )
188+ : chatRef . current . getSystemPrompt ( ) ;
189+ const role = ! systemAsUser ? "user" : "system" ;
190+
191+ chatRef . current = Chat . empty ( ) ;
192+ chatRef . current . append ( role , systemPrompt ) ;
193+
194+ logInChat ( `System messages will now be sent as ${ role } messages.` ) ;
195+ } ,
196+ } ,
173197 {
174198 name : "stats" ,
175199 description : "Show stats of the previous generation" ,
0 commit comments