From bd39a395f1eb33f0398bb74aa2e3f263908c65e2 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 31 Mar 2025 14:31:09 -0700 Subject: [PATCH] use new anthropic interface --- litellm/__init__.py | 2 +- litellm/anthropic/__init__.py | 4 ++++ litellm/{ => anthropic}/messages/__init__.py | 0 .../test_anthropic_messages_passthrough.py | 8 ++++---- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 litellm/anthropic/__init__.py rename litellm/{ => anthropic}/messages/__init__.py (100%) diff --git a/litellm/__init__.py b/litellm/__init__.py index a62322cef9..4db5bff11b 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -1026,7 +1026,7 @@ from .proxy.proxy_cli import run_server from .router import Router from .assistants.main import * from .batches.main import * -from .messages import * +from .anthropic import * from .batch_completion.main import * # type: ignore from .rerank_api.main import * from .llms.anthropic.experimental_pass_through.messages.handler import * diff --git a/litellm/anthropic/__init__.py b/litellm/anthropic/__init__.py new file mode 100644 index 0000000000..c56a530c3c --- /dev/null +++ b/litellm/anthropic/__init__.py @@ -0,0 +1,4 @@ +""" +Anthropic module for LiteLLM +""" +from .messages import acreate, create diff --git a/litellm/messages/__init__.py b/litellm/anthropic/messages/__init__.py similarity index 100% rename from litellm/messages/__init__.py rename to litellm/anthropic/messages/__init__.py diff --git a/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py b/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py index cb7ac0d3bf..ec268b1a24 100644 --- a/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py +++ b/tests/pass_through_unit_tests/test_anthropic_messages_passthrough.py @@ -84,7 +84,7 @@ async def test_anthropic_messages_non_streaming(): messages = [{"role": "user", "content": "Hello, can you tell me a short joke?"}] # Call the handler - response = await litellm.messages.acreate( + response = await litellm.anthropic.messages.acreate( messages=messages, api_key=api_key, model="claude-3-haiku-20240307", @@ -116,7 +116,7 @@ async def test_anthropic_messages_streaming(): # Call the handler async_httpx_client = AsyncHTTPHandler() - response = await litellm.messages.acreate( + response = await litellm.anthropic.messages.acreate( messages=messages, api_key=api_key, model="claude-3-haiku-20240307", @@ -136,7 +136,7 @@ async def test_anthropic_messages_streaming_with_bad_request(): Test the anthropic_messages with streaming request """ try: - response = await litellm.messages.acreate( + response = await litellm.anthropic.messages.acreate( messages=["hi"], api_key=os.getenv("ANTHROPIC_API_KEY"), model="claude-3-haiku-20240307", @@ -460,7 +460,7 @@ async def test_anthropic_messages_with_extra_headers(): mock_client.post = AsyncMock(return_value=mock_response) # Call the handler with extra_headers and our mocked client - response = await litellm.messages.acreate( + response = await litellm.anthropic.messages.acreate( messages=messages, api_key=api_key, model="claude-3-haiku-20240307",