From f7a5b31b96fe9e8c71c1e97f7e4cb3d8d4c61c76 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Thu, 23 Nov 2023 16:50:29 -0800 Subject: [PATCH] (test) azure test passing key as completion param --- litellm/tests/test_completion.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index fe98e178db..f0a26c6521 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -573,6 +573,30 @@ def test_completion_hf_model_no_provider(): # pytest.fail(f"Error occurred: {e}") # test_completion_openai_azure_with_functions() +def test_completion_azure_key_completion_arg(): + # this tests if we can pass api_key to completion, when it's not in the env + # DO NOT REMOVE THIS TEST. No MATTER WHAT Happens. + # If you want to remove it, speak to Ishaan! + # Ishaan will be very disappointed if this test is removed -> this is a standard way to pass api_key + the router + proxy use this + old_key = os.environ["AZURE_API_KEY"] + os.environ.pop("AZURE_API_KEY", None) + try: + print("azure gpt-3.5 test\n\n") + litellm.set_verbose=True + ## Test azure call + response = completion( + model="azure/chatgpt-v-2", + messages=messages, + api_key=old_key, + max_tokens=10, + ) + print(f"response: {response}") + print(response) + os.environ["AZURE_API_KEY"] = old_key + except Exception as e: + os.environ["AZURE_API_KEY"] = old_key + pytest.fail(f"Error occurred: {e}") +test_completion_azure_key_completion_arg() def test_completion_azure(): try: