Skip to content

Commit

Permalink
Merge pull request #72 from matlab-deep-learning/img-descriptions
Browse files Browse the repository at this point in the history
Allow "pepper" or "vegetable"
  • Loading branch information
ccreutzi committed Aug 6, 2024
2 parents 2cbda4d + b5ad5d5 commit 150d9c1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/tollamaChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,20 @@ function seedFixesResult(testCase)
end

function generateWithImages(testCase)
import matlab.unittest.constraints.ContainsSubstring
chat = ollamaChat("moondream");
image_path = "peppers.png";
emptyMessages = messageHistory;
messages = addUserMessageWithImages(emptyMessages,"What is in the image?",image_path);

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

function streamFunc(testCase)
Expand Down

0 comments on commit 150d9c1

Please sign in to comment.