Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code QA - Add Azure OpenAI to base llm testing #7405

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions tests/llm_translation/base_llm_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ def test_pdf_handling(self, pdf_messages, image_url):
image_messages = [{"role": "user", "content": image_content}]

base_completion_call_args = self.get_base_completion_call_args()

if not supports_pdf_input(base_completion_call_args["model"], None):
_model = (
base_completion_call_args.get("base_model")
or base_completion_call_args["model"]
)
if not supports_pdf_input(_model, None):
pytest.skip("Model does not support image input")

response = self.completion_function(
Expand Down Expand Up @@ -193,7 +196,11 @@ class TestModel(BaseModel):
first_response: str

base_completion_call_args = self.get_base_completion_call_args()
if not supports_response_schema(base_completion_call_args["model"], None):
_model = (
base_completion_call_args.get("base_model")
or base_completion_call_args["model"]
)
if not supports_response_schema(_model, None):
pytest.skip("Model does not support response schema")

try:
Expand Down Expand Up @@ -292,7 +299,11 @@ def test_image_url(self, detail):
litellm.model_cost = litellm.get_model_cost_map(url="")

base_completion_call_args = self.get_base_completion_call_args()
if not supports_vision(base_completion_call_args["model"], None):
_model = (
base_completion_call_args.get("base_model")
or base_completion_call_args["model"]
)
if not supports_vision(_model, None):
pytest.skip("Model does not support image input")

messages = [
Expand Down Expand Up @@ -340,7 +351,11 @@ def test_prompt_caching(self):
litellm.model_cost = litellm.get_model_cost_map(url="")

base_completion_call_args = self.get_base_completion_call_args()
if not supports_prompt_caching(base_completion_call_args["model"], None):
_model = (
base_completion_call_args.get("base_model")
or base_completion_call_args["model"]
)
if not supports_prompt_caching(_model, None):
print("Model does not support prompt caching")
pytest.skip("Model does not support prompt caching")

Expand Down
30 changes: 29 additions & 1 deletion tests/llm_translation/test_azure_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

sys.path.insert(
0, os.path.abspath("../../")
) # Adds the parent directory to the system path
) # Adds the parent directory to the system-path

import pytest
from litellm.llms.azure.common_utils import process_azure_headers
from httpx import Headers
from base_embedding_unit_tests import BaseLLMEmbeddingTest
from base_llm_unit_tests import BaseLLMChatTest


def test_process_azure_headers_empty():
Expand Down Expand Up @@ -211,3 +212,30 @@ def get_base_embedding_call_args(self) -> dict:

def get_custom_llm_provider(self) -> litellm.LlmProviders:
return litellm.LlmProviders.AZURE


class TestAzureChat(BaseLLMChatTest):
def get_base_completion_call_args(self) -> dict:
return {
"model": "azure/gpt-4o-mini-json-mode",
"api_key": os.getenv("AZURE_JSON_MODE_API_KEY"),
"api_base": os.getenv("AZURE_JSON_MODE_API_BASE"),
"api_version": "2024-10-01-preview",
"base_model": "gpt-4o-mini",
}

def test_tool_call_no_arguments(self, tool_call_no_arguments):
"""Test that tool calls with no arguments is translated correctly. Relevant issue: https://github.com/BerriAI/litellm/issues/6833"""
pass

def test_prompt_caching(self):
"""
We have no way to test prompt caching for Azure OpenAI.
"At this time, only the o1 model family supports the cached_tokens API response parameter." - Azure OpenAI
Ref: https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/prompt-caching


We need the `cached_tokens` in the response to test prompt caching.

"""
pass
Loading