diff --git a/tests/tazureChat.m b/tests/tazureChat.m index f56e04b..531936f 100644 --- a/tests/tazureChat.m +++ b/tests/tazureChat.m @@ -41,6 +41,14 @@ function doGenerate(testCase,StringInputs) testCase.verifyGreaterThan(strlength(response),0); end + function doGenerateUsingSystemPrompt(testCase) + 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("You are a helpful assistant"); + response = testCase.verifyWarningFree(@() generate(chat,"Hi")); + testCase.verifyClass(response,'string'); + testCase.verifyGreaterThan(strlength(response),0); + end + function generateMultipleResponses(testCase) chat = azureChat; [~,~,response] = generate(chat,"What is a cat?",NumCompletions=3); @@ -162,7 +170,26 @@ function canUseAPIVersions(testCase, 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 + function endpointNotFound(testCase) + % to verify the error, we need to unset the environment variable + % AZURE_OPENAI_ENDPOINT, if given. Use a fixture to restore the + % value on leaving the test point + import matlab.unittest.fixtures.EnvironmentVariableFixture + testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_ENDPOINT","dummy")); + unsetenv("AZURE_OPENAI_ENDPOINT"); + testCase.verifyError(@()azureChat, "llms:endpointMustBeSpecified"); + end + + function deploymentNotFound(testCase) + % to verify the error, we need to unset the environment variable + % AZURE_OPENAI_DEPLOYMENT, if given. Use a fixture to restore the + % value on leaving the test point + import matlab.unittest.fixtures.EnvironmentVariableFixture + testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_DEPLOYMENT","dummy")); + unsetenv("AZURE_OPENAI_DEPLOYMENT"); + testCase.verifyError(@()azureChat, "llms:deploymentMustBeSpecified"); end end end diff --git a/tests/tollamaChat.m b/tests/tollamaChat.m index bdbadff..6927797 100644 --- a/tests/tollamaChat.m +++ b/tests/tollamaChat.m @@ -39,6 +39,13 @@ function doGenerate(testCase,StringInputs) testCase.verifyGreaterThan(strlength(response),0); end + function doGenerateUsingSystemPrompt(testCase) + chat = ollamaChat("mistral","You are a helpful assistant"); + response = testCase.verifyWarningFree(@() generate(chat,"Hi")); + testCase.verifyClass(response,'string'); + testCase.verifyGreaterThan(strlength(response),0); + end + function extremeTopK(testCase) % setting top-k to k=1 leaves no random choice, % so we expect to get a fixed response.