Skip to content

Commit 8296726

Browse files
committed
Add endpoint and maxToken to ChatGPTModel
1 parent e6662b0 commit 8296726

1 file changed

Lines changed: 39 additions & 9 deletions

File tree

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,53 @@
11
import Foundation
22

33
public enum ChatGPTModel: String {
4+
case gpt35Turbo = "gpt-3.5-turbo"
5+
6+
case gpt35Turbo0301 = "gpt-3.5-turbo-0301"
7+
48
case textDavinci003 = "text-davinci-003"
59

610
case textCurie001 = "text-curie-001"
711

812
case textBabbage001 = "text-babbage-001"
913

1014
case textAda001 = "text-ada-001"
15+
}
1116

12-
case codeDavinci002 = "code-davinci-002"
13-
14-
case codeCushman001 = "code-cushman-001"
15-
16-
case textDavinciEdit001 = "text-davinci-edit-001"
17-
18-
case gpt35Turbo = "gpt-3.5-turbo"
19-
20-
case gpt35Turbo0301 = "gpt-3.5-turbo-0301"
17+
extension ChatGPTModel {
18+
var endpoint: String {
19+
switch self {
20+
case .gpt35Turbo:
21+
return "https://api.openai.com/v1/chat/completions"
22+
case .gpt35Turbo0301:
23+
return "https://api.openai.com/v1/chat/completions"
24+
case .textDavinci003:
25+
return "https://api.openai.com/v1/completions"
26+
case .textCurie001:
27+
return "https://api.openai.com/v1/completions"
28+
case .textBabbage001:
29+
return "https://api.openai.com/v1/completions"
30+
case .textAda001:
31+
return "https://api.openai.com/v1/completions"
32+
}
33+
}
34+
35+
var maxToken: Int {
36+
switch self {
37+
case .gpt35Turbo:
38+
return 4096
39+
case .gpt35Turbo0301:
40+
return 4096
41+
case .textDavinci003:
42+
return 4097
43+
case .textCurie001:
44+
return 2049
45+
case .textBabbage001:
46+
return 2049
47+
case .textAda001:
48+
return 2049
49+
}
50+
}
2151
}
2252

2353
extension ChatGPTModel: CaseIterable {}

0 commit comments

Comments
 (0)