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

Add gpt-4o and gpt-4-turbo models #20

Merged
merged 1 commit into from
May 15, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The `complete(using:)` method also includes various optional parameters:
```swift
let completion = chatThread.complete(
using: openAIAPIConnection,
model: .gpt4,
model: .gpt4o,
temperature: 0.7,
maxTokens: 500
)
Expand Down
10 changes: 10 additions & 0 deletions Sources/CleverBird/chat/ChatModel.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
public enum ChatModel: Codable {
case gpt35Turbo
case gpt4
case gpt4Turbo
case gpt4o
case specific(String)

public init(from decoder: Decoder) throws {
Expand All @@ -10,6 +12,10 @@ public enum ChatModel: Codable {
switch modelString {
case _ where modelString.starts(with: "gpt-3.5"):
self = .gpt35Turbo
case _ where modelString.starts(with: "gpt-4o"):
self = .gpt4o
case _ where modelString.starts(with: "gpt-4-turbo"):
self = .gpt4Turbo
case _ where modelString.starts(with: "gpt-4"):
self = .gpt4
default:
Expand All @@ -30,6 +36,10 @@ extension ChatModel: CustomStringConvertible {
switch self {
case .gpt35Turbo:
return "gpt-3.5-turbo"
case .gpt4o:
return "gpt-4o"
case .gpt4Turbo:
return "gpt-4-turbo"
case .gpt4:
return "gpt-4"
case .specific(let string):
Expand Down
4 changes: 2 additions & 2 deletions Sources/CleverBird/chat/ChatThread+complete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

extension ChatThread {
public func complete(using connection: OpenAIAPIConnection,
model: ChatModel = .gpt4,
model: ChatModel = .gpt4o,
temperature: Percentage = 0.7,
topP: Percentage? = nil,
stop: [String]? = nil,
Expand All @@ -24,7 +24,7 @@ extension ChatThread {
}

public func completeIncludeUsage(using connection: OpenAIAPIConnection,
model: ChatModel = .gpt4,
model: ChatModel = .gpt4o,
temperature: Percentage = 0.7,
topP: Percentage? = nil,
stop: [String]? = nil,
Expand Down
4 changes: 3 additions & 1 deletion Sources/CleverBird/chat/ChatThread+tokenCount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ extension ChatThread {
switch model {
case .gpt35Turbo:
tokensPerMessage = 4
case .gpt4:
case .gpt4, .gpt4Turbo:
tokensPerMessage = 3
case .gpt4o:
tokensPerMessage = 3
case .specific(_):
tokensPerMessage = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Foundation
extension StreamableChatThread {

public func complete(using connection: OpenAIAPIConnection,
model: ChatModel = .gpt4,
model: ChatModel = .gpt4o,
temperature: Percentage = 0.7,
topP: Percentage? = nil,
stop: [String]? = nil,
Expand Down
Loading