Skip to content

Commit

Permalink
Rename Model to ModelName
Browse files Browse the repository at this point in the history
For consistency between `ollamaChat` and `openAIChat`.
  • Loading branch information
ccreutzi committed Oct 9, 2024
1 parent 13ba080 commit 2d73681
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions functionSignatures.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]},
Expand All @@ -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"]},
Expand Down
14 changes: 7 additions & 7 deletions ollamaChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -106,7 +106,7 @@
end
end

this.Model = modelName;
this.ModelName = modelName;
this.ResponseFormat = nvp.ResponseFormat;
this.Temperature = nvp.Temperature;
this.TopP = nvp.TopP;
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,...
Expand Down
2 changes: 1 addition & 1 deletion tests/topenAIChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions tests/topenAIImages.m
Original file line number Diff line number Diff line change
Expand Up @@ -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", ...
Expand All @@ -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", ...
Expand All @@ -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",...
Expand Down

0 comments on commit 2d73681

Please sign in to comment.