Skip to content

Commit

Permalink
remove local copies of mustBeNonzeroLengthTextScalar
Browse files Browse the repository at this point in the history
  • Loading branch information
ccreutzi committed Dec 13, 2024
1 parent b8bfd78 commit 25b8ffc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 36 deletions.
13 changes: 4 additions & 9 deletions azureChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@
function this = azureChat(systemPrompt, nvp)
arguments
systemPrompt {llms.utils.mustBeTextOrEmpty} = []
nvp.Endpoint (1,1) string {mustBeNonzeroLengthTextScalar}
nvp.DeploymentID (1,1) string {mustBeNonzeroLengthTextScalar}
nvp.APIKey {mustBeNonzeroLengthTextScalar}
nvp.Endpoint (1,1) string {llms.utils.mustBeNonzeroLengthTextScalar}
nvp.DeploymentID (1,1) string {llms.utils.mustBeNonzeroLengthTextScalar}
nvp.APIKey {llms.utils.mustBeNonzeroLengthTextScalar}
nvp.Tools (1,:) {mustBeA(nvp.Tools, "openAIFunction")} = openAIFunction.empty
nvp.APIVersion (1,1) string {mustBeAPIVersion} = "2024-06-01"
nvp.Temperature {llms.utils.mustBeValidTemperature} = 1
Expand Down Expand Up @@ -222,7 +222,7 @@
nvp.TopP {llms.utils.mustBeValidProbability} = this.TopP
nvp.StopSequences {llms.utils.mustBeValidStop} = this.StopSequences
nvp.ResponseFormat {llms.utils.mustBeResponseFormat} = this.ResponseFormat
nvp.APIKey {mustBeNonzeroLengthTextScalar} = this.APIKey
nvp.APIKey {llms.utils.mustBeNonzeroLengthTextScalar} = this.APIKey
nvp.PresencePenalty {llms.utils.mustBeValidPenalty} = this.PresencePenalty
nvp.FrequencyPenalty {llms.utils.mustBeValidPenalty} = this.FrequencyPenalty
nvp.TimeOut (1,1) {mustBeReal,mustBePositive} = this.TimeOut
Expand Down Expand Up @@ -325,11 +325,6 @@
end
end

function mustBeNonzeroLengthTextScalar(content)
mustBeNonzeroLengthText(content)
mustBeTextScalar(content)
end

function [functionsStruct, functionNames] = functionAsStruct(functions)
numFunctions = numel(functions);
functionsStruct = cell(1, numFunctions);
Expand Down
19 changes: 7 additions & 12 deletions messageHistory.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

arguments
this (1,1) messageHistory
name {mustBeNonzeroLengthTextScalar}
content {mustBeNonzeroLengthTextScalar}
name {llms.utils.mustBeNonzeroLengthTextScalar}
content {llms.utils.mustBeNonzeroLengthTextScalar}
end

newMessage = struct("role", "system", "name", string(name), "content", string(content));
Expand All @@ -64,7 +64,7 @@

arguments
this (1,1) messageHistory
content {mustBeNonzeroLengthTextScalar}
content {llms.utils.mustBeNonzeroLengthTextScalar}
end

newMessage = struct("role", "user", "content", string(content));
Expand Down Expand Up @@ -106,7 +106,7 @@

arguments
this (1,1) messageHistory
content {mustBeNonzeroLengthTextScalar}
content {llms.utils.mustBeNonzeroLengthTextScalar}
images (1,:) {mustBeNonzeroLengthText}
nvp.Detail string {mustBeMember(nvp.Detail,["low","high","auto"])} = "auto"
end
Expand All @@ -133,9 +133,9 @@

arguments
this (1,1) messageHistory
id {mustBeNonzeroLengthTextScalar}
name {mustBeNonzeroLengthTextScalar}
content {mustBeNonzeroLengthTextScalar}
id {llms.utils.mustBeNonzeroLengthTextScalar}
name {llms.utils.mustBeNonzeroLengthTextScalar}
content {llms.utils.mustBeNonzeroLengthTextScalar}

end

Expand Down Expand Up @@ -262,11 +262,6 @@
end
end

function mustBeNonzeroLengthTextScalar(content)
mustBeNonzeroLengthText(content)
mustBeTextScalar(content)
end

function validateRegularAssistant(content)
try
mustBeNonzeroLengthText(content)
Expand Down
9 changes: 2 additions & 7 deletions openAIChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
nvp.TopP {llms.utils.mustBeValidProbability} = 1
nvp.StopSequences {llms.utils.mustBeValidStop} = {}
nvp.ResponseFormat {llms.utils.mustBeResponseFormat} = "text"
nvp.APIKey {mustBeNonzeroLengthTextScalar}
nvp.APIKey {llms.utils.mustBeNonzeroLengthTextScalar}
nvp.PresencePenalty {llms.utils.mustBeValidPenalty} = 0
nvp.FrequencyPenalty {llms.utils.mustBeValidPenalty} = 0
nvp.TimeOut (1,1) {mustBeReal,mustBePositive} = 10
Expand Down Expand Up @@ -215,7 +215,7 @@
nvp.TopP {llms.utils.mustBeValidProbability} = this.TopP
nvp.StopSequences {llms.utils.mustBeValidStop} = this.StopSequences
nvp.ResponseFormat {llms.utils.mustBeResponseFormat} = this.ResponseFormat
nvp.APIKey {mustBeNonzeroLengthTextScalar} = this.APIKey
nvp.APIKey {llms.utils.mustBeNonzeroLengthTextScalar} = this.APIKey
nvp.PresencePenalty {llms.utils.mustBeValidPenalty} = this.PresencePenalty
nvp.FrequencyPenalty {llms.utils.mustBeValidPenalty} = this.FrequencyPenalty
nvp.TimeOut (1,1) {mustBeReal,mustBePositive} = this.TimeOut
Expand Down Expand Up @@ -306,11 +306,6 @@
end
end

function mustBeNonzeroLengthTextScalar(content)
mustBeNonzeroLengthText(content)
mustBeTextScalar(content)
end

function [functionsStruct, functionNames] = functionAsStruct(functions)
numFunctions = numel(functions);
functionsStruct = cell(1, numFunctions);
Expand Down
11 changes: 3 additions & 8 deletions openAIImages.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
function this = openAIImages(nvp)
arguments
nvp.ModelName (1,1) {mustBeMember(nvp.ModelName,["dall-e-2", "dall-e-3"])} = "dall-e-2"
nvp.APIKey {mustBeNonzeroLengthTextScalar}
nvp.APIKey {llms.utils.mustBeNonzeroLengthTextScalar}
nvp.TimeOut (1,1) {mustBeReal,mustBePositive} = 10
end

Expand Down Expand Up @@ -82,7 +82,7 @@

arguments
this (1,1) openAIImages
prompt {mustBeNonzeroLengthTextScalar}
prompt {llms.utils.mustBeNonzeroLengthTextScalar}
nvp.NumImages (1,1) {mustBePositive, mustBeInteger,...
mustBeLessThanOrEqual(nvp.NumImages,10)} = 1
nvp.Size (1,1) string {mustBeMember(nvp.Size, ["256x256", "512x512", ...
Expand Down Expand Up @@ -172,7 +172,7 @@
arguments
this (1,1) openAIImages
imagePath {mustBeValidFileType(imagePath)}
prompt {mustBeNonzeroLengthTextScalar}
prompt {llms.utils.mustBeNonzeroLengthTextScalar}
nvp.MaskImagePath {mustBeValidFileType(nvp.MaskImagePath)}
nvp.NumImages (1,1) {mustBePositive, mustBeInteger,...
mustBeLessThanOrEqual(nvp.NumImages,10)} = 1
Expand Down Expand Up @@ -337,11 +337,6 @@ function mustBeValidFileType(filePath)
mustBeLessThan(s.bytes,4e+6)
end

function mustBeNonzeroLengthTextScalar(content)
mustBeNonzeroLengthText(content)
mustBeTextScalar(content)
end

function data = myImread(URI)
% imread usually, but not always, fails to read from the
% https://oaidalleapiprodscus.blob.core.windows.net URLs returned by
Expand Down

0 comments on commit 25b8ffc

Please sign in to comment.