testing fix - skip rate limit errors from anthropic api

This commit is contained in:
Ishaan Jaff 2024-08-01 12:12:50 -07:00
parent bae8be340e
commit dce8e3efb8

View file

@ -695,26 +695,31 @@ def test_completion_claude_2_stream():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_acompletion_claude_2_stream(): async def test_acompletion_claude_2_stream():
litellm.set_verbose = True try:
response = await litellm.acompletion( litellm.set_verbose = True
model="claude-2", response = await litellm.acompletion(
messages=[{"role": "user", "content": "hello from litellm"}], model="claude-2",
stream=True, messages=[{"role": "user", "content": "hello from litellm"}],
) stream=True,
complete_response = "" )
# Add any assertions here to check the response complete_response = ""
idx = 0 # Add any assertions here to check the response
async for chunk in response: idx = 0
print(chunk) async for chunk in response:
# print(chunk.choices[0].delta) print(chunk)
chunk, finished = streaming_format_tests(idx, chunk) # print(chunk.choices[0].delta)
if finished: chunk, finished = streaming_format_tests(idx, chunk)
break if finished:
complete_response += chunk break
idx += 1 complete_response += chunk
if complete_response.strip() == "": idx += 1
raise Exception("Empty response received") if complete_response.strip() == "":
print(f"completion_response: {complete_response}") raise Exception("Empty response received")
print(f"completion_response: {complete_response}")
except litellm.RateLimitError:
pass
except Exception as e:
pytest.fail(f"Error occurred: {e}")
def test_completion_palm_stream(): def test_completion_palm_stream():