We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a508d7 commit 335642fCopy full SHA for 335642f
1 file changed
Tool/Sources/OpenAIService/Memory/TemplateChatGPTMemory.swift
@@ -46,6 +46,7 @@ public actor TemplateChatGPTMemory: ChatGPTMemory {
46
47
while !(await checkTokenCount()) {
48
do {
49
+ try Task.checkCancellation()
50
try await memoryTemplate.truncate()
51
} catch {
52
Logger.service.error("Failed to truncate prompt template: \(error)")
@@ -180,6 +181,8 @@ public struct MemoryTemplate {
180
181
}
182
183
mutating func truncate() async throws {
184
+ if Task.isCancelled { return }
185
+
186
if let truncateRule = truncateRule {
187
try await truncateRule(&messages, &followUpMessages)
188
return
0 commit comments