Skip to content

Commit aae9205

Browse files
committed
Merge branch 'main' into test_UsingDALLEToEditImages
2 parents c0d67eb + bebf8b2 commit aae9205

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

+llms/+utils/errorMessageCatalog.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@
5656
catalog("llms:warningJsonInstruction") = "When using JSON mode, you must also prompt the model to produce JSON yourself via a system or user message.";
5757
catalog("llms:apiReturnedError") = "OpenAI API Error: {1}";
5858
catalog("llms:dimensionsMustBeSmallerThan") = "Dimensions must be less than or equal to {1}.";
59-
end
59+
end
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ function testRetrievalAugmentedGenerationUsingChatGPTandMATLAB(~)
6060
function testUsingDALLEToEditImages(~)
6161
UsingDALLEToEditImages;
6262
end
63+
64+
function testAnalyzeSentimentinTextUsingChatGPTinJSONMode(~)
65+
AnalyzeSentimentinTextUsingChatGPTinJSONMode;
66+
end
6367
end
6468

6569
end
@@ -68,4 +72,4 @@ function iCloseAll()
6872
% Close all opened figures
6973
allFig = findall(0, 'type', 'figure');
7074
close(allFig)
71-
end
75+
end

0 commit comments

Comments
 (0)