Skip to content

Commit 17ac743

Browse files
committed
change ChatMessage Participant system case to model case
1 parent 2445a88 commit 17ac743

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

firebaseai/ChatExample/Models/ChatMessage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import FirebaseAI
1616
import Foundation
1717

1818
enum Participant {
19-
case system
19+
case model
2020
case user
2121
}
2222

@@ -40,7 +40,7 @@ struct ChatMessage: Identifiable, Equatable {
4040

4141
extension ChatMessage {
4242
static var samples: [ChatMessage] = [
43-
.init(message: "Hello. What can I do for you today?", participant: .system),
43+
.init(message: "Hello. What can I do for you today?", participant: .model),
4444
.init(message: "Show me a simple loop in Swift.", participant: .user),
4545
.init(message: """
4646
Sure, here is a simple loop in Swift:
@@ -65,7 +65,7 @@ extension ChatMessage {
6565
```
6666
6767
This loop calculates the sum of the numbers from 1 to 100. The variable sum is initialized to 0, and then the for loop iterates over the range of numbers from 1 to 100. The variable i is assigned each number in the range, and the value of i is added to the sum variable. After the loop has finished executing, the value of sum is printed to the console.
68-
""", participant: .system),
68+
""", participant: .model),
6969
]
7070

7171
static var sample = samples[0]

firebaseai/ChatExample/ViewModels/ConversationViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ConversationViewModel: ObservableObject {
8181
messages.append(userMessage)
8282

8383
// add a pending message while we're waiting for a response from the backend
84-
let systemMessage = ChatMessage.pending(participant: .system)
84+
let systemMessage = ChatMessage.pending(participant: .model)
8585
messages.append(systemMessage)
8686

8787
do {
@@ -121,7 +121,7 @@ class ConversationViewModel: ObservableObject {
121121
messages.append(userMessage)
122122

123123
// add a pending message while we're waiting for a response from the backend
124-
let systemMessage = ChatMessage.pending(participant: .system)
124+
let systemMessage = ChatMessage.pending(participant: .model)
125125
messages.append(systemMessage)
126126

127127
do {

firebaseai/ChatExample/Views/MessageView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct ResponseTextView: View {
6262
.markdownTextStyle {
6363
FontFamilyVariant(.normal)
6464
FontSize(.em(0.85))
65-
ForegroundColor(message.participant == .system ? Color(UIColor.label) : .white)
65+
ForegroundColor(message.participant == .model ? Color(UIColor.label) : .white)
6666
}
6767
.markdownBlockStyle(\.codeBlock) { configuration in
6868
configuration.label
@@ -90,16 +90,16 @@ struct MessageView: View {
9090
}
9191
MessageContentView(message: message)
9292
.padding(10)
93-
.background(message.participant == .system
93+
.background(message.participant == .model
9494
? Color(UIColor.systemFill)
9595
: Color(UIColor.systemBlue))
9696
.roundedCorner(10,
9797
corners: [
9898
.topLeft,
9999
.topRight,
100-
message.participant == .system ? .bottomRight : .bottomLeft,
100+
message.participant == .model ? .bottomRight : .bottomLeft,
101101
])
102-
if message.participant == .system {
102+
if message.participant == .model {
103103
Spacer()
104104
}
105105
}
@@ -114,7 +114,7 @@ struct MessageView_Previews: PreviewProvider {
114114
MessageView(message: ChatMessage.samples[0])
115115
MessageView(message: ChatMessage.samples[1])
116116
MessageView(message: ChatMessage.samples[2])
117-
MessageView(message: ChatMessage(message: "Hello!", participant: .system, pending: true))
117+
MessageView(message: ChatMessage(message: "Hello!", participant: .model, pending: true))
118118
}
119119
.listStyle(.plain)
120120
.navigationTitle("Chat example")

firebaseai/FunctionCallingExample/ViewModels/FunctionCallingViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FunctionCallingViewModel: ObservableObject {
7575
messages.append(userMessage)
7676

7777
// add a pending message while we're waiting for a response from the backend
78-
let systemMessage = ChatMessage.pending(participant: .system)
78+
let systemMessage = ChatMessage.pending(participant: .model)
7979
messages.append(systemMessage)
8080

8181
print(messages)
@@ -224,7 +224,7 @@ private extension FunctionCallPart {
224224
}
225225
let messageText = "Function call requested by model:\n```\n\(json)\n```"
226226

227-
return ChatMessage(message: messageText, participant: .system)
227+
return ChatMessage(message: messageText, participant: .model)
228228
}
229229
}
230230

0 commit comments

Comments
 (0)