Skip to content

Commit 4315827

Browse files
committed
Update ChatService to remove unhandled function call request
1 parent 7fdf923 commit 4315827

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Core/Sources/ChatService/ChatService.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ public final class ChatService: ObservableObject {
8989
await pluginController.stopResponding()
9090
await chatGPTService.stopReceivingMessage()
9191
isReceivingMessage = false
92+
93+
// if it's stopped before the function finishes, remove the function call.
94+
await memory.mutateHistory { history in
95+
if history.last?.role == .assistant && history.last?.functionCall != nil {
96+
history.removeLast()
97+
}
98+
}
9299
}
93100

94101
public func clearHistory() async {

0 commit comments

Comments
 (0)