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 fix - anthropic deprecated claude 2
Ishaan Jaff4a7b9dee5f3c
diff --git a/tests/llm_translation/test_anthropic_text_completion.py b/tests/llm_translation/test_anthropic_text_completion.pydeleted file mode 100644index c0aa5b5d88d..00000000000--- a/tests/llm_translation/test_anthropic_text_completion.py+++ /dev/null@@ -1,73 +0,0 @@-import asyncio-import os-import sys-import traceback--from dotenv import load_dotenv--import litellm.types-import litellm.types.utils-from litellm.llms.anthropic.chat import ModelResponseIterator--load_dotenv()-import io-import os--sys.path.insert(- 0, os.path.abspath("../..")-) # Adds the parent directory to the system path-from typing import Optional-from unittest.mock import MagicMock, patch--import pytest--[email protected]("model", ["claude-2", "anthropic/claude-2"])[email protected](retries=6, delay=1)-async def test_acompletion_claude2(model):- try:- litellm.set_verbose = True- messages = [- {- "role": "system",- "content": "Your goal is generate a joke on the topic user gives.",- },- {"role": "user", "content": "Generate a 3 liner joke for me"},- ]- # test without max-tokens- response = await litellm.acompletion(model=model, messages=messages)- # Add any assertions here to check the response- print(response)- print(response.usage)- print(response.usage.completion_tokens)- print(response["usage"]["completion_tokens"])- # print("new cost tracking")- except litellm.InternalServerError:- pytest.skip("model is overloaded.")- except Exception as e:- pytest.fail(f"Error occurred: {e}")---async def test_acompletion_claude2_stream():- try:- litellm.set_verbose = False- messages = [- {- "role": "system",- "content": "Your goal is generate a joke on the topic user gives.",- },- {"role": "user", "content": "Generate a 3 liner joke for me"},- ]- # test without max-tokens- response = await litellm.acompletion(- model="anthropic_text/claude-2",- messages=messages,- stream=True,- max_tokens=10,- )- async for chunk in response:- print(chunk)- except Exception as e:- pytest.fail(f"Error occurred: {e}")diff --git a/tests/local_testing/test_streaming.py b/tests/local_testing/test_streaming.pyindex d989302c635..5db40946772 100644--- a/tests/local_testing/test_streaming.py+++ b/tests/local_testing/test_streaming.py@@ -642,7 +642,6 @@ def test_completion_ollama_hosted_stream():"model",[# "claude-3-5-haiku-20241022",- # "claude-2",# "mistral/mistral-small-latest","openrouter/openai/gpt-4o-mini",],@@ -673,36 +672,6 @@ def test_completion_model_stream(model):pytest.fail(f"Error occurred: {e}")-async def test_acompletion_claude_2_stream():- try:- litellm.set_verbose = True- response = await litellm.acompletion(- model="claude-2.1",- messages=[{"role": "user", "content": "hello from litellm"}],- stream=True,- )- complete_response = ""- # Add any assertions here to check the response- idx = 0- async for chunk in response:- print(chunk)- # print(chunk.choices[0].delta)- chunk, finished = streaming_format_tests(idx, chunk)- if finished:- break- complete_response += chunk- idx += 1- if complete_response.strip() == "":- raise Exception("Empty response received")- print(f"completion_response: {complete_response}")- except litellm.InternalServerError:- pass- except litellm.RateLimitError:- pass- except Exception as e:- pytest.fail(f"Error occurred: {e}")-@pytest.mark.parametrize("sync_mode",