From e37294c921e554f16c8861570b157c8be8286b16 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Fri, 2 Feb 2024 12:37:21 -0800 Subject: [PATCH] (test) improve exceptions for pplx AI --- litellm/tests/test_exceptions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/litellm/tests/test_exceptions.py b/litellm/tests/test_exceptions.py index 1800cbc5ee..d4a73c8670 100644 --- a/litellm/tests/test_exceptions.py +++ b/litellm/tests/test_exceptions.py @@ -455,15 +455,21 @@ def test_completion_perplexity_exception_on_openai_client(): # delete perplexityai api key to simulate bad api key del os.environ["PERPLEXITYAI_API_KEY"] + + # temporaily delete openai api key + original_openai_key = os.environ["OPENAI_API_KEY"] del os.environ["OPENAI_API_KEY"] + response = completion( model="perplexity/mistral-7b-instruct", messages=[{"role": "user", "content": "hello"}], ) os.environ["PERPLEXITYAI_API_KEY"] = old_azure_key + os.environ["OPENAI_API_KEY"] = original_openai_key pytest.fail("Request should have failed - bad api key") except openai.AuthenticationError as e: os.environ["PERPLEXITYAI_API_KEY"] = old_azure_key + os.environ["OPENAI_API_KEY"] = original_openai_key print("exception: ", e) assert ( "perplexity.perplexityError: The api_key client option must be set either by passing api_key to the client or by setting the PERPLEXITY_API_KEY environment variable"