Skip to content

Commit 7e0c6ce

Browse files
authored
Merge pull request #572 from innogames/openai_model
openai: use gpt-4o by default
2 parents 757d506 + fcb8638 commit 7e0c6ce

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

command/export/export.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/slack-go/slack"
1616
)
1717

18+
// limit the number of exported messages (incl thread messages)
1819
const limit = 3000
1920

2021
// NewExportCommand is a constructor to create a new export command

command/openai/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (c *Config) IsEnabled() bool {
4141

4242
var defaultConfig = Config{
4343
APIHost: apiHost,
44-
Model: "gpt-3.5-turbo", // aka model behind ChatGPT
44+
Model: "gpt-4o", // aka model behind ChatGPT
4545
UpdateInterval: time.Second * 1,
4646
HistorySize: 25,
4747
InitialSystemMessage: "You are a helpful Slack bot. By default, keep your answer short and truthful",

command/openai/openai_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ func TestOpenai(t *testing.T) {
7777
apiCompletionURL,
7878
[]testRequest{
7979
{
80-
`{"model":"gpt-3.5-turbo","messages":[{"role":"system","content":"You are a helpful Slack bot. By default, keep your answer short and truthful"},{"role":"user","content":"whats 1+1?"}],"stream":true}`,
81-
`data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
80+
`{"model":"gpt-4o","messages":[{"role":"system","content":"You are a helpful Slack bot. By default, keep your answer short and truthful"},{"role":"user","content":"whats 1+1?"}],"stream":true}`,
81+
`data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
8282
83-
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"The answer "},"index":0,"finish_reason":null}]}
83+
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{"content":"The answer "},"index":0,"finish_reason":null}]}
8484
85-
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"is 2"},"index":0,"finish_reason":null}]}
85+
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{"content":"is 2"},"index":0,"finish_reason":null}]}
8686
87-
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
87+
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
8888
8989
data: [DONE]`,
9090
http.StatusOK,
9191
},
9292
{
93-
`{"model":"gpt-3.5-turbo","messages":[{"role":"system","content":"You are a helpful Slack bot. By default, keep your answer short and truthful"},{"role":"user","content":"whats 1+1?"},{"role":"assistant","content":"The answer is 2"},{"role":"user","content":"whats 2+1?"}],"stream":true}`,
93+
`{"model":"gpt-4o","messages":[{"role":"system","content":"You are a helpful Slack bot. By default, keep your answer short and truthful"},{"role":"user","content":"whats 1+1?"},{"role":"assistant","content":"The answer is 2"},{"role":"user","content":"whats 2+1?"}],"stream":true}`,
9494
`{
9595
"id": "chatcmpl-6p9XYPYSTTRi0xEviKjjilqrWU2Ve",
9696
"object": "chat.completion",
9797
"created": 1677649420,
98-
"model": "gpt-3.5-turbo",
98+
"model": "gpt-4o",
9999
"usage": {"prompt_tokens": 56, "completion_tokens": 31, "total_tokens": 87},
100100
"choices": [
101101
{
@@ -171,7 +171,7 @@ data: [DONE]`,
171171
apiCompletionURL,
172172
[]testRequest{
173173
{
174-
`{"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"whats 1+1?"}],"stream":true}`,
174+
`{"model":"gpt-4o","messages":[{"role":"user","content":"whats 1+1?"}],"stream":true}`,
175175
`{
176176
"error": {
177177
"code": "invalid_api_key",
@@ -212,7 +212,7 @@ data: [DONE]`,
212212

213213
[]testRequest{
214214
{
215-
`{"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"whats 1+1?"}],"stream":true}`,
215+
`{"model":"gpt-4o","messages":[{"role":"user","content":"whats 1+1?"}],"stream":true}`,
216216
`{
217217
"error": {
218218
"code": "invalid_api_key",
@@ -252,12 +252,12 @@ data: [DONE]`,
252252
apiCompletionURL,
253253
[]testRequest{
254254
{
255-
`{"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"whats 1+1?"}]}`,
255+
`{"model":"gpt-4o","messages":[{"role":"user","content":"whats 1+1?"}]}`,
256256
`{
257257
"id": "chatcmpl-6p9XYPYSTTRi0xEviKjjilqrWU2Ve",
258258
"object": "chat.completion",
259259
"created": 1677649420,
260-
"model": "gpt-3.5-turbo",
260+
"model": "gpt-4o",
261261
"usage": {"prompt_tokens": 56, "completion_tokens": 31, "total_tokens": 87},
262262
"choices": [
263263
{
@@ -293,12 +293,12 @@ data: [DONE]`,
293293
apiCompletionURL,
294294
[]testRequest{
295295
{
296-
`{"model":"gpt-3.5-turbo","messages":[{"role":"system","content":"You are a helpful Slack bot. By default, keep your answer short and truthful"},{"role":"system","content":"This is a Slack bot receiving a slack thread s context, using slack user ids as identifiers. Please use user mentions in the format \u003c@U123456\u003e"},{"role":"user","content":"User \u003c@U1234\u003e wrote: thread message 1"},{"role":"user","content":"whats 1+1?"}],"stream":true}`,
297-
`data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
296+
`{"model":"gpt-4o","messages":[{"role":"system","content":"You are a helpful Slack bot. By default, keep your answer short and truthful"},{"role":"system","content":"This is a Slack bot receiving a slack thread s context, using slack user ids as identifiers. Please use user mentions in the format \u003c@U123456\u003e"},{"role":"user","content":"User \u003c@U1234\u003e wrote: thread message 1"},{"role":"user","content":"whats 1+1?"}],"stream":true}`,
297+
`data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
298298
299-
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"Jolo!"},"index":0,"finish_reason":null}]}
299+
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{"content":"Jolo!"},"index":0,"finish_reason":null}]}
300300
301-
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
301+
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
302302
303303
data: [DONE]`,
304304
http.StatusOK,
@@ -352,11 +352,11 @@ data: [DONE]`,
352352
[]testRequest{
353353
{
354354
`{"model":"dummy-test","messages":[{"role":"user","content":"User \u003c@U1234\u003e wrote: i had a great weekend"},{"role":"user","content":"summarize this thread "}],"stream":true}`,
355-
`data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
355+
`data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
356356
357-
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"Jolo!"},"index":0,"finish_reason":null}]}
357+
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{"content":"Jolo!"},"index":0,"finish_reason":null}]}
358358
359-
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
359+
data: {"id":"chatcmpl-6tuxebSPdmd2IJpb8GrZXHiYXON6r","object":"chat.completion.chunk","created":1678785018,"model":"gpt-4o-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
360360
361361
data: [DONE]`,
362362
http.StatusOK,

command/openai/tokens.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77
// https://platform.openai.com/docs/models/gpt-3-5
88
// https://platform.openai.com/docs/models/gpt-4
99
var maxTokens = map[string]int{
10-
"gpt-4": 8192,
11-
"gpt-4-32k": 32768,
12-
"gpt-4-1106-preview": 128000,
13-
"gpt-4-vision-preview": 128000,
14-
"gpt-3.5-turbo-16k": 16385,
15-
"gpt-3.5-turbo": 4096,
16-
"dummy-test": 100, // just for testing
10+
"gpt-4": 8192,
11+
"gpt-4-32k": 32768,
12+
"gpt-4-1106-preview": 128000,
13+
"gpt-4-turbo": 128000,
14+
"gpt-4o": 128000,
15+
"gpt-3.5-turbo": 16385,
16+
"dummy-test": 100, // just for testing
1717
}
1818

1919
var modelDateRe = regexp.MustCompile(`-\d{4}`)

command/openai/tokens_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ func TestModels(t *testing.T) {
1414
{"", 128000},
1515
{"jolo", 128000},
1616
{"gpt-4", 8192},
17+
{"gpt-4o", 128000},
1718
{"gpt-4-0613", 8192},
18-
{"gpt-4-32k-0613", 32768},
19-
{"gpt-3.5-turbo", 4096},
20-
{"gpt-3.5-turbo-16k-0613", 16385},
19+
{"gpt-3.5-turbo", 16385},
2120
}
2221

2322
for _, testCase := range modelsTestCases {
2423
actual := getMaxTokensForModel(testCase.input)
25-
assert.Equal(t, testCase.expected, actual)
24+
assert.Equal(t, testCase.expected, actual, "Model "+testCase.input)
2625
}
2726
}
2827

0 commit comments

Comments
 (0)