Skip to content

Commit d42e09d

Browse files
authored
Merge pull request #52 from matlab-deep-learning/openAI-updates
gpt-4o-mini does handle images
2 parents d74ec2b + 29cf265 commit d42e09d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

+llms/+openai/validateMessageSupported.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
% only certain models support image generation
77
if iscell(message.content) && any(cellfun(@(x) isfield(x,"image_url"), message.content))
8-
if ~ismember(model,["gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-4o","gpt-4o-2024-05-13"])
8+
if ~ismember(model,["gpt-4-turbo","gpt-4-turbo-2024-04-09",...
9+
"gpt-4o-mini","gpt-4o-mini-2024-07-18",...
10+
"gpt-4o","gpt-4o-2024-05-13"])
911
error("llms:invalidContentTypeForModel", ...
1012
llms.utils.errorMessageCatalog.getMessage("llms:invalidContentTypeForModel", "Image content", model));
1113
end
-841 KB
Binary file not shown.

tests/topenAIChat.m

+12-2
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ function generateWithToolsAndStreamFunc(testCase)
173173
testCase.verifyThat(data,HasField("explanation"));
174174
end
175175

176+
function generateWithImages(testCase)
177+
chat = openAIChat;
178+
image_path = "peppers.png";
179+
emptyMessages = messageHistory;
180+
messages = addUserMessageWithImages(emptyMessages,"What is in the image?",image_path);
181+
182+
text = generate(chat,messages);
183+
testCase.verifyThat(text,matlab.unittest.constraints.ContainsSubstring("pepper"));
184+
end
185+
176186
function invalidInputsGenerate(testCase, InvalidGenerateInput)
177187
f = openAIFunction("validfunction");
178188
chat = openAIChat(Tools=f, APIKey="this-is-not-a-real-key");
@@ -189,8 +199,8 @@ function assignValueToProperty(property, value)
189199
testCase.verifyError(@()assignValueToProperty(InvalidValuesSetters.Property,InvalidValuesSetters.Value), InvalidValuesSetters.Error);
190200
end
191201

192-
function invalidGenerateInputforModel(testCase)
193-
chat = openAIChat(APIKey="this-is-not-a-real-key");
202+
function gpt35TurboErrorsForImages(testCase)
203+
chat = openAIChat(APIKey="this-is-not-a-real-key",Model="gpt-3.5-turbo");
194204
image_path = "peppers.png";
195205
emptyMessages = messageHistory;
196206
inValidMessages = addUserMessageWithImages(emptyMessages,"What is in the image?",image_path);

0 commit comments

Comments
 (0)