Skip to content

Commit f0edddc

Browse files
authored
Update to gpt-4o (#35)
1 parent 796c3f3 commit f0edddc

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Examples/SwiftOpenAIExample/SwiftOpenAIExample/ChatDemo/ChatDemoView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct ChatDemoView: View {
7575
messages: [.init(
7676
role: .user,
7777
content: content)],
78-
model: .gpt41106Preview,
78+
model: .gpt4o,
7979
logProbs: true,
8080
topLogprobs: 1)
8181
switch selectedSegment {

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ public struct ChatCompletionObject: Decodable {
878878
Usage
879879
```swift
880880
let prompt = "Tell me a joke"
881-
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .gpt41106Preview)
881+
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .gpt4o)
882882
let chatCompletionObject = service.startChat(parameters: parameters)
883883
```
884884

@@ -966,7 +966,7 @@ public struct ChatCompletionChunkObject: Decodable {
966966
Usage
967967
```swift
968968
let prompt = "Tell me a joke"
969-
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .gpt41106Preview)
969+
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .gpt4o)
970970
let chatCompletionObject = try await service.startStreamedChat(parameters: parameters)
971971
```
972972

@@ -1042,14 +1042,14 @@ For more details about how to also uploading base 64 encoded images in iOS check
10421042

10431043
### Vision
10441044

1045-
[Vision](https://platform.openai.com/docs/guides/vision) API is available for use; developers must access it through the chat completions API, specifically using the gpt-4-vision-preview model. Using any other model will not provide an image description
1045+
[Vision](https://platform.openai.com/docs/guides/vision) API is available for use; developers must access it through the chat completions API, specifically using the gpt-4-vision-preview model or gpt-4o model. Using any other model will not provide an image description
10461046

10471047
Usage
10481048
```swift
10491049
let imageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
10501050
let prompt = "What is this?"
10511051
let messageContent: [ChatCompletionParameters.Message.ContentType.MessageContent] = [.text(prompt), .imageUrl(imageURL)] // Users can add as many `.imageUrl` instances to the service.
1052-
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .contentArray(messageContent))], model: .gpt4VisionPreview)
1052+
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .contentArray(messageContent))], model: .gpt4o)
10531053
let chatCompletionObject = try await service.startStreamedChat(parameters: parameters)
10541054
```
10551055

Sources/OpenAI/Public/Parameters/Model.swift

+15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ import Foundation
1212
public enum Model {
1313

1414
/// Chat completion
15+
16+
/// ### Omicron model
17+
/// As of 2024-05-13, this is the latest and greatest from OpenAI.
18+
/// From their [docs](https://platform.openai.com/docs/models/gpt-4o):
19+
///
20+
/// > GPT-4o (“o” for “omni”) is our most advanced model. It is multimodal (accepting text or image inputs
21+
/// > and outputting text), and it has the same high intelligence as GPT-4 Turbo but is much more efficient—
22+
/// > it generates text 2x faster and is 50% cheaper. Additionally, GPT-4o has the best vision and performance
23+
/// > across non-English languages of any of our models
24+
///
25+
case gpt4o // Points to gpt-4o-2024-05-13
26+
case gpt4o20240513 // 128k context window with training data up to Oct 2023
27+
1528
case gpt35Turbo
1629
case gpt35Turbo1106 // Most updated - Supports parallel function calls
1730
/// The latest GPT-3.5 Turbo model with higher accuracy at responding in requested formats and a fix for a bug which caused a text encoding issue for non-English language function calls. Returns a maximum of 4,096 output tokens. [Learn more](https://openai.com/blog/new-embedding-models-and-api-updates#:~:text=Other%20new%20models%20and%20lower%20pricing).
@@ -45,6 +58,8 @@ public enum Model {
4558

4659
public var value: String {
4760
switch self {
61+
case .gpt4o: return "gpt-4o"
62+
case .gpt4o20240513: return "gpt-4o-2024-05-13"
4863
case .gpt35Turbo: return "gpt-3.5-turbo"
4964
case .gpt35Turbo1106: return "gpt-3.5-turbo-1106"
5065
case .gpt35Turbo0125: return "gpt-3.5-turbo-0125"

0 commit comments

Comments
 (0)