From 2d7368165e08cfa15161d36c2de79d4596e64fd9 Mon Sep 17 00:00:00 2001 From: Christopher Creutzig Date: Wed, 9 Oct 2024 07:33:19 +0100 Subject: [PATCH] Rename Model to ModelName For consistency between `ollamaChat` and `openAIChat`. --- functionSignatures.json | 4 ++-- ollamaChat.m | 14 +++++++------- tests/topenAIChat.m | 2 +- tests/topenAIImages.m | 18 +++++++++--------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/functionSignatures.json b/functionSignatures.json index a380251..47030ee 100644 --- a/functionSignatures.json +++ b/functionSignatures.json @@ -105,7 +105,7 @@ { "inputs": [ - {"name":"model","kind":"positional","type":"choices=ollamaChat.models"}, + {"name":"modelName","kind":"positional","type":"choices=ollamaChat.models"}, {"name":"systemPrompt","kind":"ordered","type":["string","scalar"]}, {"name":"Temperature","kind":"namevalue","type":["numeric","scalar",">=0","<=2"]}, {"name":"TopP","kind":"namevalue","type":["numeric","scalar",">=0","<=1"]}, @@ -131,7 +131,7 @@ {"name":"messages","kind":"required","type":[["messageHistory","row"],["string","scalar"]]}, {"name":"MaxNumTokens","kind":"namevalue","type":["numeric","scalar","positive"]}, {"name":"Seed","kind":"namevalue","type":["numeric","integer","scalar"]}, - {"name":"Model","kind":"namevalue","type":"choices=ollamaChat.models"}, + {"name":"ModelName","kind":"namevalue","type":"choices=ollamaChat.models"}, {"name":"Temperature","kind":"namevalue","type":["numeric","scalar",">=0","<=2"]}, {"name":"TopP","kind":"namevalue","type":["numeric","scalar",">=0","<=1"]}, {"name":"MinP","kind":"namevalue","type":["numeric","scalar",">=0","<=1"]}, diff --git a/ollamaChat.m b/ollamaChat.m index a6d7419..eaf5343 100644 --- a/ollamaChat.m +++ b/ollamaChat.m @@ -62,14 +62,14 @@ % generate - Generate a response using the ollamaChat instance. % % ollamaChat Properties, in addition to the name-value pairs above: -% Model - Model name (as expected by Ollama server). +% ModelName - Model name (as expected by Ollama server). % % SystemPrompt - System prompt. % Copyright 2024 The MathWorks, Inc. properties - Model (1,1) string + ModelName (1,1) string Endpoint (1,1) string TopK (1,1) {mustBeReal,mustBePositive} = Inf MinP (1,1) {llms.utils.mustBeValidProbability} = 0 @@ -106,7 +106,7 @@ end end - this.Model = modelName; + this.ModelName = modelName; this.ResponseFormat = nvp.ResponseFormat; this.Temperature = nvp.Temperature; this.TopP = nvp.TopP; @@ -133,8 +133,8 @@ % Seed - An integer value to use to obtain % reproducible responses % - % Model - Model name (as expected by Ollama server). - % Default value is CHAT.Model. + % ModelName - Model name (as expected by Ollama server). + % Default value is CHAT.ModelName. % % Temperature - Temperature value for controlling the randomness % of the output. Default value is CHAT.Temperature. @@ -187,7 +187,7 @@ arguments this (1,1) ollamaChat messages {mustBeValidMsgs} - nvp.Model {mustBeTextScalar} = this.Model + nvp.ModelName {mustBeTextScalar} = this.ModelName nvp.Temperature {llms.utils.mustBeValidTemperature} = this.Temperature nvp.TopP {llms.utils.mustBeValidProbability} = this.TopP nvp.MinP {llms.utils.mustBeValidProbability} = this.MinP @@ -220,7 +220,7 @@ end [text, message, response] = llms.internal.callOllamaChatAPI(... - nvp.Model, messagesStruct, ... + nvp.ModelName, messagesStruct, ... Temperature=nvp.Temperature, ... TopP=nvp.TopP, MinP=nvp.MinP, TopK=nvp.TopK,... TailFreeSamplingZ=nvp.TailFreeSamplingZ,... diff --git a/tests/topenAIChat.m b/tests/topenAIChat.m index e373994..c883c36 100644 --- a/tests/topenAIChat.m +++ b/tests/topenAIChat.m @@ -236,7 +236,7 @@ function assignValueToProperty(property, value) end function gpt35TurboErrorsForImages(testCase) - chat = openAIChat(APIKey="this-is-not-a-real-key",Model="gpt-3.5-turbo"); + chat = openAIChat(APIKey="this-is-not-a-real-key",ModelName="gpt-3.5-turbo"); image_path = "peppers.png"; emptyMessages = messageHistory; inValidMessages = addUserMessageWithImages(emptyMessages,"What is in the image?",image_path); diff --git a/tests/topenAIImages.m b/tests/topenAIImages.m index 13f9466..4ec024e 100644 --- a/tests/topenAIImages.m +++ b/tests/topenAIImages.m @@ -36,39 +36,39 @@ function keyNotFound(testCase) end function promptSizeLimit(testCase) - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-2"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-2"); testCase.verifyError(@()generate(mdl, repmat('c', 1, 1001)), "llms:promptLimitCharacter") testCase.verifyError(@()edit(mdl, which("peppers.png"), repmat('c', 1, 1001)), "llms:promptLimitCharacter") - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-3"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-3"); testCase.verifyError(@()generate(mdl, repmat('c', 1, 4001)), "llms:promptLimitCharacter") end function invalidOptionsGenerate(testCase) - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-2"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-2"); testCase.verifyError(@()generate(mdl, "cat", Quality="hd"), "llms:invalidOptionForModel") testCase.verifyError(@()generate(mdl, "cat", Style="natural"), "llms:invalidOptionForModel") testCase.verifyError(@()generate(mdl, "cat", Size="1024x1792"), "MATLAB:validators:mustBeMember") - mdl = openAIImages(ApiKey="this-is-not-a-real-key", Model="dall-e-3"); + mdl = openAIImages(ApiKey="this-is-not-a-real-key", ModelName="dall-e-3"); testCase.verifyError(@()generate(mdl, "cat", Size="256x256"), "MATLAB:validators:mustBeMember") testCase.verifyError(@()generate(mdl, "cat", NumImages=4), "llms:invalidOptionAndValueForModel") end function invalidModelEdit(testCase) validImage = string(which("peppers.png")); - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-3"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-3"); testCase.verifyError(@()edit(mdl, validImage, "cat"), "llms:functionNotAvailableForModel") end function invalidModelVariation(testCase) validImage = string(which("peppers.png")); - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-3"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-3"); testCase.verifyError(@()createVariation(mdl, validImage), ... "llms:functionNotAvailableForModel") end function generateWithAllNVP(testCase) - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-3"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-3"); testCase.verifyWarningFree(@()generate(mdl, ... "prompt", ... Quality="hd", ... @@ -79,7 +79,7 @@ function generateWithAllNVP(testCase) function editWithAllNVP(testCase) validImage = string(which("peppers.png")); - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-2"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-2"); testCase.verifyWarningFree(@()edit(mdl, ... validImage,... "prompt", ... @@ -90,7 +90,7 @@ function editWithAllNVP(testCase) function variationWithAllNVP(testCase) validImage = string(which("peppers.png")); - mdl = openAIImages(APIKey="this-is-not-a-real-key", Model="dall-e-2"); + mdl = openAIImages(APIKey="this-is-not-a-real-key", ModelName="dall-e-2"); testCase.verifyWarningFree(@()createVariation(mdl, ... validImage,... Size="512x512",...