Skip to content

Commit 150d9c1

Browse files
authored
Merge pull request #72 from matlab-deep-learning/img-descriptions
Allow "pepper" or "vegetable"
2 parents 2cbda4d + b5ad5d5 commit 150d9c1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/tollamaChat.m

+9-2
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,20 @@ function seedFixesResult(testCase)
9999
end
100100

101101
function generateWithImages(testCase)
102+
import matlab.unittest.constraints.ContainsSubstring
102103
chat = ollamaChat("moondream");
103104
image_path = "peppers.png";
104105
emptyMessages = messageHistory;
105106
messages = addUserMessageWithImages(emptyMessages,"What is in the image?",image_path);
106107

107-
text = generate(chat,messages);
108-
testCase.verifyThat(text,matlab.unittest.constraints.ContainsSubstring("pepper"));
108+
% The moondream model is small and unreliable. We are not
109+
% testing the model, we are testing that we send images to
110+
% Ollama in the right way. So we just ask several times and
111+
% are happy when one of the responses mentions "pepper" or
112+
% "vegetable".
113+
text = arrayfun(@(~) generate(chat,messages), 1:5, UniformOutput=false);
114+
text = join([text{:}],newline+"-----"+newline);
115+
testCase.verifyThat(text,ContainsSubstring("pepper") | ContainsSubstring("vegetable"));
109116
end
110117

111118
function streamFunc(testCase)

0 commit comments

Comments
 (0)