@@ -89,20 +89,40 @@ struct ChatModelEdit {
8989 let model = ChatModel ( state: state)
9090 return . run { send in
9191 do {
92- let service = LegacyChatGPTService (
93- configuration: UserPreferenceChatGPTConfiguration ( )
94- . overriding {
95- $0. model = model
96- }
97- )
98- let reply = try await service
99- . sendAndWait ( content: " Respond with \" Test succeeded \" " )
100- await send ( . testSucceeded( reply ?? " No Message " ) )
101- let stream = try await service
102- . send ( content: " Respond with \" Stream response is working \" " )
92+ let configuration = UserPreferenceChatGPTConfiguration ( ) . overriding {
93+ $0. model = model
94+ }
95+ let service = ChatGPTService ( configuration: configuration)
96+ let reply = try await service. send ( TemplateChatGPTMemory (
97+ memoryTemplate: . init( messages: [
98+ . init( chatMessage: . init(
99+ role: . user,
100+ content: " Respond with \" Test succeeded \" "
101+ ) ) ,
102+ ] ) ,
103+ configuration: configuration,
104+ functionProvider: NoChatGPTFunctionProvider ( )
105+ ) ) . asText ( )
106+
107+ await send ( . testSucceeded( reply) )
108+ let stream = service. send ( TemplateChatGPTMemory (
109+ memoryTemplate: . init( messages: [
110+ . init( chatMessage: . init(
111+ role: . user,
112+ content: " Respond with \" Stream response is working \" "
113+ ) ) ,
114+ ] ) ,
115+ configuration: configuration,
116+ functionProvider: NoChatGPTFunctionProvider ( )
117+ ) )
103118 var streamReply = " "
104119 for try await chunk in stream {
105- streamReply += chunk
120+ switch chunk {
121+ case let . partialText( text) :
122+ streamReply += text
123+ default :
124+ continue
125+ }
106126 }
107127 await send ( . testSucceeded( streamReply) )
108128 } catch {
0 commit comments