Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure api version tests #46

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/tazureChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
InvalidGenerateInput = iGetInvalidGenerateInput;
InvalidValuesSetters = iGetInvalidValuesSetters;
StringInputs = struct('string',{"hi"},'char',{'hi'},'cellstr',{{'hi'}});
APIVersions = iGetAPIVersions();
end

methods(Test)
Expand Down Expand Up @@ -150,6 +151,19 @@ function keyNotFound(testCase)
unsetenv("AZURE_OPENAI_API_KEY");
testCase.verifyError(@()azureChat, "llms:keyMustBeSpecified");
end

function canUseAPIVersions(testCase, APIVersions)
% Test that we can use different APIVersion value to call
% azureChat.generate

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.");
chat = azureChat("APIVersion", APIVersions);

response = testCase.verifyWarningFree(@() generate(chat,"How similar is the DNA of a cat and a tiger?"));
testCase.verifyClass(response,'string');
testCase.verifyGreaterThan(strlength(response),0);

end
end
end

Expand Down Expand Up @@ -446,3 +460,11 @@ function keyNotFound(testCase)
"Input",{{ validMessages "ToolChoice" ["validfunction", "validfunction"] }},...
"Error","MATLAB:validators:mustBeTextScalar"));
end

function apiVersions = iGetAPIVersions()
apiVersions = struct("Version_2024_05_01_preview", "2024-05-01-preview", ...
"Version_2024_04_01_preview", "2024-04-01-preview", ...
"Version_2024_03_01_preview", "2024-03-01-preview", ...
"Version_2024_02_01", "2024-02-01", ...
"Version_2023_05_15", "2023-05-15");
vpapanasta marked this conversation as resolved.
Show resolved Hide resolved
end