Skip to content

Commit 2666f5f

Browse files
committed
Update tazureChat.m
Add test for all different APIVersion values
1 parent 05c861b commit 2666f5f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/tazureChat.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
InvalidGenerateInput = iGetInvalidGenerateInput;
99
InvalidValuesSetters = iGetInvalidValuesSetters;
1010
StringInputs = struct('string',{"hi"},'char',{'hi'},'cellstr',{{'hi'}});
11+
APIVersions = iGetAPIVersions();
1112
end
1213

1314
methods(Test)
@@ -150,6 +151,19 @@ function keyNotFound(testCase)
150151
unsetenv("AZURE_OPENAI_API_KEY");
151152
testCase.verifyError(@()azureChat, "llms:keyMustBeSpecified");
152153
end
154+
155+
function canUseAPIVersions(testCase, APIVersions)
156+
% Test that we can use different APIVersion value to call
157+
% azureChat.generate
158+
159+
testCase.assumeTrue(isenv("AZURE_OPENAI_API_KEY"),"end-to-end test requires environment variables AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, and AZURE_OPENAI_DEPLOYMENT.");
160+
chat = azureChat("APIVersion", APIVersions);
161+
162+
response = testCase.verifyWarningFree(@() generate(chat,"How similar is the DNA of a cat and a tiger?"));
163+
testCase.verifyClass(response,'string');
164+
testCase.verifyGreaterThan(strlength(response),0);
165+
166+
end
153167
end
154168
end
155169

@@ -446,3 +460,11 @@ function keyNotFound(testCase)
446460
"Input",{{ validMessages "ToolChoice" ["validfunction", "validfunction"] }},...
447461
"Error","MATLAB:validators:mustBeTextScalar"));
448462
end
463+
464+
function apiVersions = iGetAPIVersions()
465+
apiVersions = struct("2024-05-01-preview", "2024-05-01-preview", ...
466+
"2024-04-01-preview", "2024-04-01-preview", ...
467+
"2024-03-01-preview", "2024-03-01-preview", ...
468+
"2024-02-01", "2024-02-01", ...
469+
"2023-05-15", "2023-05-15");
470+
end

0 commit comments

Comments
 (0)