Skip to content

Commit 7980129

Browse files
committed
Update chat model test
1 parent f87c43c commit 7980129

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

Core/Sources/HostApp/AccountSettings/ChatModelManagement/ChatModelEdit.swift

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,37 +93,29 @@ struct ChatModelEdit {
9393
$0.model = model
9494
}
9595
let service = ChatGPTService(configuration: configuration)
96-
let reply = try await service.send(TemplateChatGPTMemory(
96+
let stream = service.send(TemplateChatGPTMemory(
9797
memoryTemplate: .init(messages: [
98+
.init(chatMessage: .init(
99+
role: .system,
100+
content: "You are a bot. Just do what is told."
101+
)),
102+
.init(chatMessage: .init(
103+
role: .assistant,
104+
content: "Hello"
105+
)),
98106
.init(chatMessage: .init(
99107
role: .user,
100-
content: "Respond with \"Test succeeded\""
108+
content: "Respond with \"Test succeeded.\""
101109
)),
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: [
110110
.init(chatMessage: .init(
111111
role: .user,
112-
content: "Respond with \"Stream response is working\""
112+
content: "Respond with \"Test succeeded.\""
113113
)),
114114
]),
115115
configuration: configuration,
116116
functionProvider: NoChatGPTFunctionProvider()
117117
))
118-
var streamReply = ""
119-
for try await chunk in stream {
120-
switch chunk {
121-
case let .partialText(text):
122-
streamReply += text
123-
default:
124-
continue
125-
}
126-
}
118+
let streamReply = try await stream.asText()
127119
await send(.testSucceeded(streamReply))
128120
} catch {
129121
await send(.testFailed(error.localizedDescription))

0 commit comments

Comments
 (0)