mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
test - test_completion_bedrock_invalid_role_exception
This commit is contained in:
parent
23cccba070
commit
c7f74b0297
1 changed files with 29 additions and 0 deletions
|
@ -414,6 +414,35 @@ def test_completion_mistral_exception():
|
|||
# test_completion_mistral_exception()
|
||||
|
||||
|
||||
def test_completion_bedrock_invalid_role_exception():
|
||||
"""
|
||||
Test if litellm raises a BadRequestError for an invalid role on Bedrock
|
||||
"""
|
||||
try:
|
||||
litellm.set_verbose = True
|
||||
response = completion(
|
||||
model="bedrock/anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
messages=[{"role": "very-bad-role", "content": "hello"}],
|
||||
)
|
||||
print(f"response: {response}")
|
||||
print(response)
|
||||
|
||||
except Exception as e:
|
||||
assert isinstance(
|
||||
e, litellm.BadRequestError
|
||||
), "Expected BadRequestError but got {}".format(type(e))
|
||||
print("str(e) = {}".format(str(e)))
|
||||
|
||||
# This is important - We we previously returning a poorly formatted error string. Which was
|
||||
# litellm.BadRequestError: litellm.BadRequestError: Invalid Message passed in {'role': 'very-bad-role', 'content': 'hello'}
|
||||
|
||||
# IMPORTANT ASSERTION
|
||||
assert (
|
||||
(str(e))
|
||||
== "litellm.BadRequestError: Invalid Message passed in {'role': 'very-bad-role', 'content': 'hello'}"
|
||||
)
|
||||
|
||||
|
||||
def test_content_policy_exceptionimage_generation_openai():
|
||||
try:
|
||||
# this is ony a test - we needed some way to invoke the exception :(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue