Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to gpt-4o #35

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct ChatDemoView: View {
messages: [.init(
role: .user,
content: content)],
model: .gpt41106Preview,
model: .gpt4o,
logProbs: true,
topLogprobs: 1)
switch selectedSegment {
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ public struct ChatCompletionObject: Decodable {
Usage
```swift
let prompt = "Tell me a joke"
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .gpt41106Preview)
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .gpt4o)
let chatCompletionObject = service.startChat(parameters: parameters)
```

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

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

### Vision

[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
[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

Usage
```swift
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"
let prompt = "What is this?"
let messageContent: [ChatCompletionParameters.Message.ContentType.MessageContent] = [.text(prompt), .imageUrl(imageURL)] // Users can add as many `.imageUrl` instances to the service.
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .contentArray(messageContent))], model: .gpt4VisionPreview)
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .contentArray(messageContent))], model: .gpt4o)
let chatCompletionObject = try await service.startStreamedChat(parameters: parameters)
```

Expand Down
15 changes: 15 additions & 0 deletions Sources/OpenAI/Public/Parameters/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ import Foundation
public enum Model {

/// Chat completion

/// ### Omicron model
/// As of 2024-05-13, this is the latest and greatest from OpenAI.
/// From their [docs](https://platform.openai.com/docs/models/gpt-4o):
///
/// > GPT-4o (“o” for “omni”) is our most advanced model. It is multimodal (accepting text or image inputs
/// > and outputting text), and it has the same high intelligence as GPT-4 Turbo but is much more efficient—
/// > it generates text 2x faster and is 50% cheaper. Additionally, GPT-4o has the best vision and performance
/// > across non-English languages of any of our models
///
case gpt4o // Points to gpt-4o-2024-05-13
case gpt4o20240513 // 128k context window with training data up to Oct 2023

case gpt35Turbo
case gpt35Turbo1106 // Most updated - Supports parallel function calls
/// 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).
Expand Down Expand Up @@ -45,6 +58,8 @@ public enum Model {

public var value: String {
switch self {
case .gpt4o: return "gpt-4o"
case .gpt4o20240513: return "gpt-4o-2024-05-13"
case .gpt35Turbo: return "gpt-3.5-turbo"
case .gpt35Turbo1106: return "gpt-3.5-turbo-1106"
case .gpt35Turbo0125: return "gpt-3.5-turbo-0125"
Expand Down