Skip to content

Commit 1d2a9e4

Browse files
committed
test - remove anthropic_adapter tests. no longer used
1 parent 29dc67a commit 1d2a9e4

File tree

1 file changed

+0
-201
lines changed

1 file changed

+0
-201
lines changed

tests/llm_translation/test_anthropic_completion.py

-201
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
Router,
3131
adapter_completion,
3232
)
33-
from litellm.adapters.anthropic_adapter import anthropic_adapter
3433
from litellm.types.llms.anthropic import AnthropicResponse
3534
from litellm.types.utils import GenericStreamingChunk, ChatCompletionToolCallChunk
3635
from litellm.types.llms.openai import ChatCompletionToolCallFunctionChunk
@@ -40,65 +39,6 @@
4039
from base_llm_unit_tests import BaseLLMChatTest
4140

4241

43-
def test_anthropic_completion_messages_translation():
44-
messages = [{"role": "user", "content": "Hey, how's it going?"}]
45-
46-
translated_messages = AnthropicExperimentalPassThroughConfig().translate_anthropic_messages_to_openai(messages=messages) # type: ignore
47-
48-
assert translated_messages == [{"role": "user", "content": "Hey, how's it going?"}]
49-
50-
51-
def test_anthropic_completion_input_translation():
52-
data = {
53-
"model": "gpt-3.5-turbo",
54-
"messages": [{"role": "user", "content": "Hey, how's it going?"}],
55-
}
56-
translated_input = anthropic_adapter.translate_completion_input_params(kwargs=data)
57-
58-
assert translated_input is not None
59-
60-
assert translated_input["model"] == "gpt-3.5-turbo"
61-
assert translated_input["messages"] == [
62-
{"role": "user", "content": "Hey, how's it going?"}
63-
]
64-
65-
66-
def test_anthropic_completion_input_translation_with_metadata():
67-
"""
68-
Tests that cost tracking works as expected with LiteLLM Proxy
69-
70-
LiteLLM Proxy will insert litellm_metadata for anthropic endpoints to track user_api_key and user_api_key_team_id
71-
72-
This test ensures that the `litellm_metadata` is not present in the translated input
73-
It ensures that `litellm.acompletion()` will receieve metadata which is a litellm specific param
74-
"""
75-
data = {
76-
"model": "gpt-3.5-turbo",
77-
"messages": [{"role": "user", "content": "Hey, how's it going?"}],
78-
"litellm_metadata": {
79-
"user_api_key": "88dc28d0f030c55ed4ab77ed8faf098196cb1c05df778539800c9f1243fe6b4b",
80-
"user_api_key_alias": None,
81-
"user_api_end_user_max_budget": None,
82-
"litellm_api_version": "1.40.19",
83-
"global_max_parallel_requests": None,
84-
"user_api_key_user_id": "default_user_id",
85-
"user_api_key_org_id": None,
86-
"user_api_key_team_id": None,
87-
"user_api_key_team_alias": None,
88-
"user_api_key_team_max_budget": None,
89-
"user_api_key_team_spend": None,
90-
"user_api_key_spend": 0.0,
91-
"user_api_key_max_budget": None,
92-
"user_api_key_metadata": {},
93-
},
94-
}
95-
translated_input = anthropic_adapter.translate_completion_input_params(kwargs=data)
96-
97-
assert "litellm_metadata" not in translated_input
98-
assert "metadata" in translated_input
99-
assert translated_input["metadata"] == data["litellm_metadata"]
100-
101-
10242
def streaming_format_tests(chunk: dict, idx: int):
10343
"""
10444
1st chunk - chunk.get("type") == "message_start"
@@ -113,54 +53,6 @@ def streaming_format_tests(chunk: dict, idx: int):
11353
assert chunk.get("type") == "content_block_delta"
11454

11555

116-
@pytest.mark.parametrize("stream", [True]) # False
117-
def test_anthropic_completion_e2e(stream):
118-
litellm.set_verbose = True
119-
120-
litellm.adapters = [{"id": "anthropic", "adapter": anthropic_adapter}]
121-
122-
messages = [{"role": "user", "content": "Hey, how's it going?"}]
123-
response = adapter_completion(
124-
model="gpt-3.5-turbo",
125-
messages=messages,
126-
adapter_id="anthropic",
127-
mock_response="This is a fake call",
128-
stream=stream,
129-
)
130-
131-
print("Response: {}".format(response))
132-
133-
assert response is not None
134-
135-
if stream is False:
136-
assert isinstance(response, AnthropicResponse)
137-
else:
138-
"""
139-
- ensure finish reason is returned
140-
- assert content block is started and stopped
141-
- ensure last chunk is 'message_stop'
142-
"""
143-
assert isinstance(response, litellm.types.utils.AdapterCompletionStreamWrapper)
144-
finish_reason: Optional[str] = None
145-
message_stop_received = False
146-
content_block_started = False
147-
content_block_finished = False
148-
for idx, chunk in enumerate(response):
149-
print(chunk)
150-
streaming_format_tests(chunk=chunk, idx=idx)
151-
if chunk.get("delta", {}).get("stop_reason") is not None:
152-
finish_reason = chunk.get("delta", {}).get("stop_reason")
153-
if chunk.get("type") == "message_stop":
154-
message_stop_received = True
155-
if chunk.get("type") == "content_block_stop":
156-
content_block_finished = True
157-
if chunk.get("type") == "content_block_start":
158-
content_block_started = True
159-
assert content_block_started and content_block_finished
160-
assert finish_reason is not None
161-
assert message_stop_received is True
162-
163-
16456
anthropic_chunk_list = [
16557
{
16658
"type": "content_block_start",
@@ -371,99 +263,6 @@ def test_anthropic_tool_streaming():
371263
assert tool_use["index"] == correct_tool_index
372264

373265

374-
def test_anthropic_tool_calling_translation():
375-
kwargs = {
376-
"model": "claude-3-5-sonnet-20240620",
377-
"messages": [
378-
{
379-
"role": "user",
380-
"content": [
381-
{
382-
"type": "text",
383-
"text": "Would development of a software platform be under ASC 350-40 or ASC 985?",
384-
}
385-
],
386-
},
387-
{
388-
"role": "assistant",
389-
"content": [
390-
{
391-
"type": "tool_use",
392-
"id": "37d6f703-cbcc-497d-95a1-2aa24a114adc",
393-
"name": "TaskPlanningTool",
394-
"input": {
395-
"completed_steps": [],
396-
"next_steps": [
397-
{
398-
"tool_name": "AccountingResearchTool",
399-
"description": "Research ASC 350-40 to understand its scope and applicability to software development.",
400-
},
401-
{
402-
"tool_name": "AccountingResearchTool",
403-
"description": "Research ASC 985 to understand its scope and applicability to software development.",
404-
},
405-
{
406-
"tool_name": "AccountingResearchTool",
407-
"description": "Compare the scopes of ASC 350-40 and ASC 985 to determine which is more applicable to software platform development.",
408-
},
409-
],
410-
"learnings": [],
411-
"potential_issues": [
412-
"The distinction between the two standards might not be clear-cut for all types of software development.",
413-
"There might be specific circumstances or details about the software platform that could affect which standard applies.",
414-
],
415-
"missing_info": [
416-
"Specific details about the type of software platform being developed (e.g., for internal use or for sale).",
417-
"Whether the entity developing the software is also the end-user or if it's being developed for external customers.",
418-
],
419-
"done": False,
420-
"required_formatting": None,
421-
},
422-
}
423-
],
424-
},
425-
{
426-
"role": "user",
427-
"content": [
428-
{
429-
"type": "tool_result",
430-
"tool_use_id": "eb7023b1-5ee8-43b8-b90f-ac5a23d37c31",
431-
"content": {
432-
"completed_steps": [],
433-
"next_steps": [
434-
{
435-
"tool_name": "AccountingResearchTool",
436-
"description": "Research ASC 350-40 to understand its scope and applicability to software development.",
437-
},
438-
{
439-
"tool_name": "AccountingResearchTool",
440-
"description": "Research ASC 985 to understand its scope and applicability to software development.",
441-
},
442-
{
443-
"tool_name": "AccountingResearchTool",
444-
"description": "Compare the scopes of ASC 350-40 and ASC 985 to determine which is more applicable to software platform development.",
445-
},
446-
],
447-
"formatting_step": None,
448-
},
449-
}
450-
],
451-
},
452-
],
453-
}
454-
455-
from litellm.adapters.anthropic_adapter import anthropic_adapter
456-
457-
translated_params = anthropic_adapter.translate_completion_input_params(
458-
kwargs=kwargs
459-
)
460-
461-
print(translated_params["messages"])
462-
463-
assert len(translated_params["messages"]) > 0
464-
assert translated_params["messages"][0]["role"] == "user"
465-
466-
467266
def test_process_anthropic_headers_empty():
468267
result = process_anthropic_headers({})
469268
assert result == {}, "Expected empty dictionary for no input"

0 commit comments

Comments
 (0)