From 57b22e17747003fbc5f7298ceb0dd2bf388fcf1b Mon Sep 17 00:00:00 2001 From: Christopher Creutzig <89011131+ccreutzi@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:05:50 +0200 Subject: [PATCH 1/3] Allow (long) char vectors for StopSequences --- +llms/+internal/textGenerator.m | 6 ++++++ +llms/+utils/mustBeValidStop.m | 1 + tests/topenAIChat.m | 33 ++++++++++++++++++++++++--------- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/+llms/+internal/textGenerator.m b/+llms/+internal/textGenerator.m index f6cb167..204e516 100644 --- a/+llms/+internal/textGenerator.m +++ b/+llms/+internal/textGenerator.m @@ -28,4 +28,10 @@ properties (Access=protected) StreamFun end + + methods + function hObj = set.StopSequences(hObj,value) + hObj.StopSequences = string(value); + end + end end diff --git a/+llms/+utils/mustBeValidStop.m b/+llms/+utils/mustBeValidStop.m index f3862c7..7301a2c 100644 --- a/+llms/+utils/mustBeValidStop.m +++ b/+llms/+utils/mustBeValidStop.m @@ -5,6 +5,7 @@ function mustBeValidStop(value) if ~isempty(value) mustBeVector(value); mustBeNonzeroLengthText(value); + value = string(value); % This restriction is set by the OpenAI API if numel(value)>4 error("llms:stopSequencesMustHaveMax4Elements", llms.utils.errorMessageCatalog.getMessage("llms:stopSequencesMustHaveMax4Elements")); diff --git a/tests/topenAIChat.m b/tests/topenAIChat.m index e06db55..b156b18 100644 --- a/tests/topenAIChat.m +++ b/tests/topenAIChat.m @@ -388,7 +388,6 @@ function keyNotFound(testCase) function validConstructorInput = iGetValidConstructorInput() % while it is valid to provide the key via an environment variable, % this test set does not use that, for easier setup -validFunction = openAIFunction("funName"); validConstructorInput = struct( ... "JustKey", struct( ... "Input",{{"APIKey","this-is-not-a-real-key"}}, ... @@ -396,7 +395,7 @@ function keyNotFound(testCase) "VerifyProperties", struct( ... "Temperature", {1}, ... "TopP", {1}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0}, ... "FrequencyPenalty", {0}, ... "TimeOut", {10}, ... @@ -412,7 +411,7 @@ function keyNotFound(testCase) "VerifyProperties", struct( ... "Temperature", {1}, ... "TopP", {1}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0}, ... "FrequencyPenalty", {0}, ... "TimeOut", {10}, ... @@ -428,7 +427,7 @@ function keyNotFound(testCase) "VerifyProperties", struct( ... "Temperature", {2}, ... "TopP", {1}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0}, ... "FrequencyPenalty", {0}, ... "TimeOut", {10}, ... @@ -444,7 +443,7 @@ function keyNotFound(testCase) "VerifyProperties", struct( ... "Temperature", {1}, ... "TopP", {0.2}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0}, ... "FrequencyPenalty", {0}, ... "TimeOut", {10}, ... @@ -470,13 +469,29 @@ function keyNotFound(testCase) "ResponseFormat", {"text"} ... ) ... ), ... + "StopSequencesCharVector", struct( ... + "Input",{{"APIKey","this-is-not-a-real-key","StopSequences",'supercalifragilistic'}}, ... + "ExpectedWarning", '', ... + "VerifyProperties", struct( ... + "Temperature", {1}, ... + "TopP", {1}, ... + "StopSequences", {"supercalifragilistic"}, ... + "PresencePenalty", {0}, ... + "FrequencyPenalty", {0}, ... + "TimeOut", {10}, ... + "FunctionNames", {[]}, ... + "ModelName", {"gpt-4o-mini"}, ... + "SystemPrompt", {[]}, ... + "ResponseFormat", {"text"} ... + ) ... + ), ... "PresencePenalty", struct( ... "Input",{{"APIKey","this-is-not-a-real-key","PresencePenalty",0.1}}, ... "ExpectedWarning", '', ... "VerifyProperties", struct( ... "Temperature", {1}, ... "TopP", {1}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0.1}, ... "FrequencyPenalty", {0}, ... "TimeOut", {10}, ... @@ -492,7 +507,7 @@ function keyNotFound(testCase) "VerifyProperties", struct( ... "Temperature", {1}, ... "TopP", {1}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0}, ... "FrequencyPenalty", {0.1}, ... "TimeOut", {10}, ... @@ -508,7 +523,7 @@ function keyNotFound(testCase) "VerifyProperties", struct( ... "Temperature", {1}, ... "TopP", {1}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0}, ... "FrequencyPenalty", {0}, ... "TimeOut", {0.1}, ... @@ -524,7 +539,7 @@ function keyNotFound(testCase) "VerifyProperties", struct( ... "Temperature", {1}, ... "TopP", {1}, ... - "StopSequences", {{}}, ... + "StopSequences", {string([])}, ... "PresencePenalty", {0}, ... "FrequencyPenalty", {0}, ... "TimeOut", {10}, ... From 172a4daebe9aeb130b72de5ca5e36e6e07fc7f78 Mon Sep 17 00:00:00 2001 From: Christopher Creutzig <89011131+ccreutzi@users.noreply.github.com> Date: Fri, 2 Aug 2024 13:53:12 +0200 Subject: [PATCH 2/3] Replace bakllava by moondream moondream is a much smaller vision model and perfectly suitable for the tests we want to run. --- .github/workflows/ci.yml | 2 +- tests/tollamaChat.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7babcc..6be9f48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - name: Pull models run: | ollama pull mistral - ollama pull bakllava + ollama pull moondream OLLAMA_HOST=127.0.0.1:11435 ollama pull qwen2:0.5b - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 diff --git a/tests/tollamaChat.m b/tests/tollamaChat.m index 1040c4a..52d1376 100644 --- a/tests/tollamaChat.m +++ b/tests/tollamaChat.m @@ -99,7 +99,7 @@ function seedFixesResult(testCase) end function generateWithImages(testCase) - chat = ollamaChat("bakllava"); + chat = ollamaChat("moondream"); image_path = "peppers.png"; emptyMessages = messageHistory; messages = addUserMessageWithImages(emptyMessages,"What is in the image?",image_path); From 5fa9534a7a4d45394b58380e06579998a2c2fe0c Mon Sep 17 00:00:00 2001 From: Christopher Creutzig <89011131+ccreutzi@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:34:29 +0200 Subject: [PATCH 3/3] Create CODEOWNERS --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..cf5aa55 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# Code owners, to get auto-filled reviewer lists + +# To start with, we just assume everyone in the core team is included on all reviews +* @adulai @ccreutzi @debymf @MiriamScharnke @vpapanasta \ No newline at end of file