Skip to content

Commit 841299d

Browse files
authored
Add new GPT4o model (#43)
1 parent a72d111 commit 841299d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Demo/Demo/ChatCompletions/ChatCompletionsViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class ChatCompletionsViewModel {
2323
maxTokens: 2000)
2424
if isStream {
2525
do {
26-
for try await newMessage in try await openAI.createChatCompletionsStream(model: .gpt4(.base),
26+
for try await newMessage in try await openAI.createChatCompletionsStream(model: .gpt4o(.base),
2727
messages: messages,
2828
optionalParameters: optionalParameters) {
2929
onReceiveStream(newMessage: newMessage)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ let optionalParameters = ChatCompletionsOptionalParameters(
233233
do {
234234
// Create a chat completion stream using the OpenAI API.
235235
let stream = try await openAI.createChatCompletionsStream(
236-
model: .gpt4(.base), // Specify the model, here GPT-4 base model.
236+
model: .gpt4o(.base), // Specify the model, here GPT-4 base model.
237237
messages: messages, // Provide the conversation messages.
238238
optionalParameters: optionalParameters // Include the optional parameters.
239239
)

Sources/SwiftOpenAI/OpenAI/DataModels/OpenAIModelType.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import Foundation
22

33
public enum OpenAIModelType {
4+
case gpt4o(GPT4o)
45
case gpt4(GPT4)
56
case gpt3_5(GPT3_5)
67
case embedding(EmbeddingModel)
78

89
var name: String {
910
switch self {
11+
case .gpt4o(let gpt4oModel):
12+
return gpt4oModel.rawValue
1013
case .gpt4(let gpt4Model):
1114
return gpt4Model.rawValue
1215
case .gpt3_5(let gpt3_5Model):
@@ -28,6 +31,11 @@ public enum OpenAIImageModelType {
2831
}
2932
}
3033

34+
public enum GPT4o: String {
35+
case base = "gpt-4o"
36+
case gpt_4o_2024_05_13 = "gpt-4o-2024-05-13"
37+
}
38+
3139
public enum GPT4: String {
3240
case base = "gpt-4-turbo"
3341
case gpt_4_turbo_2024_04_09 = "gpt-4-turbo-2024-04-09"

0 commit comments

Comments
 (0)