Skip to content

Commit d74ec2b

Browse files
authored
Merge pull request #50 from matlab-deep-learning/openAI-updates
Add gpt-4o-mini and make it the default
2 parents b3efaf6 + fc1798c commit d74ec2b

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

+llms/+openai/models.m

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
% Copyright 2024 The MathWorks, Inc.
55
models = [...
66
"gpt-4o","gpt-4o-2024-05-13",...
7+
"gpt-4o-mini","gpt-4o-mini-2024-07-18",...
78
"gpt-4-turbo","gpt-4-turbo-2024-04-09",...
89
"gpt-4","gpt-4-0613", ...
910
"gpt-3.5-turbo","gpt-3.5-turbo-0125", ...

doc/OpenAI.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Several functions in this repository connect MATLAB to the [OpenAI™ Chat Compl
55
To start using the OpenAI APIs, you first need to obtain OpenAI API keys. You are responsible for any fees OpenAI may charge for the use of their APIs. You should be familiar with the limitations and risks associated with using this technology, and you agree that you shall be solely responsible for full compliance with any terms that may apply to your use of the OpenAI APIs.
66

77
Some of the current LLMs supported on OpenAI are:
8+
- gpt-4o-mini, gpt-4o-mini-2024-07-18
89
- gpt-3.5-turbo, gpt-3.5-turbo-1106, gpt-3.5-turbo-0125
910
- gpt-4o, gpt-4o-2024-05-13 (GPT-4 Omni)
1011
- gpt-4-turbo, gpt-4-turbo-2024-04-09 (GPT-4 Turbo with Vision)

openAIChat.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
% using one or more name-value arguments:
1212
%
1313
% ModelName - Name of the model to use for chat completions.
14-
% The default value is "gpt-3.5-turbo".
14+
% The default value is "gpt-4o-mini".
1515
%
1616
% Temperature - Temperature value for controlling the randomness
1717
% of the output. Default value is 1; higher values
@@ -92,7 +92,7 @@
9292
arguments
9393
systemPrompt {llms.utils.mustBeTextOrEmpty} = []
9494
nvp.Tools (1,:) {mustBeA(nvp.Tools, "openAIFunction")} = openAIFunction.empty
95-
nvp.ModelName (1,1) string {mustBeModel} = "gpt-3.5-turbo"
95+
nvp.ModelName (1,1) string {mustBeModel} = "gpt-4o-mini"
9696
nvp.Temperature {llms.utils.mustBeValidTemperature} = 1
9797
nvp.TopP {llms.utils.mustBeValidTopP} = 1
9898
nvp.StopSequences {llms.utils.mustBeValidStop} = {}

tests/tollamaChat.m

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ function doGenerateUsingSystemPrompt(testCase)
4747
end
4848

4949
function extremeTopK(testCase)
50+
%% This should work, and it does on some computers. On others, Ollama
51+
%% receives the parameter, but either Ollama or llama.cpp fails to
52+
%% honor it correctly.
53+
testCase.assumeTrue(false,"disabled due to Ollama/llama.cpp not honoring parameter reliably");
54+
5055
% setting top-k to k=1 leaves no random choice,
5156
% so we expect to get a fixed response.
5257
chat = ollamaChat("mistral",TopK=1);

tests/topenAIChat.m

+15-13
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function generateAcceptsMessagesAsInput(testCase)
3434

3535
function constructChatWithAllNVP(testCase)
3636
functions = openAIFunction("funName");
37-
modelName = "gpt-3.5-turbo";
37+
modelName = "gpt-4o-mini";
3838
temperature = 0;
3939
topP = 1;
4040
stop = ["[END]", "."];
@@ -84,7 +84,9 @@ function settingToolChoiceWithNone(testCase)
8484
end
8585

8686
function fixedSeedFixesResult(testCase)
87-
chat = openAIChat;
87+
% Seed is "beta" in OpenAI documentation
88+
% and not reliable in gpt-4o-mini at this time.
89+
chat = openAIChat(ModelName="gpt-3.5-turbo");
8890

8991
result1 = generate(chat,"This is okay", "Seed", 2);
9092
result2 = generate(chat,"This is okay", "Seed", 2);
@@ -227,7 +229,7 @@ function warningJSONResponseFormatGPT35(testCase)
227229
chat = @() openAIChat("You are a useful assistant", ...
228230
APIKey="this-is-not-a-real-key", ...
229231
ResponseFormat="json", ...
230-
ModelName="gpt-3.5-turbo");
232+
ModelName="gpt-4o-mini");
231233

232234
testCase.verifyWarning(@()chat(), "llms:warningJsonInstruction");
233235
end
@@ -378,7 +380,7 @@ function keyNotFound(testCase)
378380
"FrequencyPenalty", {0}, ...
379381
"TimeOut", {10}, ...
380382
"FunctionNames", {[]}, ...
381-
"ModelName", {"gpt-3.5-turbo"}, ...
383+
"ModelName", {"gpt-4o-mini"}, ...
382384
"SystemPrompt", {[]}, ...
383385
"ResponseFormat", {"text"} ...
384386
) ...
@@ -394,7 +396,7 @@ function keyNotFound(testCase)
394396
"FrequencyPenalty", {0}, ...
395397
"TimeOut", {10}, ...
396398
"FunctionNames", {[]}, ...
397-
"ModelName", {"gpt-3.5-turbo"}, ...
399+
"ModelName", {"gpt-4o-mini"}, ...
398400
"SystemPrompt", {{struct("role","system","content","system prompt")}}, ...
399401
"ResponseFormat", {"text"} ...
400402
) ...
@@ -410,7 +412,7 @@ function keyNotFound(testCase)
410412
"FrequencyPenalty", {0}, ...
411413
"TimeOut", {10}, ...
412414
"FunctionNames", {[]}, ...
413-
"ModelName", {"gpt-3.5-turbo"}, ...
415+
"ModelName", {"gpt-4o-mini"}, ...
414416
"SystemPrompt", {[]}, ...
415417
"ResponseFormat", {"text"} ...
416418
) ...
@@ -426,7 +428,7 @@ function keyNotFound(testCase)
426428
"FrequencyPenalty", {0}, ...
427429
"TimeOut", {10}, ...
428430
"FunctionNames", {[]}, ...
429-
"ModelName", {"gpt-3.5-turbo"}, ...
431+
"ModelName", {"gpt-4o-mini"}, ...
430432
"SystemPrompt", {[]}, ...
431433
"ResponseFormat", {"text"} ...
432434
) ...
@@ -442,7 +444,7 @@ function keyNotFound(testCase)
442444
"FrequencyPenalty", {0}, ...
443445
"TimeOut", {10}, ...
444446
"FunctionNames", {[]}, ...
445-
"ModelName", {"gpt-3.5-turbo"}, ...
447+
"ModelName", {"gpt-4o-mini"}, ...
446448
"SystemPrompt", {[]}, ...
447449
"ResponseFormat", {"text"} ...
448450
) ...
@@ -458,7 +460,7 @@ function keyNotFound(testCase)
458460
"FrequencyPenalty", {0}, ...
459461
"TimeOut", {10}, ...
460462
"FunctionNames", {[]}, ...
461-
"ModelName", {"gpt-3.5-turbo"}, ...
463+
"ModelName", {"gpt-4o-mini"}, ...
462464
"SystemPrompt", {[]}, ...
463465
"ResponseFormat", {"text"} ...
464466
) ...
@@ -474,7 +476,7 @@ function keyNotFound(testCase)
474476
"FrequencyPenalty", {0.1}, ...
475477
"TimeOut", {10}, ...
476478
"FunctionNames", {[]}, ...
477-
"ModelName", {"gpt-3.5-turbo"}, ...
479+
"ModelName", {"gpt-4o-mini"}, ...
478480
"SystemPrompt", {[]}, ...
479481
"ResponseFormat", {"text"} ...
480482
) ...
@@ -490,7 +492,7 @@ function keyNotFound(testCase)
490492
"FrequencyPenalty", {0}, ...
491493
"TimeOut", {0.1}, ...
492494
"FunctionNames", {[]}, ...
493-
"ModelName", {"gpt-3.5-turbo"}, ...
495+
"ModelName", {"gpt-4o-mini"}, ...
494496
"SystemPrompt", {[]}, ...
495497
"ResponseFormat", {"text"} ...
496498
) ...
@@ -506,7 +508,7 @@ function keyNotFound(testCase)
506508
"FrequencyPenalty", {0}, ...
507509
"TimeOut", {10}, ...
508510
"FunctionNames", {[]}, ...
509-
"ModelName", {"gpt-3.5-turbo"}, ...
511+
"ModelName", {"gpt-4o-mini"}, ...
510512
"SystemPrompt", {[]}, ...
511513
"ResponseFormat", {"json"} ...
512514
) ...
@@ -566,7 +568,7 @@ function keyNotFound(testCase)
566568
"Error","MATLAB:validators:mustBeMember"),...
567569
...
568570
"InvalidModelNameSize",struct( ...
569-
"Input",{{ "ModelName", ["gpt-3.5-turbo", "gpt-3.5-turbo"] }},...
571+
"Input",{{ "ModelName", ["gpt-4o-mini", "gpt-4o-mini"] }},...
570572
"Error","MATLAB:validation:IncompatibleSize"),...
571573
...
572574
"InvalidModelNameOption",struct( ...

0 commit comments

Comments
 (0)