Skip to content

Commit

Permalink
Add gpt-4o-mini and make it the default
Browse files Browse the repository at this point in the history
  • Loading branch information
ccreutzi committed Jul 19, 2024
1 parent b3efaf6 commit c454452
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions +llms/+openai/models.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
% Copyright 2024 The MathWorks, Inc.
models = [...
"gpt-4o","gpt-4o-2024-05-13",...
"gpt-4o-mini","gpt-4o-mini-2024-07-18",...
"gpt-4-turbo","gpt-4-turbo-2024-04-09",...
"gpt-4","gpt-4-0613", ...
"gpt-3.5-turbo","gpt-3.5-turbo-0125", ...
Expand Down
1 change: 1 addition & 0 deletions doc/OpenAI.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Several functions in this repository connect MATLAB to the [OpenAI™ Chat Compl
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.

Some of the current LLMs supported on OpenAI are:
- gpt-4o-mini, gpt-4o-mini-2024-07-18
- gpt-3.5-turbo, gpt-3.5-turbo-1106, gpt-3.5-turbo-0125
- gpt-4o, gpt-4o-2024-05-13 (GPT-4 Omni)
- gpt-4-turbo, gpt-4-turbo-2024-04-09 (GPT-4 Turbo with Vision)
Expand Down
4 changes: 2 additions & 2 deletions openAIChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
% using one or more name-value arguments:
%
% ModelName - Name of the model to use for chat completions.
% The default value is "gpt-3.5-turbo".
% The default value is "gpt-4o-mini".
%
% Temperature - Temperature value for controlling the randomness
% of the output. Default value is 1; higher values
Expand Down Expand Up @@ -92,7 +92,7 @@
arguments
systemPrompt {llms.utils.mustBeTextOrEmpty} = []
nvp.Tools (1,:) {mustBeA(nvp.Tools, "openAIFunction")} = openAIFunction.empty
nvp.ModelName (1,1) string {mustBeModel} = "gpt-3.5-turbo"
nvp.ModelName (1,1) string {mustBeModel} = "gpt-4o-mini"
nvp.Temperature {llms.utils.mustBeValidTemperature} = 1
nvp.TopP {llms.utils.mustBeValidTopP} = 1
nvp.StopSequences {llms.utils.mustBeValidStop} = {}
Expand Down
28 changes: 15 additions & 13 deletions tests/topenAIChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function generateAcceptsMessagesAsInput(testCase)

function constructChatWithAllNVP(testCase)
functions = openAIFunction("funName");
modelName = "gpt-3.5-turbo";
modelName = "gpt-4o-mini";
temperature = 0;
topP = 1;
stop = ["[END]", "."];
Expand Down Expand Up @@ -84,7 +84,9 @@ function settingToolChoiceWithNone(testCase)
end

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

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

testCase.verifyWarning(@()chat(), "llms:warningJsonInstruction");
end
Expand Down Expand Up @@ -378,7 +380,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -394,7 +396,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {{struct("role","system","content","system prompt")}}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -410,7 +412,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -426,7 +428,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -442,7 +444,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -458,7 +460,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -474,7 +476,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0.1}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -490,7 +492,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {0.1}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"text"} ...
) ...
Expand All @@ -506,7 +508,7 @@ function keyNotFound(testCase)
"FrequencyPenalty", {0}, ...
"TimeOut", {10}, ...
"FunctionNames", {[]}, ...
"ModelName", {"gpt-3.5-turbo"}, ...
"ModelName", {"gpt-4o-mini"}, ...
"SystemPrompt", {[]}, ...
"ResponseFormat", {"json"} ...
) ...
Expand Down Expand Up @@ -566,7 +568,7 @@ function keyNotFound(testCase)
"Error","MATLAB:validators:mustBeMember"),...
...
"InvalidModelNameSize",struct( ...
"Input",{{ "ModelName", ["gpt-3.5-turbo", "gpt-3.5-turbo"] }},...
"Input",{{ "ModelName", ["gpt-4o-mini", "gpt-4o-mini"] }},...
"Error","MATLAB:validation:IncompatibleSize"),...
...
"InvalidModelNameOption",struct( ...
Expand Down

0 comments on commit c454452

Please sign in to comment.