Skip to content

Commit 5851aca

Browse files
committed
Merge branch 'main' into AzureAPI
2 parents a2d65cd + 91b1c06 commit 5851aca

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

examples/UsingDALLEToEditImages.mlx

1.08 MB
Binary file not shown.
470 KB
Binary file not shown.

openAIImages.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ function mustBeValidSize(this, imagesize)
298298
% Output the images
299299
if isfield(response.Body.Data.data,"url")
300300
urls = arrayfun(@(x) string(x.url), response.Body.Data.data);
301-
images = arrayfun(@imread,urls,UniformOutput=false);
301+
images = arrayfun(@myImread,urls,UniformOutput=false);
302302
else
303303
images = [];
304304
end
@@ -357,4 +357,14 @@ function mustBeValidFileType(filePath)
357357
function mustBeNonzeroLengthTextScalar(content)
358358
mustBeNonzeroLengthText(content)
359359
mustBeTextScalar(content)
360-
end
360+
end
361+
362+
function data = myImread(URI)
363+
% imread usually, but not always, fails to read from the
364+
% https://oaidalleapiprodscus.blob.core.windows.net URLs returned by
365+
% DALL•E. Use websave instead.
366+
filename = tempname + ".png";
367+
clean = onCleanup(@() delete(filename));
368+
websave(filename,URI);
369+
data = imread(filename);
370+
end

tests/texampleTests.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
methods (TestClassSetup)
77
function setUpAndTearDowns(testCase)
8+
import matlab.unittest.fixtures.CurrentFolderFixture
9+
testCase.applyFixture(CurrentFolderFixture("../examples"));
10+
811
openAIEnvVar = "OPENAI_KEY";
912
secretKey = getenv(openAIEnvVar);
1013
% Create an empty .env file because it is expected by our .mlx
@@ -53,6 +56,15 @@ function testAnalyzeTextDataUsingParallelFunctionCallwithChatGPT(~)
5356
function testRetrievalAugmentedGenerationUsingChatGPTandMATLAB(~)
5457
RetrievalAugmentedGenerationUsingChatGPTandMATLAB;
5558
end
59+
60+
function testUsingDALLEToEditImages(~)
61+
UsingDALLEToEditImages;
62+
end
63+
64+
function testAnalyzeSentimentinTextUsingChatGPTinJSONMode(testCase)
65+
testCase.verifyWarning(@AnalyzeSentimentinTextUsingChatGPTinJSONMode,...
66+
"llms:warningJsonInstruction");
67+
end
5668
end
5769

5870
end
@@ -61,4 +73,4 @@ function iCloseAll()
6173
% Close all opened figures
6274
allFig = findall(0, 'type', 'figure');
6375
close(allFig)
64-
end
76+
end

0 commit comments

Comments
 (0)