We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 335642f commit 42a4c8dCopy full SHA for 42a4c8d
1 file changed
Tool/Sources/OpenAIService/Memory/TemplateChatGPTMemory.swift
@@ -44,8 +44,13 @@ public actor TemplateChatGPTMemory: ChatGPTMemory {
44
return tokenCount <= configuration.maxTokens - configuration.minimumReplyTokens
45
}
46
47
+ var truncationTimes = 500
48
while !(await checkTokenCount()) {
49
do {
50
+ truncationTimes -= 1
51
+ if truncationTimes <= 0 {
52
+ throw CancellationError()
53
+ }
54
try Task.checkCancellation()
55
try await memoryTemplate.truncate()
56
} catch {
0 commit comments