@@ -16,36 +16,51 @@ public final class ChatService: ObservableObject {
1616
1717 let pluginController : ChatPluginController
1818 let contextController : DynamicContextController
19+ let functionProvider : ChatFunctionProvider
1920 var cancellable = Set < AnyCancellable > ( )
2021
2122 init < T: ChatGPTServiceType > (
2223 memory: AutoManagedChatGPTMemory ,
2324 configuration: OverridingChatGPTConfiguration < UserPreferenceChatGPTConfiguration > ,
25+ functionProvider: ChatFunctionProvider ,
2426 chatGPTService: T
2527 ) {
2628 self . memory = memory
2729 self . configuration = configuration
2830 self . chatGPTService = chatGPTService
29- pluginController = ChatPluginController ( chatGPTService: chatGPTService, plugins: allPlugins)
31+ self . functionProvider = functionProvider
32+ pluginController = ChatPluginController (
33+ chatGPTService: chatGPTService,
34+ plugins: allPlugins
35+ )
3036 contextController = DynamicContextController (
3137 memory: memory,
32- contextCollectors: ActiveDocumentChatContextCollector ( )
38+ functionProvider: functionProvider,
39+ contextCollectors: allContextCollectors
3340 )
3441
3542 pluginController. chatService = self
3643 }
3744
38- public init ( ) {
39- configuration = UserPreferenceChatGPTConfiguration ( ) . overriding ( )
40- memory = AutoManagedChatGPTMemory ( systemPrompt: " " , configuration: configuration)
41- chatGPTService = ChatGPTService ( memory: memory, configuration: configuration)
42- pluginController = ChatPluginController ( chatGPTService: chatGPTService, plugins: allPlugins)
43- contextController = DynamicContextController (
45+ public convenience init ( ) {
46+ let configuration = UserPreferenceChatGPTConfiguration ( ) . overriding ( )
47+ let functionProvider = ChatFunctionProvider ( )
48+ let memory = AutoManagedChatGPTMemory (
49+ systemPrompt: " " ,
50+ configuration: configuration,
51+ functionProvider: functionProvider
52+ )
53+ self . init (
4454 memory: memory,
45- contextCollectors: ActiveDocumentChatContextCollector ( )
55+ configuration: configuration,
56+ functionProvider: functionProvider,
57+ chatGPTService: ChatGPTService (
58+ memory: memory,
59+ configuration: configuration,
60+ functionProvider: functionProvider
61+ )
4662 )
4763
48- pluginController. chatService = self
4964 memory. observeHistoryChange { [ weak self] in
5065 self ? . objectWillChange. send ( )
5166 }
0 commit comments