Skip to content

Commit

Permalink
Add new GPT4o model (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftBeta authored May 13, 2024
1 parent a72d111 commit 841299d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Demo/Demo/ChatCompletions/ChatCompletionsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ChatCompletionsViewModel {
maxTokens: 2000)
if isStream {
do {
for try await newMessage in try await openAI.createChatCompletionsStream(model: .gpt4(.base),
for try await newMessage in try await openAI.createChatCompletionsStream(model: .gpt4o(.base),
messages: messages,
optionalParameters: optionalParameters) {
onReceiveStream(newMessage: newMessage)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ let optionalParameters = ChatCompletionsOptionalParameters(
do {
// Create a chat completion stream using the OpenAI API.
let stream = try await openAI.createChatCompletionsStream(
model: .gpt4(.base), // Specify the model, here GPT-4 base model.
model: .gpt4o(.base), // Specify the model, here GPT-4 base model.
messages: messages, // Provide the conversation messages.
optionalParameters: optionalParameters // Include the optional parameters.
)
Expand Down
8 changes: 8 additions & 0 deletions Sources/SwiftOpenAI/OpenAI/DataModels/OpenAIModelType.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import Foundation

public enum OpenAIModelType {
case gpt4o(GPT4o)
case gpt4(GPT4)
case gpt3_5(GPT3_5)
case embedding(EmbeddingModel)

var name: String {
switch self {
case .gpt4o(let gpt4oModel):
return gpt4oModel.rawValue
case .gpt4(let gpt4Model):
return gpt4Model.rawValue
case .gpt3_5(let gpt3_5Model):
Expand All @@ -28,6 +31,11 @@ public enum OpenAIImageModelType {
}
}

public enum GPT4o: String {
case base = "gpt-4o"
case gpt_4o_2024_05_13 = "gpt-4o-2024-05-13"
}

public enum GPT4: String {
case base = "gpt-4-turbo"
case gpt_4_turbo_2024_04_09 = "gpt-4-turbo-2024-04-09"
Expand Down

0 comments on commit 841299d

Please sign in to comment.