File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,30 @@ public final class ChatService: ObservableObject {
2727 let matches = regex. matches ( in: content, range: NSRange ( content. startIndex... , in: content) )
2828 if let match = matches. first {
2929 let command = String ( content [ Range ( match. range ( at: 1 ) , in: content) !] )
30- if let pluginType = plugins [ command] {
30+ if command == " /exit " {
31+ if let plugin = runningPlugin {
32+ _ = await chatGPTService. mutateHistory { history in
33+ history. append ( . init(
34+ role: . user,
35+ content: " " ,
36+ summary: " Exit plugin \( plugin. name) . "
37+ ) )
38+ history. append ( . init(
39+ role: . system,
40+ content: " " ,
41+ summary: " Exited plugin \( plugin. name) . "
42+ ) )
43+ }
44+ } else {
45+ _ = await chatGPTService. mutateHistory { history in
46+ history. append ( . init(
47+ role: . system,
48+ content: " " ,
49+ summary: " No plugin running. "
50+ ) )
51+ }
52+ }
53+ } else if let pluginType = plugins [ command] {
3154 let plugin = pluginType. init ( inside: chatGPTService, delegate: self )
3255 await plugin. send ( content: String ( content. dropFirst ( command. count + 1 ) ) )
3356 }
You can’t perform that action at this time.
0 commit comments