test - async claude streaming

This commit is contained in:
Ishaan Jaff
2024-04-06 17:55:26 -07:00
parent 2cf41d3d9f
commit 548b2b6861
+6 -3
View File
@@ -831,22 +831,25 @@ def test_bedrock_claude_3_streaming():
pytest.fail(f"Error occurred: {e}")
def test_claude_3_streaming_finish_reason():
@pytest.mark.asyncio
async def test_claude_3_streaming_finish_reason():
try:
litellm.set_verbose = True
messages = [
{"role": "system", "content": "Be helpful"},
{"role": "user", "content": "What do you know?"},
]
response: ModelResponse = completion( # type: ignore
response: ModelResponse = await litellm.acompletion( # type: ignore
model="claude-3-opus-20240229",
messages=messages,
stream=True,
max_tokens=10,
)
complete_response = ""
# Add any assertions here to check the response
num_finish_reason = 0
for idx, chunk in enumerate(response):
async for chunk in response:
print(f"chunk: {chunk}")
if isinstance(chunk, ModelResponse):
if chunk.choices[0].finish_reason is not None:
num_finish_reason += 1