mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
(test) improve exceptions for pplx AI
This commit is contained in:
parent
4473c48e2b
commit
e37294c921
1 changed files with 6 additions and 0 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue