-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(testing) - add e2e tests for anthropic pass through endpoints (#6840)
* tests - add e2e tests for anthropic pass through * fix swagger * fix pass through tests
- Loading branch information
1 parent
c107bae
commit cc1f8ff
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
This test ensures that the proxy can passthrough anthropic requests | ||
""" | ||
|
||
import pytest | ||
import anthropic | ||
|
||
client = anthropic.Anthropic( | ||
base_url="http://0.0.0.0:4000/anthropic", api_key="sk-1234" | ||
) | ||
|
||
|
||
def test_anthropic_basic_completion(): | ||
print("making basic completion request to anthropic passthrough") | ||
response = client.messages.create( | ||
model="claude-3-5-sonnet-20241022", | ||
max_tokens=1024, | ||
messages=[{"role": "user", "content": "Say 'hello test' and nothing else"}], | ||
) | ||
print(response) | ||
|
||
|
||
def test_anthropic_streaming(): | ||
print("making streaming request to anthropic passthrough") | ||
collected_output = [] | ||
|
||
with client.messages.stream( | ||
max_tokens=10, | ||
messages=[ | ||
{"role": "user", "content": "Say 'hello stream test' and nothing else"} | ||
], | ||
model="claude-3-5-sonnet-20241022", | ||
) as stream: | ||
for text in stream.text_stream: | ||
collected_output.append(text) | ||
|
||
full_response = "".join(collected_output) | ||
print(full_response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
This test ensures that the proxy can passthrough anthropic requests | ||
""" | ||
|
||
import pytest | ||
import anthropic | ||
|
||
client = anthropic.Anthropic( | ||
base_url="http://0.0.0.0:4000/anthropic", api_key="sk-1234" | ||
) | ||
|
||
|
||
def test_anthropic_basic_completion(): | ||
print("making basic completion request to anthropic passthrough") | ||
response = client.messages.create( | ||
model="claude-3-5-sonnet-20241022", | ||
max_tokens=1024, | ||
messages=[{"role": "user", "content": "Say 'hello test' and nothing else"}], | ||
) | ||
print(response) | ||
|
||
|
||
def test_anthropic_streaming(): | ||
print("making streaming request to anthropic passthrough") | ||
collected_output = [] | ||
|
||
with client.messages.stream( | ||
max_tokens=10, | ||
messages=[ | ||
{"role": "user", "content": "Say 'hello stream test' and nothing else"} | ||
], | ||
model="claude-3-5-sonnet-20241022", | ||
) as stream: | ||
for text in stream.text_stream: | ||
collected_output.append(text) | ||
|
||
full_response = "".join(collected_output) | ||
print(full_response) |