Skip to content

Commit c962212

Browse files
committed
Remove function role
1 parent 42a8efb commit c962212

File tree

8 files changed

+9
-19
lines changed

8 files changed

+9
-19
lines changed

Core/Sources/ChatGPTChatTab/Chat.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public struct DisplayedChatMessage: Equatable {
99
public enum Role: Equatable {
1010
case user
1111
case assistant
12-
case function
12+
case tool
1313
case ignored
1414
}
1515

@@ -312,8 +312,7 @@ struct Chat: ReducerProtocol {
312312
return .assistant
313313
}
314314
return .ignored
315-
case .function: return .function
316-
case .tool: return .function
315+
case .tool: return .tool
317316
}
318317
}(),
319318
text: message.summary ?? message.content ?? "",

Core/Sources/ChatGPTChatTab/ChatPanel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ struct ChatHistory: View {
258258
trailing: -8
259259
))
260260
.padding(.vertical, 4)
261-
case .function:
261+
case .tool:
262262
FunctionMessage(id: message.id, text: text)
263263
case .ignored:
264264
EmptyView()
@@ -453,7 +453,7 @@ struct ChatPanel_Preview: PreviewProvider {
453453
),
454454
.init(
455455
id: "6",
456-
role: .function,
456+
role: .tool,
457457
text: """
458458
Searching for something...
459459
- abc

Core/Sources/ChatService/ContextAwareAutoManagedChatGPTMemory.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public final class ContextAwareAutoManagedChatGPTMemory: ChatGPTMemory {
3939

4040
public func generatePrompt() async -> ChatGPTPrompt {
4141
let content = (await memory.history)
42-
.last(where: { $0.role == .user || $0.role == .function })?.content
42+
.last(where: { $0.role == .user || $0.role == .tool })?.content
4343
try? await contextController.collectContextInformation(
4444
systemPrompt: """
4545
\(chatService?.systemPrompt ?? "")

Pro

Submodule Pro updated from c6cace8 to 49bbd4a

Tool/Sources/OpenAIService/APIs/GoogleAIChatCompletionsService.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ extension ChatGPTPrompt {
194194
extension ModelContent {
195195
static func convertRole(_ role: ChatMessage.Role) -> String {
196196
switch role {
197-
case .user, .system, .function, .tool:
197+
case .user, .system, .tool:
198198
return "user"
199199
case .assistant:
200200
return "model"
@@ -207,10 +207,6 @@ extension ModelContent {
207207
return "System Prompt:\n\(message.content ?? " ")"
208208
case .user:
209209
return message.content ?? " "
210-
case .function:
211-
return """
212-
Result of \(message.name ?? "function"): \(message.content ?? "N/A")
213-
"""
214210
case .tool:
215211
return """
216212
Result of \(message.toolCallId ?? "tool"): \(message.content ?? "N/A")

Tool/Sources/OpenAIService/APIs/OlamaChatCompletionsService.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ extension OllamaChatCompletionsService: ChatCompletionsAPI {
3939
return .user
4040
case .system:
4141
return .system
42-
case .function:
43-
return .user
4442
case .tool:
4543
return .user
4644
}
@@ -116,8 +114,6 @@ extension OllamaChatCompletionsService: ChatCompletionsStreamAPI {
116114
return .user
117115
case .system:
118116
return .system
119-
case .function:
120-
return .user
121117
case .tool:
122118
return .user
123119
}

Tool/Sources/OpenAIService/ChatGPTService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ extension ChatGPTService {
499499

500500
await memory.streamMessage(
501501
id: messageId,
502-
role: .function,
502+
role: .tool,
503503
name: call.function.name,
504504
toolCallId: call.id
505505
)
@@ -578,7 +578,7 @@ extension ChatGPTService {
578578
}()
579579
await memory.streamMessage(
580580
id: messageId,
581-
role: .function,
581+
role: .tool,
582582
content: content,
583583
name: call.name,
584584
summary: "Finished running function."

Tool/Sources/OpenAIService/Models.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public struct ChatMessage: Equatable, Codable {
1515
case system
1616
case user
1717
case assistant
18-
case function
1918
case tool
2019
}
2120

0 commit comments

Comments
 (0)