File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ public class FunctionCallingChatAgent<Output: AgentOutputParsable & Decodable>:
7676
7777 public init (
7878 configuration: ChatGPTConfiguration = UserPreferenceChatGPTConfiguration ( ) ,
79- memory: ChatGPTMemory = ConversationChatGPTMemory ( systemPrompt: " " ) ,
8079 tools: [ AgentTool ] = [ ] ,
8180 endFunction: EndFunction
8281 ) {
@@ -92,7 +91,7 @@ public class FunctionCallingChatAgent<Output: AgentOutputParsable & Decodable>:
9291 configuration: configuration. overriding {
9392 $0. runFunctionsAutomatically = false
9493 } ,
95- memory: memory ,
94+ memory: nil ,
9695 functionProvider: functionProvider,
9796 stream: false
9897 ) ,
@@ -158,7 +157,7 @@ public class FunctionCallingChatAgent<Output: AgentOutputParsable & Decodable>:
158157 }
159158
160159 public func parseOutput( _ message: ChatMessage ) async -> AgentNextStep < Output > {
161- if message. role == . function , let functionCall = message. functionCall {
160+ if message. role == . assistant , let functionCall = message. functionCall {
162161 if let function = functionProvider. functionTools. first ( where: {
163162 $0. name == functionCall. name
164163 } ) {
Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ import OpenAIService
33
44public struct OpenAIChat : ChatModel {
55 public var configuration : ChatGPTConfiguration
6- public var memory : ChatGPTMemory
6+ public var memory : ChatGPTMemory ?
77 public var functionProvider : ChatGPTFunctionProvider
88 public var stream : Bool
99
1010 public init (
1111 configuration: ChatGPTConfiguration = UserPreferenceChatGPTConfiguration ( ) ,
12- memory: ChatGPTMemory = ConversationChatGPTMemory ( systemPrompt: " " ) ,
12+ memory: ChatGPTMemory ? = ConversationChatGPTMemory ( systemPrompt: " " ) ,
1313 functionProvider: ChatGPTFunctionProvider = NoChatGPTFunctionProvider ( ) ,
1414 stream: Bool
1515 ) {
@@ -24,6 +24,8 @@ public struct OpenAIChat: ChatModel {
2424 stops: [ String ] ,
2525 callbackManagers: [ CallbackManager ]
2626 ) async throws -> ChatMessage {
27+ let memory = memory ?? EmptyChatGPTMemory ( )
28+
2729 let service = ChatGPTService (
2830 memory: memory,
2931 configuration: configuration,
You can’t perform that action at this time.
0 commit comments