Skip to content

Commit 27ad53b

Browse files
authored
Merge pull request #150 from philippzagar/feat/update-available-models
Add OpenAI models from Jan 25th
2 parents e469133 + f0eea34 commit 27ad53b

File tree

4 files changed

+77
-42
lines changed

4 files changed

+77
-42
lines changed

README.md

+23-10
Original file line numberDiff line numberDiff line change
@@ -785,16 +785,24 @@ Models are represented as a typealias `typealias Model = String`.
785785

786786
```swift
787787
public extension Model {
788-
static let gpt4_1106_preview = "gpt-4-1106-preview"
789-
static let gpt4_vision_preview = "gpt-4-vision-preview"
788+
static let gpt4_turbo_preview = "gpt-4-turbo-preview"
789+
static let gpt4_vision_preview = "gpt-4-vision-preview"
790+
static let gpt4_0125_preview = "gpt-4-0125-preview"
791+
static let gpt4_1106_preview = "gpt-4-1106-preview"
790792
static let gpt4 = "gpt-4"
793+
static let gpt4_0613 = "gpt-4-0613"
791794
static let gpt4_0314 = "gpt-4-0314"
792795
static let gpt4_32k = "gpt-4-32k"
796+
static let gpt4_32k_0613 = "gpt-4-32k-0613"
793797
static let gpt4_32k_0314 = "gpt-4-32k-0314"
798+
794799
static let gpt3_5Turbo = "gpt-3.5-turbo"
800+
static let gpt3_5Turbo_0125 = "gpt-3.5-turbo-0125"
795801
static let gpt3_5Turbo_1106 = "gpt-3.5-turbo-1106"
796-
static let gpt3_5Turbo0301 = "gpt-3.5-turbo-0301"
797-
802+
static let gpt3_5Turbo_0613 = "gpt-3.5-turbo-0613"
803+
static let gpt3_5Turbo_0301 = "gpt-3.5-turbo-0301"
804+
static let gpt3_5Turbo_16k = "gpt-3.5-turbo-16k"
805+
static let gpt3_5Turbo_16k_0613 = "gpt-3.5-turbo-16k-0613"
798806

799807
static let textDavinci_003 = "text-davinci-003"
800808
static let textDavinci_002 = "text-davinci-002"
@@ -805,7 +813,13 @@ public extension Model {
805813
static let textDavinci_001 = "text-davinci-001"
806814
static let codeDavinciEdit_001 = "code-davinci-edit-001"
807815

816+
static let tts_1 = "tts-1"
817+
static let tts_1_hd = "tts-1-hd"
818+
808819
static let whisper_1 = "whisper-1"
820+
821+
static let dall_e_2 = "dall-e-2"
822+
static let dall_e_3 = "dall-e-3"
809823

810824
static let davinci = "davinci"
811825
static let curie = "curie"
@@ -816,22 +830,21 @@ public extension Model {
816830
static let textSearchAda = "text-search-ada-doc-001"
817831
static let textSearchBabbageDoc = "text-search-babbage-doc-001"
818832
static let textSearchBabbageQuery001 = "text-search-babbage-query-001"
833+
static let textEmbedding3 = "text-embedding-3-small"
834+
static let textEmbedding3Large = "text-embedding-3-large"
819835

820836
static let textModerationStable = "text-moderation-stable"
821837
static let textModerationLatest = "text-moderation-latest"
822-
static let moderation = "text-moderation-001"
823-
824-
static let dall_e_2 = "dall-e-2"
825-
static let dall_e_3 = "dall-e-3"
838+
static let moderation = "text-moderation-007"
826839
}
827840
```
828841

829842
GPT-4 models are supported.
830843

831-
For example to use basic GPT-4 8K model pass `.gpt4` as a parameter.
844+
As an example: To use the `gpt-4-turbo-preview` model, pass `.gpt4_turbo_preview` as the parameter to the `ChatQuery` init.
832845

833846
```swift
834-
let query = ChatQuery(model: .gpt4, messages: [
847+
let query = ChatQuery(model: .gpt4_turbo_preview, messages: [
835848
.init(role: .system, content: "You are Librarian-GPT. You know everything about the books."),
836849
.init(role: .user, content: "Who wrote Harry Potter?")
837850
])

Sources/OpenAI/Public/Models/Models/Models.swift

+52-30
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,70 @@
55
// Created by Sergii Kryvoblotskyi on 12/19/22.
66
//
77

8-
import Foundation
9-
8+
/// Defines all available OpenAI models supported by the library.
109
public typealias Model = String
10+
1111
public extension Model {
12-
13-
// Chat Completions
14-
15-
/// More capable than any GPT-3.5 model, able to do more complex tasks, and optimized for chat. Will be updated with our latest model iteration 2 weeks after it is released.
16-
static let gpt4 = "gpt-4"
12+
// Chat Completion
13+
// GPT-4
1714

18-
/// GPT-4 Turbo, teh latest gpt-4 model with improved instruction following, JSON mode, reproducible outputs, parallel function calling and more.
19-
/// Maximum of 4096 output tokens
20-
static let gpt4_1106_preview = "gpt-4-1106-preview"
15+
/// `gpt-4-turbo`, the latest gpt-4 model with improved instruction following, JSON mode, reproducible outputs, parallel function calling and more. Maximum of 4096 output tokens
16+
static let gpt4_turbo_preview = "gpt-4-turbo-preview"
2117

22-
/// Ability to understand images, in addition to all other GPT-4 Turbo capabilities.
18+
/// `gpt-4-vision-preview`, able to understand images, in addition to all other GPT-4 Turbo capabilities.
2319
static let gpt4_vision_preview = "gpt-4-vision-preview"
24-
25-
/// Snapshot of gpt-4 from March 14th 2023. Unlike gpt-4, this model will not receive updates, and will only be supported for a three month period ending on June 14th 2023.
20+
21+
/// Snapshot of `gpt-4-turbo-preview` from January 25th 2024. This model reduces cases of “laziness” where the model doesn’t complete a task. Also fixes the bug impacting non-English UTF-8 generations. Maximum of 4096 output tokens
22+
static let gpt4_0125_preview = "gpt-4-0125-preview"
23+
24+
/// Snapshot of `gpt-4-turbo-preview` from November 6th 2023. Improved instruction following, JSON mode, reproducible outputs, parallel function calling and more. Maximum of 4096 output tokens
2625
@available(*, deprecated, message: "Please upgrade to the newer model")
27-
static let gpt4_0314 = "gpt-4-0314"
28-
/// Snapshot of gpt-4 from June 13th 2023 with function calling data. Unlike gpt-4, this model will not receive updates, and will be deprecated 3 months after a new version is released.
26+
static let gpt4_1106_preview = "gpt-4-1106-preview"
27+
28+
/// Most capable `gpt-4` model, outperforms any GPT-3.5 model, able to do more complex tasks, and optimized for chat.
29+
static let gpt4 = "gpt-4"
30+
31+
/// Snapshot of `gpt-4` from June 13th 2023 with function calling data. Unlike `gpt-4`, this model will not receive updates, and will be deprecated 3 months after a new version is released.
2932
static let gpt4_0613 = "gpt-4-0613"
30-
/// Same capabilities as the base gpt-4 mode but with 4x the context length. Will be updated with our latest model iteration.
33+
34+
/// Snapshot of `gpt-4` from March 14th 2023. Unlike gpt-4, this model will not receive updates, and will only be supported for a three month period ending on June 14th 2023.
35+
@available(*, deprecated, message: "Please upgrade to the newer model")
36+
static let gpt4_0314 = "gpt-4-0314"
37+
38+
/// Same capabilities as the base `gpt-4` model but with 4x the context length. Will be updated with our latest model iteration.
3139
static let gpt4_32k = "gpt-4-32k"
32-
/// Snapshot of gpt-4-32 from March 14th 2023. Unlike gpt-4-32k, this model will not receive updates, and will only be supported for a three month period ending on June 14th 2023.
40+
41+
/// Snapshot of `gpt-4-32k` from June 13th 2023. Unlike `gpt-4-32k`, this model will not receive updates, and will be deprecated 3 months after a new version is released.
42+
static let gpt4_32k_0613 = "gpt-4-32k-0613"
43+
44+
/// Snapshot of `gpt-4-32k` from March 14th 2023. Unlike `gpt-4-32k`, this model will not receive updates, and will only be supported for a three month period ending on June 14th 2023.
3345
@available(*, deprecated, message: "Please upgrade to the newer model")
3446
static let gpt4_32k_0314 = "gpt-4-32k-0314"
35-
/// Snapshot of gpt-4-32 from June 13th 2023. Unlike gpt-4-32k, this model will not receive updates, and will be deprecated 3 months after a new version is released.
36-
static let gpt4_32k_0613 = "gpt-4-32k-0613"
37-
38-
/// The latest GPT-3.5 Turbo model with improved instruction following, JSON mode, reproducible outputs, parallel function calling and more.
39-
static let gpt3_5Turbo_1106 = "gpt-3.5-turbo-1106"
4047

41-
/// Most capable GPT-3.5 model and optimized for chat at 1/10th the cost of text-davinci-003. Will be updated with our latest model iteration.
48+
// GPT-3.5
49+
50+
/// Most capable `gpt-3.5-turbo` model and optimized for chat. Will be updated with our latest model iteration.
4251
static let gpt3_5Turbo = "gpt-3.5-turbo"
43-
/// Snapshot of gpt-3.5-turbo from March 1st 2023. Unlike gpt-3.5-turbo, this model will not receive updates, and will only be supported for a three month period ending on June 1st 2023.
52+
53+
/// Snapshot of `gpt-3.5-turbo` from January 25th 2024. Decreased prices by 50%. Various improvements including 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.
54+
static let gpt3_5Turbo_0125 = "gpt-3.5-turbo-0125"
55+
56+
/// Snapshot of `gpt-3.5-turbo` from November 6th 2023. The latest `gpt-3.5-turbo` model with improved instruction following, JSON mode, reproducible outputs, parallel function calling and more.
57+
@available(*, deprecated, message: "Please upgrade to the newer model")
58+
static let gpt3_5Turbo_1106 = "gpt-3.5-turbo-1106"
59+
60+
/// Snapshot of `gpt-3.5-turbo` from June 13th 2023 with function calling data. Unlike `gpt-3.5-turbo`, this model will not receive updates, and will be deprecated 3 months after a new version is released.
4461
@available(*, deprecated, message: "Please upgrade to the newer model")
45-
static let gpt3_5Turbo0301 = "gpt-3.5-turbo-0301"
46-
/// Snapshot of gpt-3.5-turbo from June 13th 2023 with function calling data. Unlike gpt-3.5-turbo, this model will not receive updates, and will be deprecated 3 months after a new version is released.
62+
static let gpt3_5Turbo_0613 = "gpt-3.5-turbo-0613"
63+
64+
/// Snapshot of `gpt-3.5-turbo` from March 1st 2023. Unlike `gpt-3.5-turbo`, this model will not receive updates, and will only be supported for a three month period ending on June 1st 2023.
4765
@available(*, deprecated, message: "Please upgrade to the newer model")
48-
static let gpt3_5Turbo0613 = "gpt-3.5-turbo-0613"
49-
/// Same capabilities as the standard gpt-3.5-turbo model but with 4 times the context.
66+
static let gpt3_5Turbo_0301 = "gpt-3.5-turbo-0301"
67+
68+
/// Same capabilities as the standard `gpt-3.5-turbo` model but with 4 times the context.
5069
static let gpt3_5Turbo_16k = "gpt-3.5-turbo-16k"
51-
/// Snapshot of gpt-3.5-turbo-16k from June 13th 2023. Unlike gpt-3.5-turbo-16k, this model will not receive updates, and will be deprecated 3 months after a new version is released.
70+
71+
/// Snapshot of `gpt-3.5-turbo-16k` from June 13th 2023. Unlike `gpt-3.5-turbo-16k`, this model will not receive updates, and will be deprecated 3 months after a new version is released.
5272
static let gpt3_5Turbo_16k_0613 = "gpt-3.5-turbo-16k-0613"
5373

5474
// Completions
@@ -101,12 +121,14 @@ public extension Model {
101121
static let textSearchAda = "text-search-ada-doc-001"
102122
static let textSearchBabbageDoc = "text-search-babbage-doc-001"
103123
static let textSearchBabbageQuery001 = "text-search-babbage-query-001"
124+
static let textEmbedding3 = "text-embedding-3-small"
125+
static let textEmbedding3Large = "text-embedding-3-large"
104126

105127
// Moderations
106128

107129
/// Almost as capable as the latest model, but slightly older.
108130
static let textModerationStable = "text-moderation-stable"
109131
/// Most capable moderation model. Accuracy will be slightly higher than the stable model.
110132
static let textModerationLatest = "text-moderation-latest"
111-
static let moderation = "text-moderation-001"
133+
static let moderation = "text-moderation-007"
112134
}

Tests/OpenAITests/OpenAITests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class OpenAITests: XCTestCase {
117117
}
118118

119119
func testChatsFunction() async throws {
120-
let query = ChatQuery(model: .gpt3_5Turbo_1106, messages: [
120+
let query = ChatQuery(model: .gpt3_5Turbo_0125, messages: [
121121
.init(role: .system, content: "You are Weather-GPT. You know everything about the weather."),
122122
.init(role: .user, content: "What's the weather like in Boston?"),
123123
], functions: [

Tests/OpenAITests/OpenAITestsDecoder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ class OpenAITestsDecoder: XCTestCase {
347347
let data = """
348348
{
349349
"id": "modr-5MWoLO",
350-
"model": "text-moderation-001",
350+
"model": "text-moderation-007",
351351
"results": [
352352
{
353353
"categories": {

0 commit comments

Comments
 (0)