The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test: update unit testing
Krrish Dholakiaf5aa24c3eb83
diff --git a/tests/llm_translation/test_openai.py b/tests/llm_translation/test_openai.pyindex d925f636bd7..8e6ab53df71 100644--- a/tests/llm_translation/test_openai.py+++ b/tests/llm_translation/test_openai.py@@ -456,24 +456,42 @@ class TestOpenAIGPT4OAudioTranscription(BaseLLMAudioTranscriptionTest):def get_custom_llm_provider(self) -> litellm.LlmProviders:return litellm.LlmProviders.OPENAI+@pytest.mark.asyncio@pytest.mark.parametrize("model", ["gpt-4o"])async def test_openai_pdf_url(model):from litellm.utils import return_raw_request, CallTypes- request = return_raw_request(CallTypes.completion, {- "model": model,- "messages": [{"role": "user", "content": [{"type": "text", "text": "What is the first page of the PDF?"}, {"type": "file", "file": {"file_id": "https://arxiv.org/pdf/2303.08774"}}]}],- })+ request = return_raw_request(+ CallTypes.completion,+ {+ "model": model,+ "messages": [+ {+ "role": "user",+ "content": [+ {"type": "text", "text": "What is the first page of the PDF?"},+ {+ "type": "file",+ "file": {"file_id": "https://arxiv.org/pdf/2303.08774"},+ },+ ],+ }+ ],+ },+ )print("request: ", request)- assert "file_data" in request["raw_request_body"]["messages"][0]["content"][1]["file"]+ assert (+ "file_data" in request["raw_request_body"]["messages"][0]["content"][1]["file"]+ )@pytest.mark.parametrize("sync_mode", [True, False])@pytest.mark.asyncioasync def test_openai_codex_stream(sync_mode):from litellm.main import stream_chunk_builder+kwargs = {"model": "openai/codex-mini-latest","messages": [{"role": "user", "content": "Hey!"}],@@ -482,42 +500,46 @@ async def test_openai_codex_stream(sync_mode):chunks = []if sync_mode:- response = litellm.completion(- **kwargs- )+ response = litellm.completion(**kwargs)for chunk in response:chunks.append(chunk)else:- response = await litellm.acompletion(- **kwargs- )+ response = await litellm.acompletion(**kwargs)async for chunk in response:chunks.append(chunk)-+complete_response = stream_chunk_builder(chunks=chunks)print("complete_response: ", complete_response)assert complete_response.choices[0].message.content is not None+@pytest.mark.parametrize("sync_mode", [True, False])@pytest.mark.asyncioasync def test_openai_codex(sync_mode):-- from litellm import acompletion++ from litellm import Router++ router = Router(+ model_list=[+ {+ "model_name": "openai-codex-mini-latest",+ "litellm_params": {+ "model": "openai/codex-mini-latest",+ },+ }+ ]+ )kwargs = {- "model": "openai/codex-mini-latest",+ "model": "openai-codex-mini-latest","messages": [{"role": "user", "content": "Hey!"}],}if sync_mode:- response = litellm.completion(- **kwargs- )+ response = router.completion(**kwargs)else:- response = await litellm.acompletion(- **kwargs- )+ response = await router.acompletion(**kwargs)print("response: ", response)- assert response.choices[0].message.content is not None\ No newline at end of file+ assert response.choices[0].message.content is not None