@@ -38,6 +38,7 @@ public actor AutoManagedChatGPTMemory: ChatGPTMemory {
3838 public var retrievedContent : [ ChatMessage . Reference ] = [ ]
3939 public var configuration : ChatGPTConfiguration
4040 public var functionProvider : ChatGPTFunctionProvider
41+ public var maxNumberOfMessages : Int
4142
4243 var onHistoryChange : ( ) -> Void = { }
4344
@@ -47,6 +48,7 @@ public actor AutoManagedChatGPTMemory: ChatGPTMemory {
4748 systemPrompt: String ,
4849 configuration: ChatGPTConfiguration ,
4950 functionProvider: ChatGPTFunctionProvider ,
51+ maxNumberOfMessages: Int = . max,
5052 composeHistory: @escaping HistoryComposer = {
5153 /// Default Format:
5254 /// ```
@@ -70,6 +72,7 @@ public actor AutoManagedChatGPTMemory: ChatGPTMemory {
7072 self . configuration = configuration
7173 self . functionProvider = functionProvider
7274 self . composeHistory = composeHistory
75+ self . maxNumberOfMessages = maxNumberOfMessages
7376 }
7477
7578 public func mutateHistory( _ update: ( inout [ ChatMessage ] ) -> Void ) {
@@ -110,10 +113,7 @@ public actor AutoManagedChatGPTMemory: ChatGPTMemory {
110113
111114extension AutoManagedChatGPTMemory {
112115 /// https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
113- func generateSendingHistory(
114- maxNumberOfMessages: Int = UserDefaults . shared. value ( for: \. chatGPTMaxMessageCount) ,
115- strategy: AutoManagedChatGPTMemoryStrategy
116- ) async -> ChatGPTPrompt {
116+ func generateSendingHistory( strategy: AutoManagedChatGPTMemoryStrategy ) async -> ChatGPTPrompt {
117117 // handle no function support models
118118
119119 let (
0 commit comments