Skip to content

Commit 098c830

Browse files
committed
Update list of supported models on OpenAI
Add o1, remove the deprecated 3.5-0613 models. Change examples from outdated 3.5-turbo models to newer ones (picked at random). `topenAIChat/canUseModel` needed a change because the o1 models error with `MaxNumTokens=1`, as they need a few tokens to get the multiple stages started.
1 parent 11a54ea commit 098c830

8 files changed

+39
-35
lines changed

Diff for: +llms/+openai/models.m

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
function models = models
22
%MODELS - supported OpenAI models
33

4-
% Copyright 2024 The MathWorks, Inc.
4+
% Copyright 2024-2025 The MathWorks, Inc.
55
models = [...
6-
"gpt-4o","gpt-4o-2024-05-13",...
6+
"gpt-4o","gpt-4o-2024-05-13","gpt-4o-2024-08-06","gpt-4o-2024-11-20",...
7+
"chatgpt-4o-latest",...
78
"gpt-4o-mini","gpt-4o-mini-2024-07-18",...
8-
"gpt-4-turbo","gpt-4-turbo-2024-04-09",...
9-
"gpt-4","gpt-4-0613", ...
9+
"gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-4-turbo-preview",...
10+
"gpt-4","gpt-4-0125-preview","gpt-4-0613","gpt-4-1106-preview",...
1011
"gpt-3.5-turbo","gpt-3.5-turbo-0125", ...
1112
"gpt-3.5-turbo-1106",...
12-
"o1-preview",...
13-
"o1-mini",...
13+
"gpt-3.5-turbo-16k",...
14+
"o1-preview","o1-preview-2024-09-12",...
15+
"o1-mini","o1-mini-2024-09-12",...
16+
"o1","o1-2024-12-17",...
1417
];
1518
end

Diff for: +llms/+openai/validateResponseFormat.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function validateResponseFormat(format,model,messages)
99
end
1010

1111
if isequal(format, "json")
12-
if ismember(model,["gpt-4","gpt-4-0613","o1-preview","o1-mini"])
12+
if ismember(model,["gpt-4","gpt-4-0613","o1-preview","o1-mini","o1"])
1313
error("llms:invalidOptionAndValueForModel", ...
1414
llms.utils.errorMessageCatalog.getMessage("llms:invalidOptionAndValueForModel", "ResponseFormat", "json", model));
1515
elseif nargin > 2

Diff for: doc/OpenAI.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ To start using the OpenAI APIs, you first need to obtain OpenAI API keys. You ar
66

77
Some of the current LLMs supported on OpenAI are:
88
- gpt-4o-mini, gpt-4o-mini-2024-07-18
9-
- o1-preview, o1-mini
9+
- o1, o1-mini
1010
- gpt-3.5-turbo, gpt-3.5-turbo-1106, gpt-3.5-turbo-0125
1111
- gpt-4o, gpt-4o-2024-05-13 (GPT-4 Omni)
1212
- gpt-4-turbo, gpt-4-turbo-2024-04-09 (GPT-4 Turbo with Vision)

Diff for: examples/AnalyzeTextDataUsingParallelFunctionCallwithChatGPT.md

+19-14
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ This example contains four steps:
1818

1919
To run this example, you need a valid API key from a paid OpenAI™ API account.
2020

21-
```matlab
22-
loadenv(".env")
23-
addpath('../..')
24-
```
2521
# Extracting data from text
2622

2723
The customer record contains fictional information.
@@ -54,10 +50,10 @@ messages = messageHistory;
5450
messages = addUserMessage(messages,"Extract data from the record: " + record);
5551
```
5652

57-
Create a chat object. Specify the model to be `"gpt-3.5-turbo"`, which supports parallel function calls.
53+
Create a chat object. Specify the model to be `"gpt-4o-mini"`, which supports parallel function calls.
5854

5955
```matlab
60-
model = "gpt-3.5-turbo";
56+
model = "gpt-4o-mini";
6157
chat = openAIChat("You are an AI assistant designed to extract customer data.","ModelName",model,Tools=f);
6258
```
6359

@@ -105,10 +101,10 @@ f = addParameter(f,"minAge",type="integer",description="The minimum customer age
105101
f = addParameter(f,"maxAge",type="integer",description="The maximum customer age",RequiredParameter=true);
106102
```
107103

108-
Create a chat object with a latest model.
104+
Create a chat object.
109105

110106
```matlab
111-
model = "gpt-3.5-turbo";
107+
model = "gpt-4o-mini";
112108
chat = openAIChat("You are an AI assistant designed to search customer data.",ModelName=model,Tools=f);
113109
```
114110

@@ -130,7 +126,7 @@ end
130126

131127
```matlabTextOutput
132128
tcalls = struct with fields:
133-
id: 'call_JKENvUzMbNclCTI8GTBmY7YT'
129+
id: 'call_t4ECuPMLP5mCuRCDG8ZnyjDY'
134130
type: 'function'
135131
function: [1x1 struct]
136132
@@ -161,10 +157,19 @@ end
161157

162158
```matlabTextOutput
163159
txt =
164-
"The customers who are under 30 and older than 27 are:
165-
1. Jane Smith (age 28)
166-
2. Alex Lee (age 29)
167-
3. Liam Tanaka (age 28)"
160+
"Here are the customers who are under 30 and older than 27:
161+
162+
1. **Jane Smith**
163+
- Age: 28
164+
165+
166+
2. **Alex Lee**
167+
- Age: 29
168+
169+
170+
3. **Liam Tanaka**
171+
- Age: 28
172+
168173
169174
```
170175
# Helper functions
@@ -214,5 +219,5 @@ function msg = processToolCalls(data, msg, toolCalls)
214219
end
215220
```
216221

217-
*Copyright 2024 The MathWorks, Inc.*
222+
*Copyright 2024\-2025 The MathWorks, Inc.*
218223

Diff for: examples/CreateSimpleChatBot.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,14 @@ When you run this example, an interactive AI chat starts in the MATLAB® Command
1515

1616
To run this example, you need a valid API key from a paid OpenAI™ API account.
1717

18-
```matlab
19-
loadenv(".env")
20-
addpath('../..')
21-
```
2218
# Setup Model
2319

24-
Set the maximum allowable number of words per chat session and define the keyword that, when entered by the user, ends the chat session. This example uses the model `gpt-3.5-turbo`.
20+
Set the maximum allowable number of words per chat session and define the keyword that, when entered by the user, ends the chat session. This example uses the model o1.
2521

2622
```matlab
2723
wordLimit = 2000;
2824
stopWord = "end";
29-
modelName = "gpt-3.5-turbo";
25+
modelName = "o1";
3026
```
3127

3228
Create an instance of `openAIChat` to perform the chat and `messageHistory` to store the conversation history`.`
@@ -115,15 +111,15 @@ end
115111

116112
```matlabTextOutput
117113
User: Hello, how much do you know about physics?
118-
AI: I am knowledgeable about various topics in physics. How can I assist you today?
114+
AI: I have broad knowledge spanning classical, relativistic, and quantum physics.
119115
User: What is torque?
120-
AI: Torque is a measure of the rotational force applied to an object.
116+
AI: Torque is a measure of how a force causes rotational motion around an axis.
121117
User: What is force?
122-
AI: Force is a push or pull that causes an object to accelerate or change its motion.
118+
AI: Force is an interaction that changes an object's state of motion.
123119
User: What is motion?
124-
AI: Motion is the change in position of an object over time in relation to a reference point.
120+
AI: Motion is the change in an object's position over time.
125121
User: What is time?
126-
AI: Time is a measurable period during which an action, process, or condition exists or continues.
122+
AI: Time is the dimension in which events occur sequentially from past to future.
127123
User: end
128124
AI: Closing the chat. Have a great day!
129125
```
@@ -137,5 +133,5 @@ function numWords = countNumWords(text)
137133
end
138134
```
139135

140-
*Copyright 2023\-2024 The MathWorks, Inc.*
136+
*Copyright 2023\-2025 The MathWorks, Inc.*
141137

Binary file not shown.

Diff for: examples/mlx-scripts/CreateSimpleChatBot.mlx

-88 Bytes
Binary file not shown.

Diff for: tests/topenAIChat.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function constructChatWithAllNVP(testCase)
4747
function canUseModel(testCase,ModelName)
4848
testCase.verifyClass(generate(...
4949
openAIChat(ModelName=ModelName), ...
50-
"hi",MaxNumTokens=1), ...
50+
"hi",MaxNumTokens=42), ...
5151
"string");
5252
end
5353

0 commit comments

Comments
 (0)