diff --git a/azureChat.m b/azureChat.m index fccf7da..27bdded 100644 --- a/azureChat.m +++ b/azureChat.m @@ -103,11 +103,11 @@ function this = azureChat(systemPrompt, nvp) arguments systemPrompt {llms.utils.mustBeTextOrEmpty} = [] - nvp.Endpoint {mustBeNonzeroLengthTextScalar} - nvp.Deployment {mustBeNonzeroLengthTextScalar} + nvp.Endpoint (1,1) string {mustBeNonzeroLengthTextScalar} + nvp.Deployment (1,1) string {mustBeNonzeroLengthTextScalar} nvp.APIKey {mustBeNonzeroLengthTextScalar} nvp.Tools (1,:) {mustBeA(nvp.Tools, "openAIFunction")} = openAIFunction.empty - nvp.APIVersion (1,1) {mustBeAPIVersion} = "2024-02-01" + nvp.APIVersion (1,1) string {mustBeAPIVersion} = "2024-02-01" nvp.Temperature {llms.utils.mustBeValidTemperature} = 1 nvp.TopP {llms.utils.mustBeValidTopP} = 1 nvp.StopSequences {llms.utils.mustBeValidStop} = {} diff --git a/tests/tazureChat.m b/tests/tazureChat.m index 333b1c7..f56e04b 100644 --- a/tests/tazureChat.m +++ b/tests/tazureChat.m @@ -8,6 +8,7 @@ InvalidGenerateInput = iGetInvalidGenerateInput; InvalidValuesSetters = iGetInvalidValuesSetters; StringInputs = struct('string',{"hi"},'char',{'hi'},'cellstr',{{'hi'}}); + APIVersions = iGetAPIVersions(); end methods(Test) @@ -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 @@ -446,3 +460,7 @@ function keyNotFound(testCase) "Input",{{ validMessages "ToolChoice" ["validfunction", "validfunction"] }},... "Error","MATLAB:validators:mustBeTextScalar")); end + +function apiVersions = iGetAPIVersions() +apiVersions = cellstr(llms.azure.apiVersions); +end \ No newline at end of file